63 fLog <<
"deleting globals ... " ;
64 for (
size_t i = 0; i <
fGlobals.size(); i++) {
67 fLog <<
"deleting actors ... " ;
68 for (
size_t i = 0; i <
fAllActors.size(); i++) {
71 fLog <<
"deleting connections ... " ;
76 catch (std::exception &e) {
84 Bool_t add_new =
true;
86 for (
size_t j = 0; j <
fGlobals.size(); j++) {
104 std::cout <<
"[+]============================= Topology of " <<
GetName() <<
" =============================" <<
std::endl;
105 std::cout <<
" List of registered actors : " ;
106 for (UInt_t i = 0; i <
fAllActors.size(); i++ ) {
110 for (UInt_t i = 0; i <
fTopology.size(); i++ ) {
111 for (UInt_t k = 0; k < i ; k++ ) {
114 std::cout <<
"Actors @ level " << i <<
std::endl;
115 for (UInt_t j = 0; j <
fTopology[i].size() ; j++) {
116 for (UInt_t k = 0; k < i+1 ; k++ ) {
119 std::cout <<
fTopology[i][j]->GetName() <<
" has "
123 std::cout <<
"[c]============================= Topology of " <<
GetName() <<
" =============================" <<
std::endl;
124 std::cout <<
"Configured with : " <<
std::endl;
125 for (
size_t i = 0; i <
fGlobals.size(); i++) {
129 std::cout <<
"[-]============================= Topology of " <<
GetName() <<
" =============================" <<
std::endl;
141 for (UInt_t i = 0; i <
fAllActors.size(); i++ ) {
149 while ( depth >= Int_t(
fTopology.size()) ) {
151 std::vector <ALoadedActor *> vv;
169 for (UInt_t i = 0; i <
fAllActors.size(); i++ ) {
172 std::istringstream actions( GetItem<std::string>(
"InitSequence",
fGlobals)->Get() );
175 while ( actions.good() ) {
177 fLog <<
info <<
"Apply action " << action <<
" on " <<
fAllActors[i]->GetName() ;
179 Bool_t is_done =
false;
181 if ( action ==
"config" ) {
186 fLog << error <<
" : Cannot configure " <<
fAllActors[i]->GetName() <<
". CODE ERROR is : " <<
fAllActors[i]->GetLastError() <<
dolog;
187 throw std::runtime_error(std::string(
"Cannot configure"));;
191 if ( action ==
"load" ) {
196 fLog << error <<
" : Cannot Register " <<
fAllActors[i]->GetName() <<
". CODE ERROR is : " <<
fAllActors[i]->GetLastError() <<
dolog;
197 throw std::runtime_error(std::string(
"Cannot Register"));;
202 fLog << error <<
" : Cannot Register " <<
fAllActors[i]->GetName() <<
", too much inputs " <<
fAllActors[i]->GetNbInput() <<
" asked while MAX is " <<
fAllActors[i]->GetActor()->GetMaxInput() <<
dolog;
203 throw std::out_of_range(
"incompatible inputs");
206 fLog << error <<
" Cannot Register " <<
fAllActors[i]->GetName() <<
", too much outputs " <<
fAllActors[i]->GetNbOutput() <<
" asked while MAX is " <<
fAllActors[i]->GetActor()->GetMaxOutput() <<
dolog;
207 throw std::out_of_range(
"incompatible outputs");
214 if ( action ==
"init" ) {
219 fLog << error <<
" : Cannot initialise " <<
fAllActors[i]->GetName() <<
". CODE ERROR is : " <<
fAllActors[i]->GetLastError() <<
dolog;
220 throw std::runtime_error(std::string(
"Cannot initialise"));
224 if ( is_done ==
false )
225 fLog <<
warning <<
" : is NOT a valid action. Valid are config, load or init " <<
nline;
236 UInt_t nb_loop = 0u, nb_run = 0u, nb_try = 0u, max_try = 3u;
239 for (UInt_t i = 0u; i <
fAllActors.size(); i++) {
247 while ( nb_loop != (UInt_t)max_loop ) {
250 for (UInt_t i = 0; i <
fTopology.size(); i++ ) {
251 for (UInt_t j = 0; j <
fTopology[i].size() ; j++) {
276 if (
fTopology[i][j]->GetLastError() > 0u ) {
284 if ( nb_try >= max_try )
288 fLog <<
info <<
" No active actors ==> STOP emulator after " << max_try <<
" # of tries. nb_try = " << nb_try <<
" nb_loop "<< nb_loop <<
nline;
302 for (UInt_t i = 0; i <
fAllActors.size(); i++ ) {
std::vector< ANamedItem * > fGlobals
to configure the emulator. The name of each item should be unique !
header file for BaseEmulator.cpp
virtual void SetGlobal(const ANamedItem &)
This method allows to modified some options of the emulator.
std::vector< std::vector< ALoadedActor * > > fTopology
Actors are memorized depending on their depth in the data processing chain.
virtual ANamedItem * MakeAClone() const =0
clone that named item
LogMessage & error(LogMessage &)
std::string & GetName()
Name of the emulator.
LogMessage & warning(LogMessage &)
virtual void Run(Int_t max_loop=-1)
Run max loop.
LogMessage & nline(LogMessage &)
BaseEmulator(std::string name)
std::vector< AnActorConnection * > fAllConnections
list of all connections. Owned by the emulator thus delete by this
std::string GetName() const
change value of this nmaed item using the passed one. it checks if asked, it check first if of the sa...
virtual void PrintTopology()
print topology
LogMessage & info(LogMessage &)
manipulator to modify the LogMessage
An actor looded in an emulator.
virtual NarvalInterface * GetActor() const
get loaded actor, should have the narval interface
LogMessage & dolog(LogMessage &)
virtual void Init(const NamedItem< std::string > &init_sequence=NamedItem< std::string >("InitSequence","config load init"))
Init the emulator. To be called before calling Run.
ADF::LogMessage & endl(ADF::LogMessage &log)
virtual ALoadedActor * GetLoaderByName(const Char_t *) const
search for a node in the emulator
void BuildTopology()
Built the map, starting from producer is calculates the depth of each actor in the data flow...
virtual void SetProcessMethod(const char *)
To set the current method.
std::vector< ALoadedActor * > fAllActors
list of all actors to start building the map and to delete them @ the end
It defines the general interface needed to be a narval actor.
virtual NarvalInterface * GetActorByName(const Char_t *) const
search for an actor in the emulator