Belle II Software development
DBStoreEntry Class Reference

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

#include <DBStoreEntry.h>

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.
 
 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.
 
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.
 
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.
 
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.
 

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.
 
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.
 
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.
 
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.
 
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 {
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.

68 :
const std::string m_name
Name of this payload.
Definition: DBStoreEntry.h:173
bool isRequired() const
check whether this payload is required for operation
Definition: DBStoreEntry.h:115
const EPayloadType m_payloadType
Type of this payload.
Definition: DBStoreEntry.h:171
const bool m_isArray
True if this payload is an array of objects.
Definition: DBStoreEntry.h:177
bool isArray() const
get whether this payload is an array of objects or a single objects
Definition: DBStoreEntry.h:113
const TClass *const m_objClass
Class of this payload.
Definition: DBStoreEntry.h:175
bool m_isRequired
True if at least one user marked this payload as required, false if this payload is marked optional.
Definition: DBStoreEntry.h:180

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.

104{ return m_checksum; }
std::string m_checksum
checksum of the payload file
Definition: DBStoreEntry.h:193

◆ getClass()

const TClass * getClass ( ) const
inline

get the class of this payload

Definition at line 111 of file DBStoreEntry.h.

111{ return m_objClass; }

◆ getFilename()

const std::string & getFilename ( ) const
inline

get the filename for this payload

Definition at line 101 of file DBStoreEntry.h.

101{ return m_filename; }
std::string m_filename
filename containing which contains the actual payload data
Definition: DBStoreEntry.h:191

◆ getGlobaltag()

const std::string & getGlobaltag ( ) const
inline

get the globaltag name (or testing payloads path) from which the payload is picked.

Definition at line 94 of file DBStoreEntry.h.

94{ return m_globaltag; }
std::string m_globaltag
globaltag name (or testing payloads path) from which this payload is picked.
Definition: DBStoreEntry.h:185

◆ getIntraRunBoundaries()

const std::vector< unsigned int > getIntraRunBoundaries ( ) const
inline

return the boundaries of the intra-run changes of the payload, if any

Definition at line 121 of file DBStoreEntry.h.

121{ if (isIntraRunDependent()) return m_intraRunDependency->getBoundaries(); return std::vector<unsigned int> {}; }
bool isIntraRunDependent() const
return whether or not the payload might change even during the run
Definition: DBStoreEntry.h:119
IntraRunDependency * m_intraRunDependency
If the payload has intra run dependency this will point to the whole payload and m_object will just p...
Definition: DBStoreEntry.h:200
virtual const std::vector< unsigned int > & getBoundaries() const =0
Get a vector with the intra-run boundaries.

◆ getIoV()

IntervalOfValidity getIoV ( ) const
inline

get the validity of the payload

Definition at line 99 of file DBStoreEntry.h.

99{ return m_iov; }
IntervalOfValidity m_iov
validity of this payload
Definition: DBStoreEntry.h:189

◆ getName()

const std::string & getName ( ) const
inline

get the name of the payload

Definition at line 92 of file DBStoreEntry.h.

92{ return m_name; }

◆ getObject()

const TObject * getObject ( ) const
inline

get the object for this payload, can be nullptr if the payload is not loaded or not of type c_Object

Definition at line 107 of file DBStoreEntry.h.

107{ return m_object; }
TObject * m_object
Pointer to the actual payload object.
Definition: DBStoreEntry.h:197

◆ getRevision()

unsigned int getRevision ( ) const
inline

get the revision of the payload, this is an abitrary number which indicates the conditions version

Definition at line 97 of file DBStoreEntry.h.

97{ return m_revision; }
unsigned int m_revision
revision of this payload
Definition: DBStoreEntry.h:187

◆ 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.

109{ return m_tfile; }
TFile * m_tfile
Pointer to the open ROOT TFile pointer for m_filename.
Definition: DBStoreEntry.h:195

◆ isArray()

bool isArray ( ) const
inline

get whether this payload is an array of objects or a single objects

Definition at line 113 of file DBStoreEntry.h.

113{ return m_isArray; }

◆ isIntraRunDependent()

bool isIntraRunDependent ( ) const
inline

return whether or not the payload might change even during the run

Definition at line 119 of file DBStoreEntry.h.

119{ return (bool)m_intraRunDependency; }

◆ isRequired()

bool isRequired ( ) const
inline

check whether this payload is required for operation

Definition at line 115 of file DBStoreEntry.h.

115{ return m_isRequired; }

◆ keepUntilExpired()

bool keepUntilExpired ( ) const
inline

check whether the payload should be kept until expired

Definition at line 117 of file DBStoreEntry.h.

117{ return m_keep; }
bool m_keep
if True this payload should not be updated unless it's really out of date.
Definition: DBStoreEntry.h:183

◆ registerAccessor()

void registerAccessor ( DBAccessorBase object)
inline

Register an Accessor object to be notified on changes by calling DBAccessorBase::storeEntryChanged()

Definition at line 123 of file DBStoreEntry.h.

123{ m_accessors.insert(object); }
std::unordered_set< DBAccessorBase * > m_accessors
Vector of all the accessors registered with this entry.
Definition: DBStoreEntry.h:202

◆ releaseObject()

TObject * releaseObject ( )
inlineprivate

Return the pointer to the current object and release ownership: The caller is responsible to clean up the object.

Definition at line 161 of file DBStoreEntry.h.

161{ TObject* obj{nullptr}; std::swap(obj, m_object); return obj; }

◆ removeAccessor()

void removeAccessor ( DBAccessorBase object)
inline

Deregister an Accessor object and remove it from the list of registered objects.

Definition at line 125 of file DBStoreEntry.h.

125{ m_accessors.erase(object); }

◆ require()

void require ( )
inlineprivate

Change status of this payload to required.

Definition at line 169 of file DBStoreEntry.h.

169{ m_isRequired = true; }

Friends And Related Function Documentation

◆ Database

friend class Database
friend

Also allow the Database class to return TObject* pointers for now.

Definition at line 206 of file DBStoreEntry.h.

◆ DBStore

friend class DBStore
friend

Allow only the DBStore class to update the payload contents.

Definition at line 204 of file DBStoreEntry.h.

Member Data Documentation

◆ m_accessors

std::unordered_set<DBAccessorBase*> m_accessors
private

Vector of all the accessors registered with this entry.

Definition at line 202 of file DBStoreEntry.h.

◆ m_checksum

std::string m_checksum
private

checksum of the payload file

Definition at line 193 of file DBStoreEntry.h.

◆ m_filename

std::string m_filename {""}
private

filename containing which contains the actual payload data

Definition at line 191 of file DBStoreEntry.h.

◆ m_globaltag

std::string m_globaltag {""}
private

globaltag name (or testing payloads path) from which this payload is picked.

Definition at line 185 of file DBStoreEntry.h.

◆ m_intraRunDependency

IntraRunDependency* m_intraRunDependency {nullptr}
private

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.

Definition at line 200 of file DBStoreEntry.h.

◆ m_iov

IntervalOfValidity m_iov {0, 0, 0, 0}
private

validity of this payload

Definition at line 189 of file DBStoreEntry.h.

◆ m_isArray

const bool m_isArray
private

True if this payload is an array of objects.

Definition at line 177 of file DBStoreEntry.h.

◆ m_isRequired

bool m_isRequired {false}
private

True if at least one user marked this payload as required, false if this payload is marked optional.

Definition at line 180 of file DBStoreEntry.h.

◆ 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.

◆ m_name

const std::string m_name
private

Name of this payload.

Definition at line 173 of file DBStoreEntry.h.

◆ m_objClass

const TClass* const m_objClass
private

Class of this payload.

Definition at line 175 of file DBStoreEntry.h.

◆ m_object

TObject* m_object {nullptr}
private

Pointer to the actual payload object.

Definition at line 197 of file DBStoreEntry.h.

◆ m_payloadType

const EPayloadType m_payloadType
private

Type of this payload.

Definition at line 171 of file DBStoreEntry.h.

◆ m_revision

unsigned int m_revision {0}
private

revision of this payload

Definition at line 187 of file DBStoreEntry.h.

◆ m_tfile

TFile* m_tfile {nullptr}
private

Pointer to the open ROOT TFile pointer for m_filename.

Definition at line 195 of file DBStoreEntry.h.


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