Belle II Software development
DBObjPtr.h
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#pragma once
9
10#include <framework/database/DBAccessorBase.h>
11
12namespace Belle2 {
21 template<class T> class DBObjPtr: public DBAccessorBase {
22 public:
23
31 explicit DBObjPtr(const std::string& name = "", bool required = true):
32 DBAccessorBase(DBStore::objectName<T>(name), T::Class(), false, required) {}
33
34 inline const T& operator *() const {return *getObject<T>(); }
35 inline const T* operator ->() const {return getObject<T>(); }
36 };
37
48 template<class T> class OptionalDBObjPtr: public DBObjPtr<T> {
49 public:
52 explicit OptionalDBObjPtr(const std::string& name = ""): DBObjPtr<T>(name, false) {}
53 };
55}
Base class for DBObjPtr and DBArray for easier common treatment.
Class for accessing objects in the database.
Definition: DBObjPtr.h:21
const T & operator*() const
Imitate pointer functionality.
Definition: DBObjPtr.h:34
const T * operator->() const
Imitate pointer functionality.
Definition: DBObjPtr.h:35
DBObjPtr(const std::string &name="", bool required=true)
Constructor to access an object in the DBStore.
Definition: DBObjPtr.h:31
Singleton class to cache database objects.
Definition: DBStore.h:31
Optional DBObjPtr: This class behaves the same as the DBObjPtr except that it will not raise errors w...
Definition: DBObjPtr.h:48
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:52
Abstract base class for different kinds of events.