 |
Belle II Software
release-05-02-19
|
12 #include <framework/database/DBStore.h>
13 #include <framework/logging/Logger.h>
77 inline operator bool()
const {
return isValid();}
88 return !(*
this == other);
108 void addCallback(std::function<
void(
const std::string&)> callback,
bool onDestruction =
false)
121 void addCallback(std::function<
void()> callback,
bool onDestruction =
false)
123 addCallback([callback](
const std::string&) ->
void { callback(); }, onDestruction);
133 template<
class T>
void addCallback(T*
object,
void(T::*callback)())
135 addCallback([ = ](
const std::string&) {(*
object.*callback)();});
165 B2DEBUG(32,
"DBAccessor " <<
m_name <<
" lost connection, reattaching");
180 if (destructed)
m_entry =
nullptr;
185 if (destructed == cb.second) cb.first(
m_name);
204 std::vector<std::pair<std::function<void(
const std::string&)>,
bool>>
m_callbacks;
A class that describes the interval of experiments/runs for which an object in the database is valid.
virtual bool operator==(const DBAccessorBase &other) const
Check if two store accessors point to the same object/array.
const DBStoreEntry::EPayloadType m_type
Type of the payload.
bool m_changed
Internal flag whether the object has changed since we last checked.
bool hasChanged()
Check whether the object has changed since the last call to hasChanged of the accessor).
virtual ~DBAccessorBase()
Destructor.
bool isRequired() const
Check whether this conditions object is required (at least one user declared it as required)
DBAccessorBase(DBStoreEntry::EPayloadType type, const std::string &name, bool isRequired)
Constructor to access an object in the DBStore which is not a ROOT Object.
DBStoreEntry * m_entry
Pointer to the entry in the DBStore.
const std::string & getFilename() const
get the filename for this payload
const std::string & getChecksum() const
get the checksum of the payload.
const T * getObject() const
Return a pointer to the Object already cast to the correct type.
bool isRequired() const
check whether this payload is required for operation
std::vector< std::pair< std::function< void(const std::string &)>, bool > > m_callbacks
List of all registered callback functions.
const TObject * getObject() const
get the object for this payload, can be nullptr if the payload is not loaded or not of type c_Object
Class to hold one entry from the ConditionsDB in the DBStore.
const std::string & getFilename() const
Get the filename this object is loaded from.
void removeAccessor(DBAccessorBase *object)
Deregister an Accessor object and remove it from the list of registered objects.
unsigned int getRevision() const
Return current revision of the object.
Base class for DBObjPtr and DBArray for easier common treatment.
EPayloadType
Possible Store entry types.
IntervalOfValidity getIoV() const
Return current IoV of the object.
DBStoreEntry * getEntry(DBStoreEntry::EPayloadType payloadType, const std::string &name, const TClass *objClass, bool array, bool required=true)
Returns the entry with the requested name in the DBStore.
const std::string & getChecksum() const
Get current checksum.
Abstract base class for different kinds of events.
IntervalOfValidity getIoV() const
get the validity of the payload
void storeEntryChanged(bool destructed)
Callback function which gets called by the DBStoreEntry object if it changes.
static DBStore & Instance()
Instance of a singleton DBStore.
const std::string m_name
Name of the payload in the database.
const bool m_isArray
True if the payload is an array of objects.
const bool m_isRequired
True if the payload is required, otherwise no errors will be raised if it cannot be found.
void addCallback(std::function< void()> callback, bool onDestruction=false)
Add a callback method.
bool ensureAttached() const
Make sure we are attached to the the DBStore.
bool isValid() const
Check whether a valid object was obtained from the database.
const TClass * m_objClass
Class of the payload if type is c_Object.
void registerAccessor(DBAccessorBase *object)
Register an Accessor object to be notified on changes by calling DBAccessorBase::storeEntryChanged()
void addCallback(T *object, void(T::*callback)())
Add a callback method of an object.
const std::string & getName() const
Return name under which the object is saved in the DBStore.
DBAccessorBase(const std::string &name, const TClass *objClass, bool isArray, bool isRequired)
Constructor to access an object in the DBStore.
unsigned int getRevision() const
get the revision of the payload, this is an abitrary number which indicates the conditions version
void addCallback(std::function< void(const std::string &)> callback, bool onDestruction=false)
Add a callback method.
virtual bool operator!=(const DBAccessorBase &other) const
Check if two store accessors point to a different object/array.