EventContext.h
Go to the documentation of this file.
1 #ifndef GAUDIKERNEL_EVENTCONTEXT_H
2 #define GAUDIKERNEL_EVENTCONTEXT_H 1
3 
4 #include <iostream>
5 #include <unistd.h>
6 #include <limits>
8 
23 class IProxyDict;
24 
26 public:
27  typedef size_t ContextID_t;
28  typedef size_t ContextEvt_t;
29 
32 
33 
35  EventContext(const ContextEvt_t& e, const ContextID_t& s=INVALID_CONTEXT_ID)
36  :m_evt_num(e), m_evt_slot(s), m_evt_failed(false) {
37  m_valid = (e == INVALID_CONTEXT_EVT || s == INVALID_CONTEXT_ID) ? false: true;
38  }
39 
40  ContextEvt_t evt() const { return m_evt_num; }
41  ContextID_t slot() const { return m_evt_slot; }
42  bool valid() const {return m_valid;}
43  bool evtFail() const { return m_evt_failed; }
44  IProxyDict* proxy() const { return m_proxy; }
45  const EventIDBase& eventID() const { return m_eid; }
46 
47  void set(const ContextEvt_t& e=0, const ContextID_t& s=INVALID_CONTEXT_ID,
48  const bool f=false) {
49  m_valid = (e == INVALID_CONTEXT_EVT || s == INVALID_CONTEXT_ID) ? false : true;
50  m_evt_num = e;
51  m_evt_slot = s;
52  m_evt_failed = f;
53  }
54 
55  void setEvt(const ContextEvt_t& e) {
56  if (e == INVALID_CONTEXT_EVT) setValid(false);
57  m_evt_num = e;
58  }
59 
60  void setSlot(const ContextID_t& s) {
61  if ( s == INVALID_CONTEXT_ID ) setValid(false);
62  m_evt_slot = s;
63  }
64 
65  void setFail(const bool& b=true) {
66  m_evt_failed = b;
67  }
68 
69  void setValid(const bool& b=true) {
70  m_valid = b;
71  if (!m_valid) {
74  }
75  }
76 
77  void setEventID(const EventIDBase& e) {
78  m_eid = e;
79  }
80 
81  void setProxy(IProxyDict* prx) {
82  m_proxy = prx;
83  }
84 
86  m_evt_num = c.m_evt_num;
88  m_valid = c.m_valid;
90  return *this;
91  }
92 
93 
94 private:
95  ContextEvt_t m_evt_num {INVALID_CONTEXT_EVT};
96  ContextID_t m_evt_slot {INVALID_CONTEXT_ID};
97  bool m_valid {false};
98  bool m_evt_failed {false};
99 
100  IProxyDict* m_proxy {0};
101 
103 };
104 
105 inline std::ostream& operator<<( std::ostream& os, const EventContext& ctx ) {
106  if (ctx.valid()) {
107  return os << "s: " << ctx.slot() << " e: " << ctx.evt();
108  } else {
109  return os << "INVALID";
110  }
111 }
112 
114  if (c != 0) {
115  return os << *c;
116  } else {
117  return os << "INVALID";
118  }
119 }
120 
121 
122 
123 #endif //GAUDIKERNEL_EVENTCONTEXT_H
void setEvt(const ContextEvt_t &e)
Definition: EventContext.h:55
void setEventID(const EventIDBase &e)
Definition: EventContext.h:77
ContextID_t slot() const
Definition: EventContext.h:41
ContextID_t m_evt_slot
Definition: EventContext.h:96
tuple c
Definition: gaudirun.py:391
static const ContextEvt_t INVALID_CONTEXT_EVT
Definition: EventContext.h:31
void setSlot(const ContextID_t &s)
Definition: EventContext.h:60
bool m_evt_failed
Definition: EventContext.h:98
This class represents an entry point to all the event specific data.
Definition: EventContext.h:25
size_t ContextID_t
Definition: EventContext.h:27
bool evtFail() const
Definition: EventContext.h:43
ContextEvt_t evt() const
Definition: EventContext.h:40
This class provides a unique identification for each event, in terms of run/event number and/or a tim...
IProxyDict * proxy() const
Definition: EventContext.h:44
EventIDBase m_eid
Definition: EventContext.h:102
void setFail(const bool &b=true)
Definition: EventContext.h:65
void setProxy(IProxyDict *prx)
Definition: EventContext.h:81
EventContext(const ContextEvt_t &e, const ContextID_t &s=INVALID_CONTEXT_ID)
Definition: EventContext.h:35
EventContext & operator=(const EventContext &c)
Definition: EventContext.h:85
static const ContextID_t INVALID_CONTEXT_ID
Definition: EventContext.h:30
IProxyDict * m_proxy
Definition: EventContext.h:100
ContextEvt_t m_evt_num
Definition: EventContext.h:95
This class provides a unique identification for each event, in terms of run/event number and/or a tim...
Definition: EventIDBase.h:28
string s
Definition: gaudirun.py:245
void setValid(const bool &b=true)
Definition: EventContext.h:69
const EventIDBase & eventID() const
Definition: EventContext.h:45
void set(const ContextEvt_t &e=0, const ContextID_t &s=INVALID_CONTEXT_ID, const bool f=false)
Definition: EventContext.h:47
size_t ContextEvt_t
Definition: EventContext.h:28
std::ostream & operator<<(std::ostream &os, const EventContext &ctx)
Definition: EventContext.h:105
STL class.
bool valid() const
Definition: EventContext.h:42