Diana Software
QFrameWork.cc
Go to the documentation of this file.
1 /* Diana Reconstruction program
2  *
3  * Author: MP 11/11/05
4  * $Id: QFrameWork.cc 514 2006-12-01 13:45:19Z vignatim $
5  *
6  * Implementation of QFrameWork
7  *
8 */
9 
10 #include <stdexcept>
11 
12 #include "QFrameWork.hh"
13 #include "QModuleFactory.hh"
14 #include "QGeneralFactory.hh"
15 #include "QMessage.hh"
16 #include "QSequence.hh"
17 #include "QOptions.hh"
18 #include "QProcessStatus.hh"
19 
21 //_________________________________________________________________________________
23  //
24  // ctor
25  //
26 }
27 
28 //_________________________________________________________________________________
30  //
31  // dtor
32  //
33  std::list< QSequence* > &sequences = QModuleFactory::Get()->GetSequences();
34  std::list< QSequence* >::iterator it;
35  for(it = sequences.begin(); it != sequences.end(); it++) {
36  if(*it) delete (*it);
37  }
38 }
39 
40 //_________________________________________________________________________________
41 void QFrameWork::Run () {
42  //
43  // execute all program; basically, this is the main program
44  // the list of sequences is executed in order
45  //
46 
47  // run all sequences allowing iteration over each sequence
48  std::list< QSequence* > &sequences = QModuleFactory::Get()->GetSequences();
49  std::list< QSequence* >::iterator it;
50  for(it = sequences.begin(); it != sequences.end(); it++) {
51  QSequence* fCurrentSequence = *it;
52  QMessageHandler::Get()->Send(NoFilterMsg,"Framework",std::string("Starting sequence ")
53  + fCurrentSequence->GetName() );
54 
56  while(dianaStatus.isRunning() && fCurrentSequence->Run()){
57  if(dianaStatus.HasChanged())
58  dianaStatus.Notify();
59  QMessageHandler::Get()->Send(NoFilterMsg,"Framework",std::string("Restarting sequence ")
60  + fCurrentSequence->GetName() );
61  }
62  delete fCurrentSequence;
63  *it = NULL;
64  }
65 }
66 
#define Q_END_NAMESPACE
Definition: QDiana.hh:22
#define Q_BEGIN_NAMESPACE
Definition: QDiana.hh:20
@ NoFilterMsg
Definition: QMessageDefs.hh:11
void Run()
main function, basically the real main program in diana. It runs a list of sequences provided by the ...
Definition: QFrameWork.cc:41
virtual ~QFrameWork()
destructor does nothing
Definition: QFrameWork.cc:29
QFrameWork()
empty constructor
Definition: QFrameWork.cc:22
static QMessageHandler * Get()
Definition: QMessage.cc:24
void Send(MsgLevel l, const std::string &sender, const std::string &msg)
Definition: QMessage.cc:31
std::list< QSequence * > & GetSequences()
static QModuleFactory * Get()
const std::string & GetName() const
Definition: QNamed.hh:19
process status and signal handler
void Notify()
acknowledge oldest process status contained in staus queue
bool HasChanged() const
tell wehter process status has changed
static QProcessStatus & GetInstance()
get singleton Instance
bool isRunning() const
check wether current process status is QRunning_s
Diana Reconstruction program.
Definition: QSequence.hh:40
bool Run()
The core of the sequence. Loops over Init's, Do's and Done's.
Definition: QSequence.cc:90