Belle II Software light-2406-ragdoll
DBImportBase.cc
1/**************************************************************************
2 * basf2 (Belle II Analysis Software Framework) *
3 * Author: The Belle II Collaboration *
4 * *
5 * See git log for contributors and copyright holders. *
6 * This file is licensed under LGPL-3.0, see LICENSE.md. *
7 **************************************************************************/
8
9#include <framework/database/DBImportBase.h>
10#include <framework/database/EventDependency.h>
11#include <framework/database/Database.h>
12#include <framework/logging/Logger.h>
13
14using namespace std;
15using namespace Belle2;
16
17void DBImportBase::addIntraRunDependency(unsigned long long int tag,
18 EIntraRunDependency dependency)
19{
20
21 if (!m_object) return;
22
23 if (m_dependency == c_None) m_dependency = dependency;
24 if (dependency == m_dependency) {
25 m_objects.push_back(m_object);
26 m_tags.push_back(tag);
27 m_object = nullptr;
28 } else {
29 B2FATAL("DBImportBase::addIntraRunDependency: " <<
30 "intra run dependency cannot be of mixed types");
31 }
32
33}
34
35
37{
38
39 switch (m_dependency) {
40 case c_Event:
41 return import<EventDependency>(iov);
42 case c_TimeStamp:
43 B2ERROR("DBImportBase::import: " <<
44 "intra run dependency of type 'time stamp' not supported yet");
45 return false;
46 case c_Subrun:
47 B2ERROR("DBImportBase::import: " <<
48 "intra run dependency of type 'subrun' not supported yet");
49 return false;
50 default:
51 if (!m_object) return false;
53 }
54
55}
56
57
59{
60 if (m_object) {
61 delete m_object;
62 m_object = nullptr;
63 }
64
65 m_dependency = c_None;
66 for (auto& object : m_objects) delete object;
67 m_objects.clear();
68 m_tags.clear();
69}
70
71bool DBImportBase::storeData(TObject* intraRun, const IntervalOfValidity& iov)
72{
73 return Database::Instance().storeData(m_name, intraRun, iov);
74}
75
77{
78 for (auto& object : m_objects) delete object;
79}
bool import(const IntervalOfValidity &iov)
Import the object to database.
Definition: DBImportBase.cc:36
void addIntraRunDependency(unsigned long long int tag, EIntraRunDependency type)
add intra run dependency
Definition: DBImportBase.cc:17
EIntraRunDependency
Intra run dependency types (used only internaly)
Definition: DBImportBase.h:86
virtual ~DBImportBase()
Destructor.
Definition: DBImportBase.cc:76
std::vector< unsigned long long int > m_tags
container for intra run dep.
Definition: DBImportBase.h:139
bool storeData(TObject *intraRun, const IntervalOfValidity &iov)
Store intra run dependent objects.
Definition: DBImportBase.cc:71
std::vector< TObject * > m_objects
container for intra run dependency objects
Definition: DBImportBase.h:138
virtual void clear()
Clear the content, e.g.
Definition: DBImportBase.cc:58
std::string m_name
object or array name in database
Definition: DBImportBase.h:99
EIntraRunDependency m_dependency
dependency type
Definition: DBImportBase.h:137
TObject * m_object
pointer to allocated object or array
Definition: DBImportBase.h:100
A class that describes the interval of experiments/runs for which an object in the database is valid.
static Database & Instance()
Instance of a singleton Database.
Definition: Database.cc:42
bool storeData(const std::string &name, TObject *object, const IntervalOfValidity &iov)
Store an object in the database.
Definition: Database.cc:141
Abstract base class for different kinds of events.
Definition: ClusterUtils.h:24
STL namespace.