10#include <framework/database/DBStore.h>
11#include <framework/logging/Logger.h>
74 inline operator bool()
const {
return isValid();}
85 return !(*
this == other);
105 void addCallback(std::function<
void(
const std::string&)> callback,
bool onDestruction =
false)
105 void addCallback(std::function<
void(
const std::string&)> callback,
bool onDestruction =
false) {
…}
118 void addCallback(std::function<
void()> callback,
bool onDestruction =
false)
120 addCallback([callback](
const std::string&) ->
void { callback(); }, onDestruction);
118 void addCallback(std::function<
void()> callback,
bool onDestruction =
false) {
…}
130 template<
class T>
void addCallback(T*
object,
void(T::*callback)())
132 addCallback([ = ](
const std::string&) {(*
object.*callback)();});
130 template<
class T>
void addCallback(T*
object,
void(T::*callback)()) {
…}
167 return reinterpret_cast<const T*
>(
m_entry->getObject());
174 B2DEBUG(32,
"DBAccessor " <<
m_name <<
" lost connection, reattaching");
189 if (destructed)
m_entry =
nullptr;
194 if (destructed == cb.second) cb.first(
m_name);
213 std::vector<std::pair<std::function<void(
const std::string&)>,
bool>>
m_callbacks;
bool m_changed
Internal flag whether the object has changed since we last checked.
virtual bool operator!=(const DBAccessorBase &other) const
Check if two store accessors point to a different object/array.
const TClass * m_objClass
Class of the payload if type is c_Object.
DBAccessorBase(DBStoreEntry::EPayloadType type, const std::string &name, bool isRequired)
Constructor to access an object in the DBStore which is not a ROOT Object.
virtual ~DBAccessorBase()
Destructor.
const std::string & getFilename() const
Get the filename this object is loaded from.
const std::string & getName() const
Return name under which the object is saved in the DBStore.
bool isIntraRunDependent() const
Check whether this conditions object has some intra-run dependencies.
std::vector< std::pair< std::function< void(const std::string &)>, bool > > m_callbacks
List of all registered callback functions.
DBAccessorBase(const std::string &name, const TClass *objClass, bool isArray, bool isRequired)
Constructor to access an object in the DBStore.
void addCallback(std::function< void(const std::string &)> callback, bool onDestruction=false)
Add a callback method.
bool isValid() const
Check whether a valid object was obtained from the database.
const std::string m_name
Name of the payload in the database.
IntervalOfValidity getIoV() const
Return current IoV of the object.
DBStoreEntry * m_entry
Pointer to the entry in the DBStore.
bool hasChanged()
Check whether the object has changed since the last call to hasChanged of the accessor).
unsigned int getRevision() const
Return current revision of the object.
bool ensureAttached() const
Make sure we are attached to the the DBStore.
bool isRequired() const
Check whether this conditions object is required (at least one user declared it as required)
void addCallback(std::function< void()> callback, bool onDestruction=false)
Add a callback method.
void storeEntryChanged(bool destructed)
Callback function which gets called by the DBStoreEntry object if it changes.
friend class DBStoreEntry
Allow the DBStoreEntry to call the callback notifier.
const std::vector< unsigned int > getIntraRunBoundaries() const
Get the intra-run boundaries, if any.
const T * getObject() const
Return a pointer to the Object already cast to the correct type.
const std::string & getGlobaltag() const
Return the globaltag name (or testing payloads path) this object is loaded from.
const bool m_isArray
True if the payload is an array of objects.
const std::string & getChecksum() const
Get current checksum.
void addCallback(T *object, void(T::*callback)())
Add a callback method of an object.
const DBStoreEntry::EPayloadType m_type
Type of the payload.
virtual bool operator==(const DBAccessorBase &other) const
Check if two store accessors point to the same object/array.
const bool m_isRequired
True if the payload is required, otherwise no errors will be raised if it cannot be found.
EPayloadType
Possible Store entry types.
Singleton class to cache database objects.
A class that describes the interval of experiments/runs for which an object in the database is valid.
static DBStore & Instance()
Instance of a singleton DBStore.
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.
Abstract base class for different kinds of events.