Belle II Software  release-05-02-19
PyDBObj.cc
1 /**************************************************************************
2  * BASF2 (Belle Analysis Framework 2) *
3  * Copyright(C) 2012-2017 Belle II Collaboration *
4  * *
5  * Author: The Belle II Collaboration *
6  * Contributors: Martin Ritter *
7  * *
8  * This software is provided "as is" without any warranty. *
9  **************************************************************************/
10 
11 #include <framework/pybasf2/PyDBObj.h>
12 #include <framework/datastore/DataStore.h>
13 
14 #include <TClass.h>
15 
16 using namespace Belle2;
17 
18 namespace {
21  TClass* getDefaultClass(const std::string& name)
22  {
23  // First look for an name without the namespace Belle2::
24  TClass* cl = TClass::GetClass(("Belle2::" + name).c_str());
25  if (!cl) {
26  // If this fails look for a name that already has the full namespace.
27  cl = TClass::GetClass(name.c_str());
28  }
29  if (!cl) return TObject::Class();
30  return cl;
31  }
32 }
33 
34 PyDBObj::PyDBObj(const std::string& name, bool required): PyDBObj(name, getDefaultClass(name), required) {}
35 
36 PyDBObj::PyDBObj(const TClass* objClass, bool required): PyDBObj(DataStore::defaultObjectName(objClass), objClass, required) {}
37 
38 PyDBObj::PyDBObj(const std::string& name, const TClass* objClass, bool required): DBAccessorBase(name, objClass, false, required) {}
Belle2::DBAccessorBase
Base class for DBObjPtr and DBArray for easier common treatment.
Definition: DBAccessorBase.h:28
Belle2::PyDBObj::PyDBObj
PyDBObj(const std::string &name, bool required=true)
Construct the object from the name of the payload.
Definition: PyDBObj.cc:34
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19
Belle2::PyDBObj
Class to access a DBObjPtr from Python.
Definition: PyDBObj.h:50
Belle2::DataStore
In the store you can park objects that have to be accessed by various modules.
Definition: DataStore.h:53