stream  0.10.0
stream analysis framework
Event.h
1 #ifndef BASE_EVENT_H
2 #define BASE_EVENT_H
3 
4 #include "base/SubEvent.h"
5 
6 #include "base/TimeStamp.h"
7 
8 #include <map>
9 #include <string>
10 
11 namespace base {
12 
13  typedef std::map<std::string, base::SubEvent*> EventsMap;
14 
17  class Event {
18  protected:
19  EventsMap fMap;
20 
21  GlobalTime_t fTriggerTm;
22 
23  public:
25  Event() : fMap(), fTriggerTm(0.) {}
26 
28  virtual ~Event()
29  {
30  DestroyEvents();
31  }
32 
34  void SetTriggerTime(GlobalTime_t tm) { fTriggerTm = tm; }
35 
37  GlobalTime_t GetTriggerTime() const { return fTriggerTm; }
38 
41  {
42  for (EventsMap::iterator iter = fMap.begin(); iter != fMap.end(); iter++)
43  delete iter->second;
44  fMap.clear();
45  }
46 
48  void ResetEvents()
49  {
50  for (EventsMap::iterator iter = fMap.begin(); iter != fMap.end(); iter++)
51  if (iter->second)
52  iter->second->Clear();
53 
54  fTriggerTm = 0;
55  }
56 
58  void AddSubEvent(const std::string& name, base::SubEvent* ev)
59  {
60  EventsMap::iterator iter = fMap.find(name);
61  if (iter != fMap.end()) delete iter->second;
62  fMap[name] = ev;
63  }
64 
66  unsigned NumSubEvents() const { return fMap.size(); }
67 
69  base::SubEvent* GetSubEvent(const std::string& name) const
70  {
71  EventsMap::const_iterator iter = fMap.find(name);
72  return (iter != fMap.end()) ? iter->second : 0;
73  }
74 
77  base::SubEvent* GetSubEvent(const std::string& name, unsigned subindx) const;
78 
80  EventsMap &GetEventsMap() { return fMap; }
81  };
82 
83 }
84 
85 #endif
Event - collection of several subevents.
Definition: Event.h:17
EventsMap & GetEventsMap()
Return events map.
Definition: Event.h:80
void ResetEvents()
reset events
Definition: Event.h:48
GlobalTime_t GetTriggerTime() const
get trigger time
Definition: Event.h:37
void AddSubEvent(const std::string &name, base::SubEvent *ev)
add subevent
Definition: Event.h:58
unsigned NumSubEvents() const
Return number of subevents.
Definition: Event.h:66
base::SubEvent * GetSubEvent(const std::string &name) const
Return subevent by name.
Definition: Event.h:69
GlobalTime_t fTriggerTm
trigger time
Definition: Event.h:21
EventsMap fMap
subevents map
Definition: Event.h:19
void DestroyEvents()
destroy all events
Definition: Event.h:40
void SetTriggerTime(GlobalTime_t tm)
set trigger time
Definition: Event.h:34
Event()
constructor
Definition: Event.h:25
virtual ~Event()
destructor
Definition: Event.h:28
SubEvent - base class for all event structures Need for: virtual destructor - to be able delete any i...
Definition: base/SubEvent.h:14