11#include <framework/datastore/DataStore.h>
12#include <framework/datastore/StoreAccessorBase.h>
119 template<
class ...Args>
bool construct(Args&& ... params)
121 T* t =
new T(std::forward<Args>(params)...);
133 T* t =
new T(std::forward<Args>(params)...);
139#ifdef __clang_analyzer__
144 inline operator bool()
const {
return isValid();}
166 throw std::runtime_error(
"Trying to access StoreObjPtr " +
readableName() +
167 ", which was not created. Please check isValid() before accesses if the object is not guaranteed to be created in every event.");
In the store you can park objects that have to be accessed by various modules.
std::vector< std::string > getListOfObjects(const TClass *objClass, EDurability durability) const
Returns a list of names of StoreObjPtr-objects whose class is (or inherits from) objClass.
EDurability
Durability types.
@ c_Event
Different object in each event, all objects/arrays are invalidated after event() function has been ca...
static DataStore & Instance()
Instance of singleton Store.
TObject ** getObject(const StoreAccessorBase &accessor)
Get a pointer to a pointer of an object in the DataStore.
Base class for StoreObjPtr and StoreArray for easier common treatment.
std::string readableName() const
Convert this acessor into a readable string (for messages).
bool assign(TObject *object, bool replace=false)
Assign 'object' to this accessor.
Type-safe access to single objects in the data store.
T & operator*() const
Imitate pointer functionality.
void ensureAttached() const
Ensure that this object is attached.
bool isValid() const
Check whether the object was created.
bool constructAndReplace(Args &&... params)
Construct an object of type T in this StoreObjPtr, using the provided constructor arguments.
T * operator->() const
Imitate pointer functionality.
void ensureValid() const
if accesses to this object would crash, throw an std::runtime_error
StoreObjPtr(const std::string &name="", DataStore::EDurability durability=DataStore::c_Event)
Constructor to access an object in the DataStore.
TObject ** m_storeObjPtr
Store of actual pointer.
bool construct(Args &&... params)
Construct an object of type T in this StoreObjPtr, using the provided constructor arguments.
static std::vector< std::string > getObjectList(DataStore::EDurability durability=DataStore::c_Event)
Return list of object names with matching type.
Abstract base class for different kinds of events.