| The Gaudi Framework v27r1

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

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>
7 #include "GaudiKernel/EventIDBase.h"
8
23 class IProxyDict;
24
25 class EventContext{
26 public:
27 typedef size_t ContextID_t;
28 typedef size_t ContextEvt_t;
29
30 static const ContextID_t INVALID_CONTEXT_ID = std::numeric_limits<ContextID_t>::max();
31 static const ContextEvt_t INVALID_CONTEXT_EVT = std::numeric_limits<ContextEvt_t>::max();
32
33
34 EventContext() {};
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) {
72 m_evt_slot = INVALID_CONTEXT_ID;
73 m_evt_num = INVALID_CONTEXT_EVT;
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
85 EventContext& operator=(const EventContext& c) {
86 m_evt_num = c.m_evt_num;
87 m_evt_slot = c.m_evt_slot;
88 m_valid = c.m_valid;
89 m_evt_failed = c.m_evt_failed;
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
102 EventIDBase m_eid {};
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
113 inline std::ostream& operator<< (std::ostream& os, const EventContext* c) {
114 if (c != 0) {
115 return os << *c;
116 } else {
117 return os << "INVALID";
118 }
119 }
120
121
122
123 #endif //GAUDIKERNEL_EVENTCONTEXT_H
EventContext::m_valid
bool m_valid
Definition: EventContext.h:97
EventContext::setEvt
void setEvt(const ContextEvt_t &e)
Definition: EventContext.h:55
EventContext::setEventID
void setEventID(const EventIDBase &e)
Definition: EventContext.h:77
EventContext::slot
ContextID_t slot() const
Definition: EventContext.h:41
EventContext::m_evt_slot
ContextID_t m_evt_slot
Definition: EventContext.h:96
gaudirun.c
tuple c
Definition: gaudirun.py:391
EventContext::INVALID_CONTEXT_EVT
static const ContextEvt_t INVALID_CONTEXT_EVT
Definition: EventContext.h:31
EventContext::setSlot
void setSlot(const ContextID_t &s)
Definition: EventContext.h:60
EventContext::m_evt_failed
bool m_evt_failed
Definition: EventContext.h:98
EventContext
This class represents an entry point to all the event specific data.
Definition: EventContext.h:25
EventContext::ContextID_t
size_t ContextID_t
Definition: EventContext.h:27
EventContext::evtFail
bool evtFail() const
Definition: EventContext.h:43
EventContext::evt
ContextEvt_t evt() const
Definition: EventContext.h:40
EventIDBase.h
This class provides a unique identification for each event, in terms of run/event number and/or a tim...
EventContext::proxy
IProxyDict * proxy() const
Definition: EventContext.h:44
EventContext::m_eid
EventIDBase m_eid
Definition: EventContext.h:102
EventContext::setFail
void setFail(const bool &b=true)
Definition: EventContext.h:65
EventContext::setProxy
void setProxy(IProxyDict *prx)
Definition: EventContext.h:81
EventContext::EventContext
EventContext(const ContextEvt_t &e, const ContextID_t &s=INVALID_CONTEXT_ID)
Definition: EventContext.h:35
EventContext::operator=
EventContext & operator=(const EventContext &c)
Definition: EventContext.h:85
EventContext::INVALID_CONTEXT_ID
static const ContextID_t INVALID_CONTEXT_ID
Definition: EventContext.h:30
EventContext::m_proxy
IProxyDict * m_proxy
Definition: EventContext.h:100
std::numeric_limits::max
T max(T...args)
EventContext::m_evt_num
ContextEvt_t m_evt_num
Definition: EventContext.h:95
EventIDBase
This class provides a unique identification for each event, in terms of run/event number and/or a tim...
Definition: EventIDBase.h:28
gaudirun.s
string s
Definition: gaudirun.py:245
EventContext::setValid
void setValid(const bool &b=true)
Definition: EventContext.h:69
EventContext::eventID
const EventIDBase & eventID() const
Definition: EventContext.h:45
EventContext::EventContext
EventContext()
Definition: EventContext.h:34
EventContext::set
void set(const ContextEvt_t &e=0, const ContextID_t &s=INVALID_CONTEXT_ID, const bool f=false)
Definition: EventContext.h:47
EventContext::ContextEvt_t
size_t ContextEvt_t
Definition: EventContext.h:28
operator<<
std::ostream & operator<<(std::ostream &os, const EventContext &ctx)
Definition: EventContext.h:105
std::ostream
STL class.
EventContext::valid
bool valid() const
Definition: EventContext.h:42