Belle II Software development
DBStore Class Reference

Singleton class to cache database objects. More...

#include <DBStore.h>

Public Member Functions

 ~DBStore ()
 Destructor.
 
DBStoreEntrygetEntry (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.
 
DBStoreEntrygetEntry (const std::string &name, const TClass *objClass, bool array, bool required=true)
 Returns the entry with the requested name in the DBStore.
 
void update ()
 Updates all objects that are outside their interval of validity.
 
void update (const EventMetaData &event)
 Updates all objects that are outside their interval of validity.
 
void updateEvent ()
 Updates all intra-run dependent objects.
 
void updateEvent (const unsigned int eventNumber)
 Updates all intra-run dependent objects.
 
void reset (bool keepEntries=false)
 Invalidate all payloads.
 
std::set< std::string > getAllEntryNames ()
 Return the names of all the payloads stored in the database at the time of this function is called.
 
void addConstantOverride (const std::string &name, TObject *obj, bool oneRun=false)
 Add constant override payload.
 

Static Public Member Functions

static DBStoreInstance ()
 Instance of a singleton DBStore.
 
template<class T >
static std::string objectName (const std::string &name)
 Return the database name for an object of the given type and name.
 
template<class T >
static std::string arrayName (const std::string &name)
 Return the database name for an object of the given type and name.
 

Private Member Functions

 DBStore ()
 Hidden constructor, as it is a singleton.
 
 DBStore (const DBStore &)
 same for copy constructor
 
void performUpdate (const EventMetaData &event)
 The main code that does an update, factored out so it can be used by both update and update(event).
 
void performUpdateEvent (const EventMetaData &event)
 The main code that does an updateEvent.
 

Private Attributes

std::unordered_map< std::string, DBStoreEntrym_dbEntries
 Map names to DBEntry objects.
 
std::set< DBStoreEntry * > m_intraRunDependencies
 List of intra-run dependent conditions.
 
StoreObjPtr< EventMetaDatam_storeEvent
 StoreObjPtr for the EventMetaData to get the current experiment and run from the DataStore.
 
std::optional< EventMetaDatam_manualEvent
 Optional EventMetaData variable.
 

Detailed Description

Singleton class to cache database objects.

The DBStore is the owner of the objects retrieved from the database.

Definition at line 31 of file DBStore.h.

Constructor & Destructor Documentation

◆ DBStore()

DBStore ( )
inlineexplicitprivate

Hidden constructor, as it is a singleton.

Definition at line 151 of file DBStore.h.

151{};

Member Function Documentation

◆ arrayName()

static std::string arrayName ( const std::string &  name)
inlinestatic

Return the database name for an object of the given type and name.

Definition at line 50 of file DBStore.h.

50{ return DataStore::arrayName<T>(name); }

◆ getEntry()

DBStoreEntry * getEntry ( const std::string &  name,
const TClass *  objClass,
bool  array,
bool  required = true 
)
inline

Returns the entry with the requested name in the DBStore.

If the DBStore entry does not exist yet it is added to the map.

If the DBStore map already contains an object under the key with a DIFFERENT type than the given type one, an error will be reported.

Parameters
nameName under which the object is stored in the database (and in the DBStore).
objClassThe class of the object.
arrayWhether it is a TClonesArray or not.
requiredIf true emit errors if the object cannot be found
Returns
DBEntry, or NULL if the requested type does not match the one in the DBStore

Definition at line 86 of file DBStore.h.

88 {
89 return getEntry(DBStoreEntry::c_Object, name, objClass, array, required);
90 }
@ c_Object
A ROOT file containing a object with the name of the DBStoreEntry.
Definition: DBStoreEntry.h:56
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.
Definition: DBStore.cc:34

◆ objectName()

static std::string objectName ( const std::string &  name)
inlinestatic

Return the database name for an object of the given type and name.

Definition at line 44 of file DBStore.h.

44{ return DataStore::objectName<T>(name); }

Member Data Documentation

◆ m_dbEntries

std::unordered_map<std::string, DBStoreEntry> m_dbEntries
private

Map names to DBEntry objects.

Definition at line 166 of file DBStore.h.

◆ m_intraRunDependencies

std::set<DBStoreEntry*> m_intraRunDependencies
private

List of intra-run dependent conditions.

Definition at line 169 of file DBStore.h.

◆ m_manualEvent

std::optional<EventMetaData> m_manualEvent
private

Optional EventMetaData variable.

This is set by DBStore::Instance().update(event). Provides a similar interface to StoreObjPtr and allows us to check when not initialized/valid easily. Can be moved to a std::optional when/if we move to C++17.

Definition at line 181 of file DBStore.h.

◆ m_storeEvent

StoreObjPtr<EventMetaData> m_storeEvent
private

StoreObjPtr for the EventMetaData to get the current experiment and run from the DataStore.

Definition at line 174 of file DBStore.h.


The documentation for this class was generated from the following files: