LCCD
1.5.0
|
Implementation of ConditionsHandlerBase that reads the conditions data from the database. More...
#include <DBCondHandler.hh>
Public Member Functions | |
DBCondHandler (const DBCondHandler &)=delete | |
DBCondHandler & | operator= (const DBCondHandler &)=delete |
DBCondHandler (const std::string &dbInit, const std::string &folder, const std::string &name, const std::string &tag="") | |
Default constructor. More... | |
virtual void | update (LCCDTimeStamp timeStamp) |
Retrieves the conditions data from the data base if time stamp exceeds current validity time range. More... | |
virtual void | registerDefaultCollection (lcio::LCCollection *col) |
Register a pointer to a default collection which will be passed to the IConditionsChangeListener if no data can be found for a given time stamp. | |
virtual lcio::LCCollection * | defaultCollection () |
The default collection registered with the handler. | |
virtual lcio::LCCollection * | lastValidCollection () |
The last valid collection held by the handler. | |
Public Member Functions inherited from lccd::ConditionsHandlerBase | |
ConditionsHandlerBase (const ConditionsHandlerBase &)=delete | |
ConditionsHandlerBase & | operator= (const ConditionsHandlerBase &)=delete |
ConditionsHandlerBase (const std::string &name) | |
Default c'tor - need a name for the conditions data set. | |
virtual void | updateEvent (lcio::LCEvent *evt) |
Retrieves the new conditions data if required by evt->getTimestamp() and adds a collection to event with its name. More... | |
virtual lcio::LCCollection * | currentCollection () |
Returns the current collection of conditions data. | |
virtual void | registerChangeListener (IConditionsChangeListener *cl) |
Every IConditionsChangeListener will be notified if the conditions data of this instance has changed. | |
virtual void | removeChangeListener (IConditionsChangeListener *cl) |
Remove the specified listener from list of registered listeners ;. | |
virtual bool | isChangeListenerRegistered (IConditionsChangeListener *cl) |
checks if the changeListner is Registered | |
virtual const std::string | name () |
The name of this conditions handler - used, e.g. More... | |
virtual LCCDTimeStamp | validSince () |
First timestamp for which the current conditions data is valid. | |
virtual LCCDTimeStamp | validTill () |
Last timestamp for which the current conditions data is valid. | |
Protected Attributes | |
lccd::DBInterface * | _db = nullptr |
std::string | _dbInit {} |
std::string | _folder {} |
std::string | _tag {} |
lcio::LCCollection * | _defaultCollection = nullptr |
The registered default collection. | |
lcio::LCCollection * | _lastValidCollection = nullptr |
The last valid collection of conditions data. More... | |
Protected Attributes inherited from lccd::ConditionsHandlerBase | |
lcio::LCCollection * | _col = nullptr |
The current collection of conditions data. More... | |
std::string | _name {} |
Name assigned with conditions data. | |
LCCDTimeStamp | _validSince {} |
First timestamp for which the current data is valid. More... | |
LCCDTimeStamp | _validTill {} |
Last timestamp for which the current data is valid. More... | |
std::vector < IConditionsChangeListener * > | _changeListeners {} |
The registered change listeners. | |
Additional Inherited Members | |
Protected Member Functions inherited from lccd::ConditionsHandlerBase | |
virtual void | notifyListeners () |
Tell all registered listeners that the conditions data has changed. | |
Implementation of ConditionsHandlerBase that reads the conditions data from the database.
On every call to update() it checks whether the provided time stamp exceeds the validity of the current conditions data. If so, new constants are retrieved from the data base.
In the case where no collection is available for a given time range, the default collection will be set as the present collection, and will be the one returned to the registered IConditionsChangeListener. The previously last valid collection i.e. not the Default Collection, will be held and can be accessed via the method lastValidCollection().
The Default Collection should be set via the method registerDefaultCollection( lcio::LCCollection* col) In the case of no collection found and no Default Collection set an exception will be raised. Only one Default Collection may be registered per Conditions Handler. Trying to register additional Default Collections will cause an lccd::Exception( std::string ) to be thrown.
The default collection may be accessed via the method defaultCollection(), and if so desired this method should be used by the IConditionsChangeListener to verify if this is the collection provided via the call-back method conditionsChanged.
Upon registering an IConditionsChangeListener with the Conditions Handler the call-back method registeredWithHandler( IConditionsHandler* ch ) will be called. Likewise calling removeChangeListener( IConditionsChangeListener* cl) will call the call-back method deRegisteredWithHandler( IConditionsHandler* ch )
lccd::DBCondHandler::DBCondHandler | ( | const std::string & | dbInit, |
const std::string & | folder, | ||
const std::string & | name, | ||
const std::string & | tag = "" |
||
) |
Default constructor.
You have to specify the following parameters:
dbInit,: | initialization string for the database, e.g. "localhost:lccd_test:calvin:hobbes" |
folder,: | name of the database folder |
name,: | of this conditions data set - used, e.g. as collection name in update(LCEvent* evt) |
tag,: | tag to be used for queries, HEAD if omitted |
References lccd::ConditionsHandlerBase::_col, _defaultCollection, and _lastValidCollection.
|
virtual |
Retrieves the conditions data from the data base if time stamp exceeds current validity time range.
Notifies all registered listeners if conditions have changed. Note in the case that no valid collection is available for timeStamp, the default collection will be sent if registered, otherwise an exception will be thrown which can not be caught in user code. If sent the default collection will have the following attributes attached as collection parameters: DBSINCE, DBTILL and DBQUERYTIME
Implements lccd::ConditionsHandlerBase.
References lccd::ConditionsHandlerBase::_col, _defaultCollection, _lastValidCollection, lccd::ConditionsHandlerBase::_validSince, lccd::ConditionsHandlerBase::_validTill, lccd::DBQUERYTIME, lccd::DBSINCE, lccd::DBTILL, lccd::DBInterface::findCollection(), lccd::DBInterface::findLastValidCollection(), lccd::DBInterface::findNextValidCollection(), lccd::LCCDMinusInf, lccd::LCCDPlusInf, lccd::ConditionsHandlerBase::name(), and lccd::ConditionsHandlerBase::notifyListeners().
|
protected |
The last valid collection of conditions data.
Referenced by DBCondHandler(), lastValidCollection(), and update().