Belle II Software development
PyDBObj.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/pybasf2/PyDBObj.h>
10#include <framework/datastore/DataStore.h>
11
12#include <TClass.h>
13
14using namespace Belle2;
15
16namespace {
19 TClass* getDefaultClass(const std::string& name)
20 {
21 // First look for an name without the namespace Belle2::
22 TClass* cl = TClass::GetClass(("Belle2::" + name).c_str());
23 if (!cl) {
24 // If this fails look for a name that already has the full namespace.
25 cl = TClass::GetClass(name.c_str());
26 }
27 if (!cl) return TObject::Class();
28 return cl;
29 }
30}
31
32PyDBObj::PyDBObj(const std::string& name, bool required): PyDBObj(name, getDefaultClass(name), required) {}
33
34PyDBObj::PyDBObj(const TClass* objClass, bool required): PyDBObj(DataStore::defaultObjectName(objClass), objClass, required) {}
35
36PyDBObj::PyDBObj(const std::string& name, const TClass* objClass, bool required): DBAccessorBase(name, objClass, false, required) {}
37
39{
40 PyObject* list = PyList_New(0);
41 // Currently, the boundaries are defined only as unsigned int.
42 // If in the future this will change, this method has to be updated accordingly.
43 for (auto boundary : getIntraRunBoundaries())
44 PyList_Append(list, PyLong_FromUnsignedLong(boundary));
45 return list;
46}
Base class for DBObjPtr and DBArray for easier common treatment.
const std::vector< unsigned int > getIntraRunBoundaries() const
Get the intra-run boundaries, if any.
In the store you can park objects that have to be accessed by various modules.
Definition: DataStore.h:51
Class to access a DBObjPtr from Python.
Definition: PyDBObj.h:50
PyObject * getIntraRunBoundariesList() const
Get the intra-run boundaries, if any, as a python list.
Definition: PyDBObj.cc:38
PyDBObj(const std::string &name, bool required=true)
Construct the object from the name of the payload.
Definition: PyDBObj.cc:32
Abstract base class for different kinds of events.