8#include <framework/pybasf2/PyStoreObj.h>
10#include <framework/datastore/DataStore.h>
11#include <framework/datastore/StoreAccessorBase.h>
12#include <framework/logging/Logger.h>
22 T* replaceNullPtr(T* value, T* fallback)
24 return value ? value : fallback;
35 for (
const auto& n :
list(durability))
57 const std::string& name,
59 m_storeAccessor(name, durability, objClass, false)
73 B2ERROR(
"Cannot register PyStoreObj '" << name <<
"' with unknown TClass. Please supply one to the PyStoreObj constructor.");
100 return objClass and objClass != TObject::Class();
108 B2ERROR(
"Cannot create unregistered PyStoreObj.");
113 if (
isValid() and not replace)
return true;
116 B2ERROR(
"Cannot create PyStoreObj with unknown TClass.");
In the store you can park objects that have to be accessed by various modules.
EStoreFlags
Flags describing behaviours of objects etc.
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.
static DataStore & Instance()
Instance of singleton Store.
StoreEntry * getEntry(const StoreAccessorBase &accessor)
Check whether an entry with the correct type is registered in the DataStore map and return it.
a (simplified) python wrapper for StoreObjPtr.
StoreAccessorBase m_storeAccessor
Store accessor to retrieve the object.
static void printList(DataStore::EDurability durability=DataStore::EDurability::c_Event)
Print list of available objects for given durability.
PyStoreObj(const std::string &name, DataStore::EDurability durability=DataStore::EDurability::c_Event)
constructor.
void ensureAttached() const
Ensure that contained TObject has been attached to a memory location on the DataStore.
bool hasValidClass() const
Check whether a TClass for the contained object could be determined.
bool isValid() const
Check whether the object was registered and created.
bool isRequired(const std::string &name="")
Ensure this object has been registered previously.
bool isOptional(const std::string &name="")
Tell the DataStore about an optional input.
bool registerInDataStore(DataStore::EStoreFlags storeFlags)
Register the object in the DataStore.
bool assign(TObject *object, bool replace=false)
Assign 'object' to the accessor.
StoreEntry * m_storeEntry
Pointer to the DataStore entry - serves as an internal cache omitting repeated look up from the DataS...
static std::vector< std::string > list(DataStore::EDurability durability=DataStore::EDurability::c_Event)
Return list of available objects for given durability.
void attach() const
Lookup the store entry and cache a pointer to it.
bool create(bool replace=false)
Create default constructed object in the DataStore.
const std::string & getName() const
Return name under which the object is saved in the DataStore.
bool isRequired(const std::string &name="")
Ensure this array/object has been registered previously.
bool isOptional(const std::string &name="")
Tell the DataStore about an optional input.
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.
TClass * getClass() const
The underlying object's type.
bool registerInDataStore(DataStore::EStoreFlags storeFlags=DataStore::c_WriteOut)
Register the object/array in the DataStore.
bool create(bool replace=false)
Create a default object in the data store.
Abstract base class for different kinds of events.
TObject * ptr
The pointer to the returned object, either equal to 'object' or null, depending on wether the object ...