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