Belle II Software development
GlobalParamSetAccess Class Referenceabstract

Base accessor class to store different DBObjects e.g. More...

#include <GlobalParam.h>

Inheritance diagram for GlobalParamSetAccess:
GlobalParamSet< Belle2::alignment::EmptyGlobalParamSet > GlobalParamSet< DBObjType >

Public Member Functions

 GlobalParamSetAccess ()
 Constructor.
 
virtual ~GlobalParamSetAccess ()
 Virtual destructor (base class, but with no members)
 
virtual unsigned short getGlobalUniqueID () const =0
 implement: Get the global unique id of DBObject
 
virtual double getGlobalParam (unsigned short, unsigned short)=0
 implement: get a global parameter value based on the element number in the DBObject and its parameter number.
 
virtual void setGlobalParam (double, unsigned short, unsigned short)=0
 implemtn: set a global param value by element and param number
 
virtual std::vector< std::pair< unsigned short, unsigned short > > listGlobalParams ()=0
 implement: generate list of all global parameters in the DBObject
 
virtual void updateGlobalParam (double correction, unsigned short element, unsigned short param)
 Sum value of global element param with a correction.
 
virtual TObject * getDBObj ()=0
 Get a raw pointer to the internal DB object (can be nullptr if not yet constructed) Use with caution - always check for nullptr.
 
virtual std::string getDefaultName () const =0
 Get the default DBObject name used by datastore.
 
virtual TObject * releaseObject ()=0
 Release the object from internal unique_ptr to be managed elsewhere Useful to pass it to be stored in DB (and thus later deleted by framework)
 
virtual GlobalParamSetAccessclone ()=0
 Clone the object, making a copy of the internal object - has to be implemented in derived template class to return the actuall type of the object.
 
virtual void loadFromDB (EventMetaData emd)=0
 Load the content (by copying obj retrieved from DB) for a given exp/run/event.
 
virtual void loadFromDBObjPtr ()=0
 Load using DBObjPtr<DBObjType> which uses current EventMetaData to load valid constants.
 
virtual void construct ()=0
 Construct the internal DBObject.
 
virtual bool isConstructed () const =0
 Has the internal DBObject been already constructed The object is constructed at latest on first access to its parameters.
 
virtual bool hasBeenChangedInDB (bool resetChangedState=true) final
 Has the object been updated in DB since GlobalParamSet<...> has been constructed? Since last call to this function with resetChangedState=true.
 
virtual void callbackDB ()
 Function to call when object has been changed in DB since last loaded.
 
template<class DBObjType >
bool is () const
 Is this set of given type?
 
bool empty ()
 Is this set empty or otherwise 'invalid' to identify null sets, end of hierarchy.
 
 operator bool ()
 Tentative operator to quickly check the set Returns true when the set is not empty() and the DB object is constructed and can be accessed.
 

Protected Attributes

bool m_hasBeenChangedInDB {false}
 Flag for object changed in DB.
 

Detailed Description

Base accessor class to store different DBObjects e.g.

in a vector but allow to access their stored global parameters

Definition at line 95 of file GlobalParam.h.

Constructor & Destructor Documentation

◆ GlobalParamSetAccess()

Constructor.

Definition at line 98 of file GlobalParam.h.

98{}

◆ ~GlobalParamSetAccess()

virtual ~GlobalParamSetAccess ( )
inlinevirtual

Virtual destructor (base class, but with no members)

Definition at line 100 of file GlobalParam.h.

100{}

Member Function Documentation

◆ callbackDB()

virtual void callbackDB ( )
inlinevirtual

Function to call when object has been changed in DB since last loaded.

Reimplemented in GlobalParamSet< DBObjType >, and GlobalParamSet< Belle2::alignment::EmptyGlobalParamSet >.

Definition at line 139 of file GlobalParam.h.

139{m_hasBeenChangedInDB = true;}
bool m_hasBeenChangedInDB
Flag for object changed in DB.
Definition: GlobalParam.h:174

◆ clone()

virtual GlobalParamSetAccess * clone ( )
pure virtual

Clone the object, making a copy of the internal object - has to be implemented in derived template class to return the actuall type of the object.

Implemented in GlobalParamSet< DBObjType >, and GlobalParamSet< Belle2::alignment::EmptyGlobalParamSet >.

◆ construct()

virtual void construct ( )
pure virtual

◆ empty()

bool empty ( )
inline

Is this set empty or otherwise 'invalid' to identify null sets, end of hierarchy.

Definition at line 148 of file GlobalParam.h.

149 {
150 // We consider this to be the definition of empty
151 if (is<EmptyGlobalParamSet>())
152 return true;
153 // This is by convention (also used in hierarchy)
154 if (getGlobalUniqueID() == 0)
155 return true;
156 // This actually constructs the object using Default constructor if not
157 // previously loaded from DB (or using construct)
158 // TODO this is still not fully impelemnted by DB objects
159 if (listGlobalParams().empty())
160 return true;
161 return false;
162 }
bool empty()
Is this set empty or otherwise 'invalid' to identify null sets, end of hierarchy.
Definition: GlobalParam.h:148
virtual std::vector< std::pair< unsigned short, unsigned short > > listGlobalParams()=0
implement: generate list of all global parameters in the DBObject
virtual unsigned short getGlobalUniqueID() const =0
implement: Get the global unique id of DBObject

◆ getDBObj()

virtual TObject * getDBObj ( )
pure virtual

Get a raw pointer to the internal DB object (can be nullptr if not yet constructed) Use with caution - always check for nullptr.

Implemented in GlobalParamSet< DBObjType >, and GlobalParamSet< Belle2::alignment::EmptyGlobalParamSet >.

◆ getDefaultName()

virtual std::string getDefaultName ( ) const
pure virtual

Get the default DBObject name used by datastore.

Implemented in GlobalParamSet< DBObjType >, and GlobalParamSet< Belle2::alignment::EmptyGlobalParamSet >.

◆ getGlobalParam()

virtual double getGlobalParam ( unsigned short  ,
unsigned short   
)
pure virtual

implement: get a global parameter value based on the element number in the DBObject and its parameter number.

Might be that element/param is zero. Check the meaning in DB object

Implemented in GlobalParamSet< DBObjType >, GlobalParamSet< Belle2::alignment::EmptyGlobalParamSet >, GlobalParamSet< DBObjType >, GlobalParamSet< Belle2::alignment::EmptyGlobalParamSet >, GlobalParamSet< DBObjType >, and GlobalParamSet< Belle2::alignment::EmptyGlobalParamSet >.

◆ getGlobalUniqueID()

◆ hasBeenChangedInDB()

virtual bool hasBeenChangedInDB ( bool  resetChangedState = true)
inlinefinalvirtual

Has the object been updated in DB since GlobalParamSet<...> has been constructed? Since last call to this function with resetChangedState=true.

Definition at line 137 of file GlobalParam.h.

137{auto tmp = m_hasBeenChangedInDB; if (resetChangedState) m_hasBeenChangedInDB = false; return tmp;}

◆ is()

bool is ( ) const
inline

Is this set of given type?

Returns
true if stored set is of given type

Definition at line 144 of file GlobalParam.h.

144{return DBObjType::getGlobalUniqueID() == getGlobalUniqueID();}

◆ isConstructed()

virtual bool isConstructed ( ) const
pure virtual

Has the internal DBObject been already constructed The object is constructed at latest on first access to its parameters.

Implemented in GlobalParamSet< DBObjType >, and GlobalParamSet< Belle2::alignment::EmptyGlobalParamSet >.

◆ listGlobalParams()

virtual std::vector< std::pair< unsigned short, unsigned short > > listGlobalParams ( )
pure virtual

◆ loadFromDB()

virtual void loadFromDB ( EventMetaData  emd)
pure virtual

Load the content (by copying obj retrieved from DB) for a given exp/run/event.

Implemented in GlobalParamSet< DBObjType >, and GlobalParamSet< Belle2::alignment::EmptyGlobalParamSet >.

◆ loadFromDBObjPtr()

virtual void loadFromDBObjPtr ( )
pure virtual

Load using DBObjPtr<DBObjType> which uses current EventMetaData to load valid constants.

Implemented in GlobalParamSet< DBObjType >, and GlobalParamSet< Belle2::alignment::EmptyGlobalParamSet >.

◆ operator bool()

operator bool ( )
inline

Tentative operator to quickly check the set Returns true when the set is not empty() and the DB object is constructed and can be accessed.

Definition at line 167 of file GlobalParam.h.

168 {
169 return not empty() and isConstructed();
170 }
virtual bool isConstructed() const =0
Has the internal DBObject been already constructed The object is constructed at latest on first acces...

◆ releaseObject()

virtual TObject * releaseObject ( )
pure virtual

Release the object from internal unique_ptr to be managed elsewhere Useful to pass it to be stored in DB (and thus later deleted by framework)

Implemented in GlobalParamSet< DBObjType >, and GlobalParamSet< Belle2::alignment::EmptyGlobalParamSet >.

◆ setGlobalParam()

virtual void setGlobalParam ( double  ,
unsigned short  ,
unsigned short   
)
pure virtual

◆ updateGlobalParam()

virtual void updateGlobalParam ( double  correction,
unsigned short  element,
unsigned short  param 
)
inlinevirtual

Sum value of global element param with a correction.

Definition at line 112 of file GlobalParam.h.

112{setGlobalParam(getGlobalParam(element, param) + correction, element, param);}
virtual void setGlobalParam(double, unsigned short, unsigned short)=0
implemtn: set a global param value by element and param number
virtual double getGlobalParam(unsigned short, unsigned short)=0
implement: get a global parameter value based on the element number in the DBObject and its parameter...

Member Data Documentation

◆ m_hasBeenChangedInDB

bool m_hasBeenChangedInDB {false}
protected

Flag for object changed in DB.

Definition at line 174 of file GlobalParam.h.


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