Diana Software
QDriver.cc
Go to the documentation of this file.
1 #include "QDriver.hh"
2 #include "QEventAssembler.hh"
3 #include "QError.hh"
4 #include "QBool.hh"
5 
7 
8 
10 {
11  Panic("Missing method: \"Action Init(QEvent& ev)\" or \"Action Init(QEventAssembler& eva)\" not implemented");
12  return ACT_NEXTEV;
13 }
14 
15 
17 {
18  Panic("Missing method: \"void Do(QEvent& ev)\" or \"void Do(QEvent& ev, const QEventList& neigh)\" not implemented");
19  return ACT_NEXTEV;
20 }
21 
23 {
24  return Do(eva);
25 }
26 
28 {
29 
30  fLastAction = Init(ev);
31  fSkipEvents = GetBool("SkipEvents",false,false);
32  if(!fSkipEvents) {
33  Info("Skip events set to false");
34  ev.GetEvent().Add<QBool>("SkipEvent").SetWrite(false);
35  }
36 
38  Error("go to previous event not supported before the event loop start");
40  }
41 
43  SetNeedNeighbours(false);
44 }
45 
46 void QDriver::End()
47 {
49  fLastAction = Done();
51  }
52 }
53 
54 bool QDriver::Process(QEventAssembler& eva, QEventList& neigh,const bool exec,QEventList& oneigh)
55 {
56  if(!fSkipEvents) eva.GetEvent().Get<QBool>("SkipEvent") = !exec;
57 
59  QEvent& ev = eva.GetEvent();
60  if(fSkipEvents) fLastAction = Do(eva,oneigh);
61  else fLastAction = Do(eva,neigh);
62  fExecuted = true;
65  }
66 
67  if(fSkip) return false;
68  return exec;
69 }
70 
72 {
73  fStopRun = false;
74  fSkip = false;
75 
76  switch (action.fActionId) {
77  case ACT_NEXTEV:
78  break;
79  case ACT_SKIP:
80  fSkip = true;
81  break;
82  case ACT_PREVEV:
83  {
85  if(err != QERR_SUCCESS)
86  Error("Error on go to previous event: %s",err.GetDescription().c_str());
87  break;
88  }
89  case ACT_GOTOEV:
90  {
92  if(err != QERR_SUCCESS)
93  Error("Action go to event %d: %s",action.fEventNumber,err.GetDescription().c_str());
94  break;
95  }
96  case ACT_RERUN:
97  {
98  fStopRun = true;
99  SetRunAgain(true);
100  break;
101  }
102  case ACT_QUIT:
103  default:
104  {
105  fStopRun = true;
106  SetRunAgain(false);
107  break;
108  }
109  };
110 }
111 
err
Definition: CheckOF.C:114
#define Q_END_NAMESPACE
Definition: QDiana.hh:22
#define Q_BEGIN_NAMESPACE
Definition: QDiana.hh:20
@ QERR_SUCCESS
Definition: QError.hh:27
void Info(const char *descr,...) const
Send an info message (information) with printf syntax.
Definition: QBaseModule.hh:218
void Error(const char *descr,...) const
Send an error message (an error that the framework cannot recover) with printf syntax.
Definition: QBaseModule.hh:238
void Panic(const char *descr,...) const
Send a panic message (stops the framework) with printf syntax.
Definition: QBaseModule.hh:248
bool GetBool(const std::string &parname, bool defVal, bool warnCfg=true) const
Get a bool parameter from config file ( see GetDouble() )
Definition: QBaseModule.cc:256
void SetRunAgain(bool b)
Set that the sequence will be reiterated.
Definition: QBaseModule.hh:120
void SetNeedNeighbours(bool need)
set wheter this module needs neighbours
Definition: QBaseModule.hh:169
bool wrapped into a QObject
Definition: QBool.hh:17
class to store ActionId and fEventNumber (in case fActionId=ACT_GOTOEV)
Definition: QDriver.hh:59
int fEventNumber
Definition: QDriver.hh:64
ActionId fActionId
Definition: QDriver.hh:63
void End()
End method is called after event loop and calls Done()
Definition: QDriver.cc:46
bool fStopRun
stop run or not
Definition: QDriver.hh:115
virtual Action Done()=0
Done method is called after event loop.
void Begin(QEventAssembler &eva)
Begin method is called before event loop, and calls Init()
Definition: QDriver.cc:27
virtual Action Do(QEventAssembler &eva)
Do method is called for each event, getting the QEventAssembler as argument.
Definition: QDriver.cc:16
virtual Action Init(QEventAssembler &eva)
Init method is called before event loop.
Definition: QDriver.cc:9
bool Process(QEventAssembler &eva, QEventList &neigh, const bool exec, QEventList &oneigh)
Process method is called for each event, getting the QEventAssembler as argument and calls Do()
Definition: QDriver.cc:54
int fCurrentEventNumber
current event number to make ACT_PREV use JumpToEvent(fCurrentEventNumber-1)
Definition: QDriver.hh:119
bool fSkip
skip event
Definition: QDriver.hh:117
const QError & JumpToEvent(Long64_t event)
next iteration diana will jump to event
Definition: QDriver.hh:109
void HandleAction(Action action)
internal method to handle action returned by inheriting classes
Definition: QDriver.cc:71
bool fSkipEvents
skip filtered events
Definition: QDriver.hh:123
@ ACT_PREVEV
Definition: QDriver.hh:49
@ ACT_NEXTEV
Definition: QDriver.hh:45
@ ACT_GOTOEV
Definition: QDriver.hh:51
@ ACT_RERUN
Definition: QDriver.hh:53
@ ACT_SKIP
Definition: QDriver.hh:47
@ ACT_QUIT
Definition: QDriver.hh:55
Action fLastAction
last action performed
Definition: QDriver.hh:113
error class with error type and description
Definition: QError.hh:115
Visitor class of QEvent that provides full handling of QEvent.
QEvent & GetEvent()
Get the QEvent.
list of references to const QEvent (s)
Definition: QEventList.hh:21
diana event
Definition: QEvent.hh:46
void Get(const char *owner, ReadHandle< Q > &handle) const
Get a QObject Handle in read mode.
Definition: QEvent.hh:74
unsigned int GetReadNumber() const
return the event number as read by the current reader.
Definition: QEvent.hh:60
void Add(WriteHandle< Q > &handle)
Add a QObject to the event.
Definition: QEvent.hh:193