 |
Belle II Software
release-05-02-19
|
13 #include <framework/datastore/DataStore.h>
14 #include <framework/datastore/StoreAccessorBase.h>
97 template <
class T>
class StoreObjPtr :
public StoreAccessorBase {
106 StoreAccessorBase(DataStore::objectName<T>(name), durability, T::Class(), false),
m_storeObjPtr(0) {}
120 template<
class ...Args>
bool construct(Args&& ... params)
122 T* t =
new T(std::forward<Args>(params)...);
123 return assign(t,
false);
134 T* t =
new T(std::forward<Args>(params)...);
135 return assign(t,
true);
139 inline T&
operator *()
const {
return *operator->();}
140 inline T* operator ->()
const {
ensureValid();
return static_cast<T*
>(*m_storeObjPtr);}
141 inline operator bool()
const {
return isValid();}
163 throw std::runtime_error(
"Trying to access StoreObjPtr " + readableName() +
164 ", which was not created. Please check isValid() before accesses if the object is not guaranteed to be created in every event.");
static std::vector< std::string > getObjectList(DataStore::EDurability durability=DataStore::c_Event)
Return list of object names with matching type.
static DataStore & Instance()
Instance of singleton Store.
bool constructAndReplace(Args &&... params)
Construct an object of type T in this StoreObjPtr, using the provided constructor arguments.
TObject ** getObject(const StoreAccessorBase &accessor)
Get a pointer to a pointer of an object in the DataStore.
B2Vector3< DataType > operator*(DataType a, const B2Vector3< DataType > &p)
non-memberfunction Scaling of 3-vectors with a real number
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.
StoreObjPtr(const std::string &name="", DataStore::EDurability durability=DataStore::c_Event)
Constructor to access an object in the DataStore.
bool construct(Args &&... params)
Construct an object of type T in this StoreObjPtr, using the provided constructor arguments.
Abstract base class for different kinds of events.
Type-safe access to single objects in the data store.
void ensureValid() const
if accesses to this object would crash, throw an std::runtime_error
TObject ** m_storeObjPtr
Store of actual pointer.
void ensureAttached() const
Ensure that this object is attached.
@ c_Event
Different object in each event, all objects/arrays are invalidated after event() function has been ca...
EDurability
Durability types.
bool isValid() const
Check whether the object was created.