Belle II Software  release-05-01-25
Database Class Reference

Singleton base class for the low-level interface to the database. More...

#include <Database.h>

Collaboration diagram for Database:

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 *, IntervalOfValiditygetData (const EventMetaData &event, const std::string &name)
 Request an object from the database. More...
 
bool getData (const EventMetaData &event, DBQuery &query)
 Request an object from the database. More...
 
bool getData (const EventMetaData &event, std::vector< DBQuery > &query)
 Request multiple objects from the database. More...
 
bool storeData (const std::string &name, TObject *object, const IntervalOfValidity &iov)
 Store an object in the database. More...
 
bool storeData (TClonesArray *array, const IntervalOfValidity &iov)
 Store an ClonesArray in the database with the default name. More...
 
template<class T >
bool storeData (T *object, const IntervalOfValidity &iov)
 Store an object in the database with the default name. More...
 
bool storeData (std::list< DBImportQuery > &query)
 Store multiple objects in the database. More...
 
bool addPayload (const std::string &name, const std::string &fileName, const IntervalOfValidity &iov)
 Add a payload file to the database. More...
 
std::string getGlobalTags ()
 Return the global tags used by the database. More...
 
ScopeGuard createScopedUpdateSession ()
 Make sure we have efficient http pipelinging during initialize/beginRun but don't keep session alive for full processing time. More...
 
void initialize (const EDatabaseState target=c_Ready)
 Initialize the database connection settings on first use.
 

Static Public Member Functions

static DatabaseInstance ()
 Instance of a singleton Database.
 
static void reset (bool keepConfig=false)
 Reset the database instance. More...
 
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::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::MetadataProviderm_metadataProvider
 Currently active metadata provider.
 
std::unique_ptr< Conditions::PayloadProviderm_payloadProvider
 The active payload provider.
 
std::unique_ptr< Conditions::TestingPayloadStoragem_payloadCreation
 testing payload storage to create new payloads
 
std::vector< Conditions::TestingPayloadStoragem_testingPayloads
 optional list of testing payload storages to look for existing payloads
 
EDatabaseState m_configState {c_PreInit}
 Current configuration state of the database.
 

Detailed Description

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 44 of file Database.h.

Member Enumeration Documentation

◆ 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 47 of file Database.h.

47  {
49  c_PreInit = 0,
53  c_Ready = 2,
54  };

Member Function Documentation

◆ addPayload()

bool addPayload ( const std::string &  name,
const std::string &  fileName,
const IntervalOfValidity iov 
)
inline

Add a payload file to the database.

Parameters
nameName that identifies the object in the database.
fileNameThe name of the payload file.
iovThe interval of validity of the the object.
Returns
True if the storage of the object succeeded.

Definition at line 174 of file Database.h.

◆ getData()

bool getData ( const EventMetaData event,
DBQuery query 
)
inline

Request an object from the database.

Parameters
eventThe metadata of the event for which the object should be valid.
queryObject containing the necessary identification which will be filled with all information about the payload.
Returns
True if the payload could be found. False otherwise.

Definition at line 112 of file Database.h.

◆ storeData() [1/2]

bool storeData ( T *  object,
const IntervalOfValidity iov 
)
inline

Store an object in the database with the default name.

Parameters
objectThe object that should be stored in the database.
iovThe interval of validity of the the object.
Returns
True if the storage of the object succeeded.

Definition at line 156 of file Database.h.

◆ storeData() [2/2]

bool storeData ( TClonesArray *  array,
const IntervalOfValidity iov 
)
inline

Store an ClonesArray in the database with the default name.

Parameters
arrayThe object that should be stored in the database.
iovThe interval of validity of the the object.
Returns
True if the storage of the object succeeded.

Definition at line 147 of file Database.h.


The documentation for this class was generated from the following files:
Belle2::Database::c_PreInit
@ c_PreInit
Before any initialization.
Definition: Database.h:49
Belle2::Database::c_InitGlobaltagList
@ c_InitGlobaltagList
Globaltag list has been finalized metadata providers not and globaltags are not checked for usability...
Definition: Database.h:51
Belle2::Database::c_Ready
@ c_Ready
Everything is ready.
Definition: Database.h:53