Belle II Software  release-05-02-19
StoreWrappedObjPtr< T > Class Template Reference

This class is for convenience access and registration of objects, that are stored inside the StoreWrapper on the DataStore. More...

#include <StoreWrappedObjPtr.h>

Inheritance diagram for StoreWrappedObjPtr< T >:
Collaboration diagram for StoreWrappedObjPtr< T >:

Public Member Functions

 StoreWrappedObjPtr (const std::string &name="", DataStore::EDurability durability=DataStore::c_Event)
 Constructor to access an object in the DataStore. More...
 
bool registerInDataStore (DataStore::EStoreFlags storeFlags=DataStore::c_DontWriteOut|DataStore::c_ErrorIfAlreadyRegistered)
 Register the object/array in the DataStore. More...
 
bool registerInDataStore (const std::string &name, DataStore::EStoreFlags storeFlags=DataStore::c_DontWriteOut|DataStore::c_ErrorIfAlreadyRegistered)
 Register the object/array in the DataStore. More...
 
T & operator* () const
 Dereference to the wrapped object.
 
T * operator-> () const
 Forward pointer access to the wrapped object.
 
bool isValid () const
 Check whether the object was created. More...
 
bool construct (Args &&... params)
 Construct an object of type T in this StoreObjPtr, using the provided constructor arguments. More...
 
bool constructAndReplace (Args &&... params)
 Construct an object of type T in this StoreObjPtr, using the provided constructor arguments. More...
 

Static Public Member Functions

static std::vector< std::string > getObjectList (DataStore::EDurability durability=DataStore::c_Event)
 Return list of object names with matching type. More...
 

Private Member Functions

void ensureAttached () const
 Ensure that this object is attached.
 
void ensureValid () const
 if accesses to this object would crash, throw an std::runtime_error
 

Private Attributes

TObject ** m_storeObjPtr
 Store of actual pointer. More...
 

Detailed Description

template<class T>
class Belle2::TrackFindingCDC::StoreWrappedObjPtr< T >

This class is for convenience access and registration of objects, that are stored inside the StoreWrapper on the DataStore.

It limits the user to registrations of transient store objects only, since objects wrapped by the StoreWrapper are usually not intended for streaming.

Definition at line 40 of file StoreWrappedObjPtr.h.

Constructor & Destructor Documentation

◆ StoreWrappedObjPtr()

StoreWrappedObjPtr ( const std::string &  name = "",
DataStore::EDurability  durability = DataStore::c_Event 
)
inline

Constructor to access an object in the DataStore.

Parameters
nameName under which the object is stored in the DataStore. If an empty string is supplied, the type name will be used.
durabilityDecides durability map used for getting the accessed object.

Definition at line 49 of file StoreWrappedObjPtr.h.

Member Function Documentation

◆ construct()

bool construct ( Args &&...  params)
inlineinherited

Construct an object of type T in this StoreObjPtr, using the provided constructor arguments.

If this StoreObjPtr already contains an object, this function will fail.

Returns
True if the creation succeeded.

Definition at line 128 of file StoreObjPtr.h.

◆ constructAndReplace()

bool constructAndReplace ( Args &&...  params)
inlineinherited

Construct an object of type T in this StoreObjPtr, using the provided constructor arguments.

If this StoreObjPtr already contains an object, it will be replaced.

Returns
True if the creation succeeded.

Definition at line 140 of file StoreObjPtr.h.

◆ getObjectList()

static std::vector<std::string> getObjectList ( DataStore::EDurability  durability = DataStore::c_Event)
inlinestaticinherited

Return list of object names with matching type.


Definition at line 153 of file StoreObjPtr.h.

◆ isValid()

bool isValid
inlineinherited

Check whether the object was created.

Returns
True if the object exists.

Definition at line 120 of file StoreObjPtr.h.

◆ registerInDataStore() [1/2]

bool registerInDataStore ( const std::string &  name,
DataStore::EStoreFlags  storeFlags = DataStore::c_DontWriteOut | DataStore::c_ErrorIfAlreadyRegistered 
)
inline

Register the object/array in the DataStore.

This must be called in the initialization phase.

Parameters
nameIf not empty, set non-default name for this object/array. This is permanent, so that e.g. after using registerInDataStore("myName") in initialize(), this object will continue refer to 'myName' in event().
storeFlagsORed combination of DataStore::EStoreFlag flags. Defaults to c_DontWriteOut | DataStore::c_ErrorIfAlreadyRegistered.
Returns
True if the registration succeeded.

Definition at line 72 of file StoreWrappedObjPtr.h.

◆ registerInDataStore() [2/2]

bool registerInDataStore ( DataStore::EStoreFlags  storeFlags = DataStore::c_DontWriteOut | DataStore::c_ErrorIfAlreadyRegistered)
inline

Register the object/array in the DataStore.

This must be called in the initialization phase.

Parameters
storeFlagsORed combination of DataStore::EStoreFlag flags. Defaults to c_DontWriteOut | c_ErrorIfAlreadyRegistered.
Returns
True if the registration succeeded.

Definition at line 60 of file StoreWrappedObjPtr.h.

Member Data Documentation

◆ m_storeObjPtr

TObject** m_storeObjPtr
privateinherited

Store of actual pointer.

Don't make this a T** as this might cause problems with multiple inheritance objects

Definition at line 175 of file StoreObjPtr.h.


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