// ESAF : Euso Simulation and Analysis Framework
// $Id: SimuFramework.cc,v 1.4 2004/09/28 12:10:36 thea Exp $
// Marco Pallavicini created Oct, 16 2003
#include "SimuFramework.hh"
#include "Config.hh"
#include "SimuModuleFactory.hh"
#include "SimuModule.hh"
ClassImp(SimuFramework)
// ctor
SimuFramework::SimuFramework() : EsafConfigurable() {
// get file name with module list
string sName = Conf()->GetStr("SimuFramework.ModuleFile");
sName = "./config/General/"+sName;
// build factory
SimuModuleFactory factory( sName );
// get modules
int counter=0;
while ( SimuModule *aModule = factory.GetModule() ) {
cout << "Loading module : " << aModule->GetName() << endl;
fModules[ aModule->GetName() ] = aModule;
counter++;
}
cout << "SimuFramework: " << counter << " modules loadedn";
}
// dtor
SimuFramework::~SimuFramework() {
}
// parse a command line
void SimuFramework::ParseCommandLine(const int&, const char**) {
}
// execute a complete run
void SimuFramework::Execute() {
map<string,SimuModule*>::const_iterator it;
// init all modules
for( it = fModules.begin(); it != fModules.end(); it++) {
if ( ! it->second->Init() ) {
cerr << "Module " << it->first << " failedn";
throw runtime_error("Init failed");
}
}
// run
// execute all modules
for( it = fModules.begin(); it != fModules.end(); it++) {
if ( ! it->second->PreProcess() )
break;
if ( ! it->second->Process() )
break;
if ( ! it->second->PostProcess() )
break;
}
// clean up
for( it = fModules.begin(); it != fModules.end(); it++) {
it->second->UserMemoryClean(); // delete user objects
//it->second->StandardMemoryClean(); // delete int and double maps
}
// end all modules
for( it = fModules.begin(); it != fModules.end(); it++) {
it->second->Done();
}
}
// dump the module list
void SimuFramework::Dump( ostream& os ) const {
os << "Framework Dumpn";
os << "The following Modules where loaded:n";
int i=1;
map<string,SimuModule*>::const_iterator it = fModules.begin();
for( ; it != fModules.end(); it++ ) {
os << "tModule: " << i++ << "t" << it->second->GetName() << endl;
}
}