10#include <framework/database/IntervalOfValidity.h>
11#include <framework/database/PayloadMetadata.h>
12#include <framework/database/TestingPayloadStorage.h>
13#include <framework/database/DBStore.h>
14#include <framework/utilities/ScopeGuard.h>
15#include <TClonesArray.h>
31 namespace Conditions {
32 class MetadataProvider;
33 class PayloadProvider;
67 static void reset(
bool keepConfig =
false);
84 explicit DBImportQuery(
const std::string& aName, TObject* aObject =
nullptr,
101 std::pair<TObject*, IntervalOfValidity>
getData(
const EventMetaData& event,
const std::string& name);
112 std::vector<DBQuery> container{query};
113 bool found =
getData(event, container);
114 query = container[0];
135 const TObject*
getData(
const std::string& name,
int experiment,
int run)
138 return getData(eventMetaData, name).first;
182 bool storeData(std::list<DBImportQuery>& query);
static std::string defaultArrayName()
Return the default storage name for an array of the given type.
Singleton base class for the low-level interface to the database.
std::string m_currentProvider
Name of the currently used metadata provider.
Database(const Database &)=delete
No copy constructor, as it is a singleton.
bool getData(const EventMetaData &event, DBQuery &query)
Request an object from the database.
std::unique_ptr< Conditions::MetadataProvider > m_metadataProvider
Currently active metadata provider.
EDatabaseState m_configState
Current configuration state of the database.
bool storeData(T *object, const IntervalOfValidity &iov)
Store an object in the database with the default name.
EDatabaseState
State of the database.
@ 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.
std::unique_ptr< Conditions::PayloadProvider > m_payloadProvider
The active payload provider.
std::set< std::string > m_usableTagStates
Set of usable globaltag states to be handed to the metadata providers.
bool storeData(TClonesArray *array, const IntervalOfValidity &iov)
Store an ClonesArray in the database with the default name.
std::unique_ptr< Conditions::TestingPayloadStorage > m_payloadCreation
testing payload storage to create new payloads
std::vector< std::string > m_globalTags
List of globaltags to be used.
bool addPayload(const std::string &name, const std::string &fileName, const IntervalOfValidity &iov)
Add a payload file to the database.
std::vector< Conditions::TestingPayloadStorage > m_testingPayloads
optional list of testing payload storages to look for existing payloads
std::set< std::string > getAllDataNames()
Return the names of all the payloads stored in the database at the time of this function is called.
std::vector< std::string > m_metadataConfigurations
List of available metadata providers (which haven't been tried yet)
Database()=default
Hidden constructor, as it is a singleton.
const TObject * getData(const std::string &name, int experiment, int run)
Convenience function to get an object for an arbitrary experiment and run.
A class that describes the interval of experiments/runs for which an object in the database is valid.
Simple ScopeGuard to execute a function at the end of the object lifetime.
std::string getGlobalTags()
Return the global tags used by the database.
void initialize(const EDatabaseState target=c_Ready)
Initialize the database connection settings on first use.
~Database()
Hidden destructor, as it is a singleton.
std::pair< TObject *, IntervalOfValidity > getData(const EventMetaData &event, const std::string &name)
Request an object from the database.
static Database & Instance()
Instance of a singleton Database.
static DBStore & Instance()
Instance of a singleton DBStore.
static void exposePythonAPI()
Exposes setGlobalTag function of the Database class to Python.
bool storeData(const std::string &name, TObject *object, const IntervalOfValidity &iov)
Store an object in the database.
void nextMetadataProvider()
Enable the next metadataprovider in the list.
std::set< std::string > getAllEntryNames()
Return the names of all the payloads stored in the database at the time of this function is called.
static void reset(bool keepConfig=false)
Reset the database instance.
ScopeGuard createScopedUpdateSession()
Make sure we have efficient http pipelinging during initialize/beginRun but don't keep session alive ...
Abstract base class for different kinds of events.
Struct for bulk write queries.
IntervalOfValidity iov
Interval of validity of the object.
TObject * object
Pointer to the object.
DBImportQuery(const std::string &aName, TObject *aObject=nullptr, const IntervalOfValidity &aIov=IntervalOfValidity())
Constructor.
std::string name
identifier of the object