LCCD  1.5.0
ConditionsHandlerBase.hh
1 #ifndef ConditionsHandlerBase_h
2 #define ConditionsHandlerBase_h
3 
4 #include "lccd.h"
5 
6 #include "IConditionsHandler.hh"
7 
8 #include <vector>
9 
10 
11 //using namespace lcio ;
12 
13 namespace lccd {
14 
28 
29  public:
30 
32  ConditionsHandlerBase& operator=(const ConditionsHandlerBase&) = delete ;
33 
36  ConditionsHandlerBase(const std::string& name) :
37  _col(NULL),
38  _name( name),
39  _validSince( LCCDPlusInf ) , // initially we don't have a valid time range
41  }
42 
43  virtual ~ConditionsHandlerBase() {}
44 
45 
50  virtual void updateEvent( lcio::LCEvent* evt ) ;
51 
52 
57  virtual void update( LCCDTimeStamp timestamp ) = 0 ;
58 
59 
62  virtual lcio::LCCollection* currentCollection() { return _col ; }
63 
64 
69 
70 
74 
75 
79 
80 
84  virtual void registerDefaultCollection( lcio::LCCollection* col) = 0 ;
85 
88  virtual lcio::LCCollection* defaultCollection() = 0;
89 
92  virtual lcio::LCCollection* lastValidCollection() = 0;
93 
99  virtual const std::string name() { return _name ; }
100 
103  virtual LCCDTimeStamp validSince() { return _validSince ; }
104 
107  virtual LCCDTimeStamp validTill() { return _validTill ; }
108 
109 
110  protected :
111 
113 
116  virtual void notifyListeners() ;
117 
118 
119  // ---- data members ------
120 
122  lcio::LCCollection* _col = nullptr ;
123 
125  std::string _name{} ;
126 
129 
132 
134  std::vector< IConditionsChangeListener* > _changeListeners{} ;
135 
136 
137 
138  };
139 } //end namespace
140 
141 #endif // ConditionsHandlerBase_h
lcio::LCCollection * _col
The current collection of conditions data.
Definition: ConditionsHandlerBase.hh:122
virtual LCCDTimeStamp validSince()
First timestamp for which the current conditions data is valid.
Definition: ConditionsHandlerBase.hh:103
LCCDTimeStamp LCCDPlusInf
The largest possible time stamp.
Definition: lccd.cc:18
Simple interface that allows notification of implementation classes if a conditions data set has chan...
Definition: IConditionsChangeListener.hh:22
Base implementation of IConditionsHandler.
Definition: ConditionsHandlerBase.hh:27
virtual void registerChangeListener(IConditionsChangeListener *cl)
Every IConditionsChangeListener will be notified if the conditions data of this instance has changed...
Definition: ConditionsHandlerBase.cc:25
virtual bool isChangeListenerRegistered(IConditionsChangeListener *cl)
checks if the changeListner is Registered
Definition: ConditionsHandlerBase.cc:31
virtual LCCDTimeStamp validTill()
Last timestamp for which the current conditions data is valid.
Definition: ConditionsHandlerBase.hh:107
Abstract handler for conditions data.
Definition: IConditionsHandler.hh:26
std::vector< IConditionsChangeListener * > _changeListeners
The registered change listeners.
Definition: ConditionsHandlerBase.hh:134
LCCDTimeStamp _validSince
First timestamp for which the current data is valid.
Definition: ConditionsHandlerBase.hh:128
std::string _name
Name assigned with conditions data.
Definition: ConditionsHandlerBase.hh:125
LCCDTimeStamp _validTill
Last timestamp for which the current data is valid.
Definition: ConditionsHandlerBase.hh:131
LCCDTimeStamp LCCDMinusInf
The smallest possible time stamp.
Definition: lccd.cc:16
virtual void removeChangeListener(IConditionsChangeListener *cl)
Remove the specified listener from list of registered listeners ;.
Definition: ConditionsHandlerBase.cc:42
lcio::long64 LCCDTimeStamp
The timestamp in LCCD is a 64bit int as defined in LCIO.
Definition: lccd.h:24
virtual void updateEvent(lcio::LCEvent *evt)
Retrieves the new conditions data if required by evt-&gt;getTimestamp() and adds a collection to event w...
Definition: ConditionsHandlerBase.cc:12
virtual lcio::LCCollection * defaultCollection()=0
The default collection registered with the handler.
ConditionsHandlerBase(const std::string &name)
Default c&#39;tor - need a name for the conditions data set.
Definition: ConditionsHandlerBase.hh:36
virtual void notifyListeners()
Tell all registered listeners that the conditions data has changed.
Definition: ConditionsHandlerBase.cc:54
virtual const std::string name()
The name of this conditions handler - used, e.g.
Definition: ConditionsHandlerBase.hh:99
virtual lcio::LCCollection * currentCollection()
Returns the current collection of conditions data.
Definition: ConditionsHandlerBase.hh:62
virtual void registerDefaultCollection(lcio::LCCollection *col)=0
Register a pointer to a default collection which will be passed to the IConditionsChangeListener if n...
virtual lcio::LCCollection * lastValidCollection()=0
The last valid collection held by the handler.
virtual void update(LCCDTimeStamp timestamp)=0
Retrieves the new conditions data if required by timestamp.