Belle II Software development
ECLDBTool Class Reference

The ECLDBTool class is designed to read / write object from / to database. More...

#include <ECLDBTool.h>

Public Member Functions

 ECLDBTool (bool isLocal, const char *dbName, const char *payloadName)
 Constructor.
 
 ~ECLDBTool ()
 Destructor.
 
void connect () const
 Connect to a database.
 
void write (TObject *const obj, const IntervalOfValidity &iov) const
 Write object and validity interval to a database.
 
void read (TObject **obj, IntervalOfValidity **iov, const EventMetaData &event) const
 Read object and validity interval from a database.
 
void read (IntervalOfValidity **iov, const EventMetaData &event) const
 Read just validity interval.
 
void changeIoV (const EventMetaData &event, const IntervalOfValidity &iov) const
 Change interval of validity (Make a copy of the current payload with other validity interval).
 

Private Attributes

bool m_isLocal
 If m_isLocal is true, local database is used.
 
std::string m_dbName
 Tag in the central database or path to a local database.
 
std::string m_payloadName
 Name of payload.
 

Detailed Description

The ECLDBTool class is designed to read / write object from / to database.

Definition at line 23 of file ECLDBTool.h.

Constructor & Destructor Documentation

◆ ECLDBTool()

ECLDBTool ( bool  isLocal,
const char *  dbName,
const char *  payloadName 
)

Constructor.

Parameters
isLocalenables local database usage.
dbNameis a tag of the central database or path to a local database.
payloadNameis name of payload.

Definition at line 15 of file ECLDBTool.cc.

17 :
18 m_isLocal(isLocal),
19 m_dbName(dbName),
20 m_payloadName(payloadName)
21{
22}
std::string m_dbName
Tag in the central database or path to a local database.
Definition: ECLDBTool.h:90
bool m_isLocal
If m_isLocal is true, local database is used.
Definition: ECLDBTool.h:85
std::string m_payloadName
Name of payload.
Definition: ECLDBTool.h:94

◆ ~ECLDBTool()

~ECLDBTool ( )

Destructor.

Definition at line 24 of file ECLDBTool.cc.

25{
26}

Member Function Documentation

◆ changeIoV()

void changeIoV ( const EventMetaData event,
const IntervalOfValidity iov 
) const

Change interval of validity (Make a copy of the current payload with other validity interval).

Parameters
eventis the event metadata.
iovis the validity interval.

Definition at line 66 of file ECLDBTool.cc.

68{
69 auto data = Database::Instance().
70 getData(event, m_payloadName.c_str());
71 auto obj = std::get<0>(data);
72 write(obj, iov);
73 delete obj;
74}
void write(TObject *const obj, const IntervalOfValidity &iov) const
Write object and validity interval to a database.
Definition: ECLDBTool.cc:38
static Database & Instance()
Instance of a singleton Database.
Definition: Database.cc:42

◆ connect()

void connect ( ) const

Connect to a database.

Definition at line 28 of file ECLDBTool.cc.

29{
31 if (m_isLocal) {
32 conf.prependTestingPayloadLocation(m_dbName.c_str());
33 } else {
34 conf.prependGlobalTag(m_dbName.c_str());
35 }
36}
static Configuration & getInstance()
Get a reference to the instance which will be used when the Database is initialized.

◆ read() [1/2]

void read ( IntervalOfValidity **  iov,
const EventMetaData event 
) const

Read just validity interval.

Parameters
iovis validity interval.
eventis the event metadata.

Definition at line 55 of file ECLDBTool.cc.

57{
58 auto data = Database::Instance().
59 getData(event, m_payloadName.c_str());
60 auto obj = std::get<0>(data);
61 *iov = new IntervalOfValidity(std::get<1>(data));
62 delete obj;
63}
A class that describes the interval of experiments/runs for which an object in the database is valid.

◆ read() [2/2]

void read ( TObject **  obj,
IntervalOfValidity **  iov,
const EventMetaData event 
) const

Read object and validity interval from a database.

Parameters
objis object.
iovis validity interval.
eventis event metadata.

Definition at line 45 of file ECLDBTool.cc.

48{
49 auto data = Database::Instance().
50 getData(event, m_payloadName.c_str());
51 *obj = std::get<0>(data);
52 *iov = new IntervalOfValidity(std::get<1>(data));
53}

◆ write()

void write ( TObject *const  obj,
const IntervalOfValidity iov 
) const

Write object and validity interval to a database.

Parameters
objis object.
iovis validity interval.

Definition at line 38 of file ECLDBTool.cc.

40{
42 obj, iov);
43}
bool storeData(const std::string &name, TObject *object, const IntervalOfValidity &iov)
Store an object in the database.
Definition: Database.cc:141

Member Data Documentation

◆ m_dbName

std::string m_dbName
private

Tag in the central database or path to a local database.

Definition at line 90 of file ECLDBTool.h.

◆ m_isLocal

bool m_isLocal
private

If m_isLocal is true, local database is used.

Otherwise central database is used.

Definition at line 85 of file ECLDBTool.h.

◆ m_payloadName

std::string m_payloadName
private

Name of payload.

Definition at line 94 of file ECLDBTool.h.


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