source: JEM-EUSO/esaf_lal/tags/v1_r0/esaf/packages/simulation/framework/src/SimuFramework.cc @ 117

Last change on this file since 117 was 117, checked in by moretto, 11 years ago

ESAF version compilable on mac OS

File size: 2.3 KB
Line 
1// ESAF : Euso Simulation and Analysis Framework
2// $Id: SimuFramework.cc 1112 2004-09-28 12:10:53Z thea $
3// Marco Pallavicini created Oct, 16 2003
4
5#include "SimuFramework.hh"
6#include "Config.hh"
7#include "SimuModuleFactory.hh"
8#include "SimuModule.hh"
9
10ClassImp(SimuFramework)
11
12// ctor
13SimuFramework::SimuFramework() : EsafConfigurable() {
14   
15    // get file name with module list
16    string sName = Conf()->GetStr("SimuFramework.ModuleFile");
17    sName = "./config/General/"+sName;
18   
19    // build factory
20    SimuModuleFactory factory( sName );
21   
22    // get modules
23    int counter=0;
24    while ( SimuModule *aModule = factory.GetModule() ) {
25        cout << "Loading module : " << aModule->GetName() << endl;
26        fModules[ aModule->GetName() ] = aModule;
27        counter++;
28    }
29
30    cout << "SimuFramework: " << counter << " modules loaded\n";
31}
32
33// dtor
34SimuFramework::~SimuFramework() {
35}
36
37// parse a command line
38void SimuFramework::ParseCommandLine(const int&, const char**) {
39}
40
41// execute a complete run
42void SimuFramework::Execute() {
43    map<string,SimuModule*>::const_iterator it;
44
45    // init all modules
46    for( it = fModules.begin(); it != fModules.end(); it++) {
47        if ( ! it->second->Init() ) {
48            cerr << "Module " << it->first << " failed\n";
49            throw runtime_error("Init failed");
50        }
51    }
52
53    // run
54
55    // execute all modules
56    for( it = fModules.begin(); it != fModules.end(); it++) {
57        if ( ! it->second->PreProcess() )
58        break;
59    if ( ! it->second->Process() )
60        break;
61    if ( ! it->second->PostProcess() )
62        break;
63    }
64
65    // clean up
66    for( it = fModules.begin(); it != fModules.end(); it++) {
67        it->second->UserMemoryClean();      // delete user objects
68        //it->second->StandardMemoryClean();  // delete int and double maps
69    }
70
71    // end all modules
72    for( it = fModules.begin(); it != fModules.end(); it++) {
73        it->second->Done();
74    }
75}
76
77// dump the module list
78void SimuFramework::Dump( ostream& os ) const {
79    os << "Framework Dump\n";
80    os << "The following Modules where loaded:\n";
81   
82    int i=1;
83    map<string,SimuModule*>::const_iterator it = fModules.begin();
84    for( ; it != fModules.end(); it++ ) {
85        os << "\tModule: " << i++ << "\t" << it->second->GetName() << endl;
86    }
87}
88
89
Note: See TracBrowser for help on using the repository browser.