9#include <framework/database/DBStoreEntry.h>
10#include <framework/database/DBAccessorBase.h>
11#include <framework/dataobjects/EventMetaData.h>
12#include <framework/logging/Logger.h>
15#include <TClonesArray.h>
20 void deleteAndSetNullptr() {}
24 template<
class T,
class... Args>
void deleteAndSetNullptr(T*& ptr, Args&& ... args)
28 deleteAndSetNullptr(std::forward<Args>(args)...);
40 bool isArray =
dynamic_cast<const TClonesArray*
>(obj) !=
nullptr;
41 TClass* objClass =
isArray ? (
dynamic_cast<const TClonesArray*
>(obj)->GetClass()) : (obj->IsA());
51 if (!
m_accessors.empty()) B2DEBUG(38,
"DBEntry " <<
m_name <<
" destroyed, notifying accessors");
63 B2DEBUG(35,
"IntraRunDependency for " <<
m_name <<
": new object (" << old <<
", " <<
m_object <<
"), notifying accessors");
84 const std::string& checksum,
const std::string& globaltag,
const EventMetaData& event)
105 B2DEBUG(30,
"DBEntry changed"
124 TDirectory* oldDirectory = gDirectory;
126 gDirectory = oldDirectory;
129 B2ERROR(
"Cannot open " << std::quoted(
m_filename) <<
" for reading");
133 m_tfile->SetBit(kCanDelete,
false);
139 B2ERROR(
"Failed to get " << std::quoted(
m_name) <<
" from payload file "
143 m_object->SetBit(kCanDelete,
false);
147 if (
m_object->InheritsFrom(IntraRunDependency::Class())) {
170 B2DEBUG(34,
"DBEntry " << std::quoted(
m_name) <<
" override unchanged");
183 B2DEBUG(34,
"DBEntry " <<
this <<
" " << std::quoted(
m_name) <<
" override created: " << std::endl
184 <<
" object = " <<
m_object << std::endl
185 <<
" validity = " <<
m_iov << std::endl
186 <<
" -> notiying accessors");
201 B2FATAL(
"Existing entry '" <<
m_name <<
"' is of a different type than requested");
207 B2FATAL(
"Existing entry '" <<
m_name <<
"' is an " << ((
m_isArray) ?
"array" :
"object") <<
208 " and the requested one an " << ((array) ?
"array" :
"object"));
214 B2FATAL(
"Existing entry '" <<
m_name <<
"' of type " <<
215 m_objClass->GetName() <<
" doesn't match requested type " <<
216 objClass->GetName());
220 B2FATAL(
"Existing entry '" <<
m_name <<
"' of type " <<
221 m_objClass->GetName() <<
" doesn't match actual type " <<
222 objClass->GetName());
231 if (object->InheritsFrom(IntraRunDependency::Class())) {
234 TClass* objClass =
object->IsA();
235 bool array = (objClass == TClonesArray::Class());
237 objClass =
static_cast<const TClonesArray*
>(object)->GetClass();
Base class for DBObjPtr and DBArray for easier common treatment.
Class to hold one entry from the ConditionsDB in the DBStore.
std::unordered_set< DBAccessorBase * > m_accessors
Vector of all the accessors registered with this entry.
EPayloadType
Possible Store entry types.
@ c_RawFile
Just a plain old file, we don't look at it just provide the filename.
@ c_Object
A ROOT file containing a object with the name of the DBStoreEntry.
bool isIntraRunDependent() const
return whether or not the payload might change even during the run
IntraRunDependency * m_intraRunDependency
If the payload has intra run dependency this will point to the whole payload and m_object will just p...
IntervalOfValidity m_iov
validity of this payload
unsigned int m_revision
revision of this payload
std::string m_checksum
checksum of the payload file
const std::string m_name
Name of this payload.
bool m_keep
if True this payload should not be updated unless it's really out of date.
bool isRequired() const
check whether this payload is required for operation
const EPayloadType m_payloadType
Type of this payload.
TFile * m_tfile
Pointer to the open ROOT TFile pointer for m_filename.
std::string m_filename
filename containing which contains the actual payload data
const bool m_isArray
True if this payload is an array of objects.
std::string m_globaltag
globaltag name (or testing payloads path) from which this payload is picked.
bool isArray() const
get whether this payload is an array of objects or a single objects
const TClass *const m_objClass
Class of this payload.
TObject * m_object
Pointer to the actual payload object.
A class that describes the interval of experiments/runs for which an object in the database is valid.
Base class for handling changing conditions during a run.
TObject * getObject(const EventMetaData &event) const
Get the conditions object that is valid for the given event.
Class to store variables with their name which were sent to the logging service.
void notifyAccessors(bool onDestruction=false)
Notify all the registered accessors.
void resetPayload()
reset the payload to nothing
bool checkType(const TObject *object) const
Check if a given TObject instance is compatible with the type of this entry.
void updateObject(const EventMetaData &event)
update the payload object according to the new event information.
~DBStoreEntry()
Clean up memory.
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 databa...
static DBStoreEntry fromObject(const std::string &name, const TObject *obj, bool isRequired)
Construct a new DBStoreEntry with a requested name and an object directly.
void loadPayload(const EventMetaData &event)
Actual load the payload from file after all info is set.
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 ob...
Abstract base class for different kinds of events.