Belle II Software  release-08-01-10
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...
 
const TObject * getData (const std::string &name, int experiment, int run)
 Convenience function to get an object for an arbitrary experiment and run. More...
 
std::set< std::string > getAllDataNames ()
 Return the names of all the payloads stored in the database at the time of this function is called. 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::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::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 42 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 45 of file Database.h.

45  {
47  c_PreInit = 0,
51  c_Ready = 2,
52  };
@ c_PreInit
Before any initialization.
Definition: Database.h:47
@ c_InitGlobaltagList
Globaltag list has been finalized metadata providers not and globaltags are not checked for usability...
Definition: Database.h:49
@ c_Ready
Everything is ready.
Definition: Database.h:51

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

◆ getAllDataNames()

std::set<std::string> getAllDataNames ( )
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.

◆ getData() [1/2]

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

◆ getData() [2/2]

const TObject* getData ( const std::string &  name,
int  experiment,
int  run 
)
inline

Convenience function to get an object for an arbitrary experiment and run.

Parameters
[in]nameThe name identifying the object.
[in]experimentThe experiment number.
[in]runThe run number.

Definition at line 135 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 174 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 165 of file Database.h.


The documentation for this class was generated from the following files: