Belle II Software  release-05-02-19
DBObjPtr.h
1 /**************************************************************************
2  * BASF2 (Belle Analysis Framework 2) *
3  * Copyright(C) 2015-2018 Belle II Collaboration *
4  * *
5  * Author: The Belle II Collaboration *
6  * Contributors: Thomas Kuhr, Martin Ritter *
7  * *
8  * This software is provided "as is" without any warranty. *
9  **************************************************************************/
10 #pragma once
11 
12 #include <framework/database/DBAccessorBase.h>
13 
14 namespace Belle2 {
23  template<class T> class DBObjPtr: public DBAccessorBase {
24  public:
25 
30  explicit DBObjPtr(const std::string& name = "", bool required = true):
31  DBAccessorBase(DBStore::objectName<T>(name), T::Class(), false, required) {}
32 
33  inline const T& operator *() const {return *getObject<T>(); }
34  inline const T* operator ->() const {return getObject<T>(); }
35  };
36 
47  template<class T> class OptionalDBObjPtr: public DBObjPtr<T> {
48  public:
51  explicit OptionalDBObjPtr(const std::string& name = ""): DBObjPtr<T>(name, false) {}
52  };
54 }
Belle2::DBObjPtr::DBObjPtr
DBObjPtr(const std::string &name="", bool required=true)
Constructor to access an object in the DBStore.
Definition: DBObjPtr.h:38
Belle2::DBAccessorBase
Base class for DBObjPtr and DBArray for easier common treatment.
Definition: DBAccessorBase.h:28
Belle2::operator*
B2Vector3< DataType > operator*(DataType a, const B2Vector3< DataType > &p)
non-memberfunction Scaling of 3-vectors with a real number
Definition: B2Vector3.h:528
Belle2::DBStore
Singleton class to cache database objects.
Definition: DBStore.h:42
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19
Belle2::OptionalDBObjPtr::OptionalDBObjPtr
OptionalDBObjPtr(const std::string &name="")
Construct a new Array with a given name or with the default name which is identical to the class name...
Definition: DBObjPtr.h:59