Belle II Software development
DBPointer< T, KEY, METHOD, NAME > Class Template Reference

Class for pointing to an element in an array stored in the database. More...

#include <DBPointer.h>

Public Member Functions

 DBPointer (KEY key)
 Constructor of pointer to an array element in the database.
 
KEY key () const
 Accessor for key value.
 
 operator KEY () const
 Accessor for key value.
 
KEY operator= (KEY key)
 Setter for key value.
 
bool isValid () const
 Check whether we point to a valid object.
 
 operator bool () const
 Is this pointer's data safe to access?
 
const T & operator* () const
 Imitate pointer functionality.
 
const T * operator-> () const
 Imitate pointer functionality.
 

Private Member Functions

const T * getPointer () const
 Find the referred object and set m_object to it.
 

Private Attributes

KEY m_key
 Key value of the referred array element.
 
const T * m_object
 Pointer to actual object.
 

Detailed Description

template<class T, typename KEY, KEY(T::*)() const METHOD, const std::string & NAME = DBPointer_defaultName>
class Belle2::DBPointer< T, KEY, METHOD, NAME >

Class for pointing to an element in an array stored in the database.

Definition at line 24 of file DBPointer.h.

Constructor & Destructor Documentation

◆ DBPointer()

template<class T, typename KEY, KEY(T::*)() const METHOD, const std::string & NAME = DBPointer_defaultName>
DBPointer ( KEY key)
inlineexplicit

Constructor of pointer to an array element in the database.

Parameters
keyThe key value to identify the element.

Definition at line 31 of file DBPointer.h.

31 :
32 m_key(key), m_object(0) {};

Member Function Documentation

◆ getPointer()

template<class T, typename KEY, KEY(T::*)() const METHOD, const std::string & NAME = DBPointer_defaultName>
const T * getPointer ( ) const
inlineprivate

Find the referred object and set m_object to it.

Definition at line 57 of file DBPointer.h.

58 {
59 if (!m_object) {
60 DBArray<T> array(NAME);
61 m_object = array.getByKey(METHOD, m_key);
62 }
63 return m_object;
64 }

◆ isValid()

template<class T, typename KEY, KEY(T::*)() const METHOD, const std::string & NAME = DBPointer_defaultName>
bool isValid ( ) const
inline

Check whether we point to a valid object.

Returns
True if the object exists.

Definition at line 47 of file DBPointer.h.

47{return getPointer();}

◆ key()

template<class T, typename KEY, KEY(T::*)() const METHOD, const std::string & NAME = DBPointer_defaultName>
KEY key ( ) const
inline

Accessor for key value.

Definition at line 35 of file DBPointer.h.

35{return m_key;}

◆ operator bool()

template<class T, typename KEY, KEY(T::*)() const METHOD, const std::string & NAME = DBPointer_defaultName>
operator bool ( ) const
inline

Is this pointer's data safe to access?

Definition at line 50 of file DBPointer.h.

50{return isValid();}
bool isValid(EForwardBackward eForwardBackward)
Check whether the given enum instance is one of the valid values.

◆ operator KEY()

template<class T, typename KEY, KEY(T::*)() const METHOD, const std::string & NAME = DBPointer_defaultName>
operator KEY ( ) const
inline

Accessor for key value.

Definition at line 38 of file DBPointer.h.

38{return m_key;}

◆ operator*()

template<class T, typename KEY, KEY(T::*)() const METHOD, const std::string & NAME = DBPointer_defaultName>
const T & operator* ( ) const
inline

Imitate pointer functionality.

Definition at line 52 of file DBPointer.h.

◆ operator->()

template<class T, typename KEY, KEY(T::*)() const METHOD, const std::string & NAME = DBPointer_defaultName>
const T * operator-> ( ) const
inline

Imitate pointer functionality.

Definition at line 53 of file DBPointer.h.

◆ operator=()

template<class T, typename KEY, KEY(T::*)() const METHOD, const std::string & NAME = DBPointer_defaultName>
KEY operator= ( KEY key)
inline

Setter for key value.

Definition at line 41 of file DBPointer.h.

41{m_key = key; m_object = 0; return m_key;}

Member Data Documentation

◆ m_key

template<class T, typename KEY, KEY(T::*)() const METHOD, const std::string & NAME = DBPointer_defaultName>
KEY m_key
private

Key value of the referred array element.

Definition at line 67 of file DBPointer.h.

◆ m_object

template<class T, typename KEY, KEY(T::*)() const METHOD, const std::string & NAME = DBPointer_defaultName>
const T* m_object
mutableprivate

Pointer to actual object.

Definition at line 70 of file DBPointer.h.


The documentation for this class was generated from the following file: