Belle II Software development
|
Singleton base class for the low-level interface to the database. More...
#include <Database.h>
Classes | |
struct | DBImportQuery |
Struct for bulk write queries. More... | |
Public Types | |
enum | EDatabaseState { c_PreInit = 0 , c_InitGlobaltagList = 1 , c_Ready = 2 } |
State of the database. More... | |
using | DBQuery = Conditions::PayloadMetadata |
Struct for bulk read queries. | |
Public Member Functions | |
std::pair< TObject *, IntervalOfValidity > | getData (const EventMetaData &event, const std::string &name) |
Request an object from the database. | |
bool | getData (const EventMetaData &event, DBQuery &query) |
Request an object from the database. | |
bool | getData (const EventMetaData &event, std::vector< DBQuery > &query) |
Request multiple objects from the database. | |
const TObject * | getData (const std::string &name, int experiment, int run) |
Convenience function to get an object for an arbitrary experiment and run. | |
std::set< std::string > | getAllDataNames () |
Return the names of all the payloads stored in the database at the time of this function is called. | |
bool | storeData (const std::string &name, TObject *object, const IntervalOfValidity &iov) |
Store an object in the database. | |
bool | storeData (TClonesArray *array, const IntervalOfValidity &iov) |
Store an ClonesArray in the database with the default name. | |
template<class T > | |
bool | storeData (T *object, const IntervalOfValidity &iov) |
Store an object in the database with the default name. | |
bool | storeData (std::list< DBImportQuery > &query) |
Store multiple objects in the database. | |
bool | addPayload (const std::string &name, const std::string &fileName, const IntervalOfValidity &iov) |
Add a payload file to the database. | |
std::string | getGlobalTags () |
Return the global tags used by the database. | |
ScopeGuard | createScopedUpdateSession () |
Make sure we have efficient http pipelinging during initialize/beginRun but don't keep session alive for full processing time. | |
void | initialize (const EDatabaseState target=c_Ready) |
Initialize the database connection settings on first use. | |
Static Public Member Functions | |
static Database & | Instance () |
Instance of a singleton Database. | |
static void | reset (bool keepConfig=false) |
Reset the database instance. | |
static void | exposePythonAPI () |
Exposes setGlobalTag function of the Database class to Python. | |
Protected Member Functions | |
Database ()=default | |
Hidden constructor, as it is a singleton. | |
Database (const Database &)=delete | |
No copy constructor, as it is a singleton. | |
~Database () | |
Hidden destructor, as it is a singleton. | |
void | nextMetadataProvider () |
Enable the next metadataprovider in the list. | |
Protected Attributes | |
std::vector< std::string > | m_metadataConfigurations |
List of available metadata providers (which haven't been tried yet) | |
std::string | m_currentProvider |
Name of the currently used metadata provider. | |
std::vector< std::string > | m_globalTags |
List of globaltags to be used. | |
std::set< std::string > | m_usableTagStates |
Set of usable globaltag states to be handed to the metadata providers. | |
std::unique_ptr< Conditions::MetadataProvider > | m_metadataProvider |
Currently active metadata provider. | |
std::unique_ptr< Conditions::PayloadProvider > | m_payloadProvider |
The active payload provider. | |
std::unique_ptr< Conditions::TestingPayloadStorage > | m_payloadCreation |
testing payload storage to create new payloads | |
std::vector< Conditions::TestingPayloadStorage > | m_testingPayloads |
optional list of testing payload storages to look for existing payloads | |
EDatabaseState | m_configState {c_PreInit} |
Current configuration state of the database. | |
Singleton base class for the low-level interface to the database.
To be used by the DBStore. Currently the Database instance keeps the ownership of the objects, but this may change for the final backend.
Definition at line 42 of file Database.h.
using DBQuery = Conditions::PayloadMetadata |
Struct for bulk read queries.
Definition at line 72 of file Database.h.
enum EDatabaseState |
State of the database.
Enumerator | |
---|---|
c_PreInit | Before any initialization. |
c_InitGlobaltagList | Globaltag list has been finalized metadata providers not and globaltags are not checked for usability. |
c_Ready | Everything is ready. |
Definition at line 45 of file Database.h.
|
inline |
Add a payload file to the database.
name | Name that identifies the object in the database. |
fileName | The name of the payload file. |
iov | The interval of validity of the the object. |
Definition at line 192 of file Database.h.
|
inline |
Return the names of all the payloads stored in the database at the time of this function is called.
This is equivalent to getting all the payloads' names used by the current basf2 process.
Definition at line 146 of file Database.h.
|
inline |
Request an object from the database.
event | The metadata of the event for which the object should be valid. |
query | Object containing the necessary identification which will be filled with all information about the payload. |
Definition at line 110 of file Database.h.
|
inline |
Convenience function to get an object for an arbitrary experiment and run.
[in] | name | The name identifying the object. |
[in] | experiment | The experiment number. |
[in] | run | The run number. |
Definition at line 135 of file Database.h.
|
inline |
Store an object in the database with the default name.
object | The object that should be stored in the database. |
iov | The interval of validity of the the object. |
Definition at line 174 of file Database.h.
|
inline |
Store an ClonesArray in the database with the default name.
array | The object that should be stored in the database. |
iov | The interval of validity of the the object. |
Definition at line 165 of file Database.h.
|
protected |
Current configuration state of the database.
Definition at line 246 of file Database.h.
|
protected |
Name of the currently used metadata provider.
Definition at line 232 of file Database.h.
|
protected |
List of globaltags to be used.
Definition at line 234 of file Database.h.
|
protected |
List of available metadata providers (which haven't been tried yet)
Definition at line 230 of file Database.h.
|
protected |
Currently active metadata provider.
Definition at line 238 of file Database.h.
|
protected |
testing payload storage to create new payloads
Definition at line 242 of file Database.h.
|
protected |
The active payload provider.
Definition at line 240 of file Database.h.
|
protected |
optional list of testing payload storages to look for existing payloads
Definition at line 244 of file Database.h.
|
protected |
Set of usable globaltag states to be handed to the metadata providers.
Definition at line 236 of file Database.h.