 |
Belle II Software
release-05-02-19
|
11 #include <framework/database/DBStoreEntry.h>
12 #include <framework/database/DBAccessorBase.h>
13 #include <framework/database/IntraRunDependency.h>
14 #include <framework/dataobjects/EventMetaData.h>
15 #include <framework/logging/Logger.h>
18 #include <TClonesArray.h>
23 void deleteAndSetNullptr() {}
27 template<
class T,
class... Args>
void deleteAndSetNullptr(T*& ptr, Args&& ... args)
31 deleteAndSetNullptr(std::forward<Args>(args)...);
42 bool isArray =
dynamic_cast<const TClonesArray*
>(obj) !=
nullptr;
43 TClass* objClass =
isArray ? (
dynamic_cast<const TClonesArray*
>(obj)->GetClass()) : (obj->IsA());
53 if (!
m_accessors.empty()) B2DEBUG(38,
"DBEntry " <<
m_name <<
" destroyed, notifying accessors");
65 B2DEBUG(35,
"IntraRunDependency for " <<
m_name <<
": new object (" << old <<
", " <<
m_object <<
"), notifying accessors");
105 B2DEBUG(30,
"DBEntry changed"
123 TDirectory* oldDirectory = gDirectory;
125 gDirectory = oldDirectory;
128 B2ERROR(
"Cannot open " << std::quoted(
m_filename) <<
" for reading");
132 m_tfile->SetBit(kCanDelete,
false);
138 B2ERROR(
"Failed to get " << std::quoted(
m_name) <<
" from payload file "
142 m_object->SetBit(kCanDelete,
false);
146 if (
m_object->InheritsFrom(IntraRunDependency::Class())) {
168 B2DEBUG(34,
"DBEntry " << std::quoted(
m_name) <<
" override unchanged");
181 B2DEBUG(34,
"DBEntry " <<
this <<
" " << std::quoted(
m_name) <<
" override created: " << std::endl
182 <<
" object = " <<
m_object << std::endl
183 <<
" validity = " <<
m_iov << std::endl
184 <<
" -> notiying accessors");
199 B2FATAL(
"Existing entry '" <<
m_name <<
"' is of a different type than requested");
205 B2FATAL(
"Existing entry '" <<
m_name <<
"' is an " << ((
m_isArray) ?
"array" :
"object") <<
206 " and the requested one an " << ((array) ?
"array" :
"object"));
212 B2FATAL(
"Existing entry '" <<
m_name <<
"' of type " <<
213 m_objClass->GetName() <<
" doesn't match requested type " <<
214 objClass->GetName());
218 B2FATAL(
"Existing entry '" <<
m_name <<
"' of type " <<
219 m_objClass->GetName() <<
" doesn't match actual type " <<
220 objClass->GetName());
229 if (object->InheritsFrom(IntraRunDependency::Class())) {
232 TClass* objClass =
object->IsA();
233 bool array = (objClass == TClonesArray::Class());
235 objClass =
static_cast<const TClonesArray*
>(object)->GetClass();
A class that describes the interval of experiments/runs for which an object in the database is valid.
TObject * m_object
Pointer to the actual payload object.
std::string m_checksum
checksum of the payload file
@ c_Object
A ROOT file containing a object with the name of the DBStoreEntry.
bool isRequired() const
check whether this payload is required for operation
IntervalOfValidity m_iov
validity of this payload
Class to hold one entry from the ConditionsDB in the DBStore.
unsigned int m_revision
revision of this payload
~DBStoreEntry()
Clean up memory.
bool isArray() const
get whether this payload is an array of objects or a single objects
std::string m_filename
filename containing which contains the actual payload data
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...
Base class for DBObjPtr and DBArray for easier common treatment.
bool m_keep
if True this payload should not be updated unless it's really out of date.
DBStoreEntry(EPayloadType type, const std::string &name, const TClass *objClass, bool isArray, bool isRequired)
Construct a new DBStoreEntry.
EPayloadType
Possible Store entry types.
std::unordered_set< DBAccessorBase * > m_accessors
Vector of all the accessors registered with this entry.
IntraRunDependency * m_intraRunDependency
If the payload has intra run dependency this will point to the whole payload and m_object will just p...
void notifyAccessors(bool onDestruction=false)
Notify all the registered accessors.
void loadPayload(const EventMetaData &event)
Actual load the payload from file after all info is set.
bool checkType(const TObject *object) const
Check if a given TObject instance is compatible with the type of this entry.
void updatePayload(unsigned int revision, const IntervalOfValidity &iov, const std::string &filename, const std::string &checksum, const EventMetaData &event)
Update the payload information for this entry and if appropriate open the new file and extract the ob...
static DBStoreEntry fromObject(const std::string &name, const TObject *obj, bool isRequired)
Construct a new DBStoreEntry with a requested name and an object directly.
const bool m_isArray
True if this payload is an array of objects.
Abstract base class for different kinds of events.
const TClass *const m_objClass
Class of this payload.
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.
Base class for handling changing conditions during a run.
const std::string m_name
Name of this payload.
const EPayloadType m_payloadType
Type of this payload.
void updateObject(const EventMetaData &event)
update the payload object according to the new event information.
bool isIntraRunDependent() const
return whether or not the payload might change even during the run
TFile * m_tfile
Pointer to the open ROOT TFile pointer for m_filename.
@ c_RawFile
Just a plain old file, we don't look at it just provide the filename.
void resetPayload()
reset the payload to nothing