Belle II Software  release-08-01-10
DBStoreEntry Class Reference

Class to hold one entry from the ConditionsDB in the DBStore. More...

#include <DBStoreEntry.h>

Collaboration diagram for DBStoreEntry:

Public Types

enum  EPayloadType {
  c_RawFile ,
  c_ROOTFile ,
  c_Object
}
 Possible Store entry types. More...
 

Public Member Functions

 DBStoreEntry (EPayloadType type, const std::string &name, const TClass *objClass, bool isArray, bool isRequired)
 Construct a new DBStoreEntry. More...
 
 DBStoreEntry (const DBStoreEntry &)=delete
 Don't copy the entries around.
 
DBStoreEntryoperator= (const DBStoreEntry &)=delete
 Also don't just assign them to each other.
 
 DBStoreEntry (DBStoreEntry &&)=default
 But we're fine with moving them.
 
 ~DBStoreEntry ()
 Clean up memory. More...
 
const std::string & getName () const
 get the name of the payload
 
const std::string & getGlobaltag () const
 get the globaltag name (or testing payloads path) from which the payload is picked.
 
unsigned int getRevision () const
 get the revision of the payload, this is an abitrary number which indicates the conditions version
 
IntervalOfValidity getIoV () const
 get the validity of the payload
 
const std::string & getFilename () const
 get the filename for this payload
 
const std::string & getChecksum () const
 get the checksum of the payload. More...
 
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
 
const TFile * getTFile () const
 get the ROOT TFile pointer for this payload. More...
 
const TClass * getClass () const
 get the class of this payload
 
bool isArray () const
 get whether this payload is an array of objects or a single objects
 
bool isRequired () const
 check whether this payload is required for operation
 
bool keepUntilExpired () const
 check whether the payload should be kept until expired
 
bool isIntraRunDependent () const
 return whether or not the payload might change even during the run
 
const std::vector< unsigned int > getIntraRunBoundaries () const
 return the boundaries of the intra-run changes of the payload, if any
 
void registerAccessor (DBAccessorBase *object)
 Register an Accessor object to be notified on changes by calling DBAccessorBase::storeEntryChanged()
 
void removeAccessor (DBAccessorBase *object)
 Deregister an Accessor object and remove it from the list of registered objects.
 

Static Public Member Functions

static DBStoreEntry fromObject (const std::string &name, const TObject *obj, bool isRequired)
 Construct a new DBStoreEntry with a requested name and an object directly. More...
 

Private Member Functions

void resetPayload ()
 reset the payload to nothing
 
void updatePayload (unsigned int revision, const IntervalOfValidity &iov, const std::string &filename, const std::string &checksum, const std::string &globaltag, const EventMetaData &event)
 Update the payload information for this entry and if appropriate open the new file and extract the object as needed. More...
 
void loadPayload (const EventMetaData &event)
 Actual load the payload from file after all info is set.
 
void updateObject (const EventMetaData &event)
 update the payload object according to the new event information. More...
 
void overrideObject (TObject *obj, const IntervalOfValidity &iov)
 Set an override object in case we want to use a different object then actually provided by the database. More...
 
TObject * releaseObject ()
 Return the pointer to the current object and release ownership: The caller is responsible to clean up the object.
 
bool checkType (const TObject *object) const
 Check if a given TObject instance is compatible with the type of this entry.
 
bool checkType (EPayloadType type, const TClass *objClass, bool array, bool inverse=false) const
 Check if a given TClass is compatible with the type of this entry.
 
void notifyAccessors (bool onDestruction=false)
 Notify all the registered accessors.
 
void require ()
 Change status of this payload to required.
 

Private Attributes

const EPayloadType m_payloadType
 Type of this payload.
 
const std::string m_name
 Name of this payload.
 
const TClass *const m_objClass
 Class of this payload.
 
const bool m_isArray
 True if this payload is an array of objects.
 
bool m_isRequired {false}
 True if at least one user marked this payload as required, false if this payload is marked optional.
 
bool m_keep {false}
 if True this payload should not be updated unless it's really out of date. More...
 
std::string m_globaltag {""}
 globaltag name (or testing payloads path) from which this payload is picked.
 
unsigned int m_revision {0}
 revision of this payload
 
IntervalOfValidity m_iov {0, 0, 0, 0}
 validity of this payload
 
std::string m_filename {""}
 filename containing which contains the actual payload data
 
std::string m_checksum
 checksum of the payload file
 
TFile * m_tfile {nullptr}
 Pointer to the open ROOT TFile pointer for m_filename.
 
TObject * m_object {nullptr}
 Pointer to the actual payload object.
 
IntraRunDependencym_intraRunDependency {nullptr}
 If the payload has intra run dependency this will point to the whole payload and m_object will just point to the part currently valid.
 
std::unordered_set< DBAccessorBase * > m_accessors
 Vector of all the accessors registered with this entry.
 

Friends

class DBStore
 Allow only the DBStore class to update the payload contents.
 
class Database
 Also allow the Database class to return TObject* pointers for now.
 

Detailed Description

Class to hold one entry from the ConditionsDB in the DBStore.

This class is what every DBObjPtr and DBArray are pointing to. It owns the TFile pointer for the payload and the payload object itself.

Any update of the Payload goes through here: when the payload changes after a run the updatePayload() will be called with the new revision, iov and filename. This class then opens the File and obtains the payload object.

Warning
Users should not need to use this class at all but just need DBObjPtr and DBArray.

This class also supports raw file payloads (where we do not even open the file but will just return the filename to interested parties) or ROOTFile payloads (where we make sure the file can be read by ROOT but don't extract anything from it) But at the moment there is no api to use these types.

See also
DBObjPtr DBArray DBStore

Definition at line 47 of file DBStoreEntry.h.

Member Enumeration Documentation

◆ EPayloadType

Possible Store entry types.

Enumerator
c_RawFile 

Just a plain old file, we don't look at it just provide the filename.

c_ROOTFile 

Normal ROOT file but no extraction of any specific object.

c_Object 

A ROOT file containing a object with the name of the DBStoreEntry.

Definition at line 50 of file DBStoreEntry.h.

50  {
52  c_RawFile,
54  c_ROOTFile,
56  c_Object
57  };
@ c_RawFile
Just a plain old file, we don't look at it just provide the filename.
Definition: DBStoreEntry.h:52
@ c_ROOTFile
Normal ROOT file but no extraction of any specific object.
Definition: DBStoreEntry.h:54
@ c_Object
A ROOT file containing a object with the name of the DBStoreEntry.
Definition: DBStoreEntry.h:56

Constructor & Destructor Documentation

◆ DBStoreEntry()

DBStoreEntry ( EPayloadType  type,
const std::string &  name,
const TClass *  objClass,
bool  isArray,
bool  isRequired 
)
inline

Construct a new DBStoreEntry.

Parameters
typestore entry type
namename of the payload, ususally the class name of the payload but can be any string identifying the payload in the database
objClassTClass* pointer of the payload, used to check that we actually obtained the correct payload from the database
isArrayif true the object is required to be a TClonesArray containing objClass objects.
isRequiredif false don't emit errors if the payload cannot be found for any run

Definition at line 68 of file DBStoreEntry.h.

Member Function Documentation

◆ getChecksum()

const std::string& getChecksum ( ) const
inline

get the checksum of the payload.

This is a fixed size string calculated from the file contents. If this changes the payload data also changed

Definition at line 104 of file DBStoreEntry.h.

◆ getTFile()

const TFile* getTFile ( ) const
inline

get the ROOT TFile pointer for this payload.

Can be nullptr if the payload is not loaded or neither c_ROOTFile or c_Object

Definition at line 109 of file DBStoreEntry.h.

Member Data Documentation

◆ m_keep

bool m_keep {false}
private

if True this payload should not be updated unless it's really out of date.

Usually only set for overrides

Definition at line 183 of file DBStoreEntry.h.


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