 |
Belle II Software
release-05-02-19
|
11 #include <framework/database/DBStore.h>
12 #include <framework/database/Database.h>
13 #include <framework/logging/Logger.h>
35 const TClass* objClass,
bool array,
bool required)
43 if (!dbEntry.
checkType(type, objClass, array))
return nullptr;
45 B2DEBUG(39,
"DBEntry " << name <<
" was requested once more.");
48 B2DEBUG(34,
"DBEntry " << name <<
" is now required");
54 const auto iter =
m_dbEntries.emplace(name, DBStoreEntry{type, name, objClass, array, required});
55 DBStoreEntry& dbEntry = iter.first->second;
56 B2DEBUG(34,
"DBEntry " << name <<
" was created (" << (required ?
"required" :
"optional") <<
")");
64 dbEntry.updatePayload(query.revision, query.iov, query.filename, query.checksum, *
m_manualEvent);
72 dbEntry.updatePayload(query.revision, query.iov, query.filename, query.checksum, *
m_storeEvent);
115 std::vector<Database::DBQuery> entries;
118 bool expired = !entry.second.getIoV().contains(event);
120 B2DEBUG(34,
"DBEntry " << entry.first <<
" out of date, will need update");
122 if (!entry.second.keepUntilExpired() || expired)
123 entries.emplace_back(entry.first, entry.second.isRequired());
129 if (entries.empty())
return;
135 for (
auto& query : entries) {
136 auto& dbEntry =
m_dbEntries.find(query.name)->second;
137 dbEntry.updatePayload(query.revision, query.iov, query.filename, query.checksum, event);
147 B2WARNING(
"DBStore is currently using manual event information. But you are asking for the DataStore's EventMetaData "
148 "to be used to update the Intra-run dependencies. Update could not proceed. "
149 "Did you forget to call DBStore::Instance().update() before calling this function?");
162 B2WARNING(
"DBStore is not currently using manual event information. But you are asking for the event number to be set "
163 " to a custom value. Update of the Intra-run dependencies could not proceed. "
164 "Did you forget to call DBStore::Instance().update(event), or accidentally call DBStore::Instance().update() "
165 "prior to to this?");
173 dbEntry->updateObject(event);
180 B2DEBUG(31,
"DBStore::reset(): Cleaning all database information");
186 entry.second.resetPayload();
191 StoreObjPtr<EventMetaData> event;
208 iov = IntervalOfValidity(exp, run, exp, run);
215 DBStoreEntry& dbEntry = iter->second;
216 dbEntry.overrideObject(obj, iov);
220 B2WARNING(
"An override for DBEntry " << name <<
" was created.");
std::pair< TObject *, IntervalOfValidity > getData(const EventMetaData &event, const std::string &name)
Request an object from the database.
bool isRequired() const
check whether this payload is required for operation
void addConstantOverride(const std::string &name, TObject *obj, bool oneRun=false)
Add constant override payload.
void require()
Change status of this payload to required.
static IntervalOfValidity always()
Function that returns an interval of validity that is always valid, c.f.
Class to hold one entry from the ConditionsDB in the DBStore.
void reset(bool keepEntries=false)
Invalidate all payloads.
EPayloadType
Possible Store entry types.
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.
bool checkType(const TObject *object) const
Check if a given TObject instance is compatible with the type of this entry.
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 performUpdate(const EventMetaData &event)
The main code that does an update, factored out so it can be used by both update and update(event).
StoreObjPtr< EventMetaData > m_storeEvent
StoreObjPtr for the EventMetaData to get the current experiment and run from the DataStore.
Abstract base class for different kinds of events.
Type-safe access to single objects in the data store.
static DBStore & Instance()
Instance of a singleton DBStore.
std::unordered_map< std::string, DBStoreEntry > m_dbEntries
Map names to DBEntry objects.
@ c_InitGlobaltagList
Globaltag list has been finalized metadata providers not and globaltags are not checked for usability...
void updateEvent()
Updates all intra-run dependent objects.
void performUpdateEvent(const EventMetaData &event)
The main code that does an updateEvent.
void initialize(const EDatabaseState target=c_Ready)
Initialize the database connection settings on first use.
boost::optional< EventMetaData > m_manualEvent
Optional EventMetaData variable.
static Database & Instance()
Instance of a singleton Database.
DBStore()
Hidden constructor, as it is a singleton.
Conditions::PayloadMetadata DBQuery
Struct for bulk read queries.
std::set< DBStoreEntry * > m_intraRunDependencies
List of intra-run dependent conditions.
void update()
Updates all objects that are outside their interval of validity.