11 #include <framework/datastore/StoreAccessorBase.h>
12 #include <framework/datastore/DataStore.h>
14 #include <framework/utilities/ArrayIterator.h>
16 #include <TClonesArray.h>
25 namespace _StoreArrayImpl {
157 const std::string& namedRelation =
"")
const
174 const std::string& namedRelation =
"")
const
186 const std::string& namedRelation =
"")
const
210 (*m_storeArray)->Delete();
232 TObject* obj = (*m_storeArray)->At(i);
234 throw std::out_of_range(
"Out-of-range access in StoreArray::operator[], for " +
readableName() +
", index " + std::to_string(i));
235 return static_cast<T*
>(obj);
301 inline operator bool()
const {
return isValid(); }
338 return static_cast<T*
>((*m_storeArray)->AddrAt(
getEntries()));
356 throw std::runtime_error(
"Write access to " +
readableName() +
" failed, did you remember to call registerInDataStore()?");
In the store you can park objects that have to be accessed by various modules.
bool optionalRelation(const StoreAccessorBase &fromArray, const StoreAccessorBase &toArray, EDurability durability, std::string const &namedRelation)
Register the given relation as an optional input.
EStoreFlags
Flags describing behaviours of objects etc.
@ c_WriteOut
Object/array should be saved by output modules.
bool registerRelation(const StoreAccessorBase &fromArray, const StoreAccessorBase &toArray, EDurability durability, EStoreFlags storeFlags, const std::string &namedRelation)
Register a relation in the DataStore map.
std::vector< std::string > getListOfArrays(const TClass *arrayClass, EDurability durability) const
Returns a list of names of arrays which are of type (or inherit from) arrayClass.
EDurability
Durability types.
@ c_Event
Different object in each event, all objects/arrays are invalidated after event() function has been ca...
bool requireRelation(const StoreAccessorBase &fromArray, const StoreAccessorBase &toArray, EDurability durability, std::string const &namedRelation)
Produce ERROR message if no relation of given durability exists between fromArray and toArray (in tha...
static DataStore & Instance()
Instance of singleton Store.
bool hasRelation(const StoreAccessorBase &fromArray, const StoreAccessorBase &toArray, EDurability durability, const std::string &namedRelation)
Check for the existence of a relation in the DataStore map.
TObject ** getObject(const StoreAccessorBase &accessor)
Get a pointer to a pointer of an object in the DataStore.
Optimizes class to iterate over TObjArray and classes inheriting from it.
Base class for StoreObjPtr and StoreArray for easier common treatment.
std::string readableName() const
Convert this acessor into a readable string (for messages).
bool create(bool replace=false)
Create a default object in the data store.
Accessor to arrays stored in the data store.
bool requireRelationTo(const StoreArray< TO > &toArray, DataStore::EDurability durability=DataStore::c_Event, const std::string &namedRelation="") const
Produce error if no relation from this array to 'toArray' has been registered.
const_iterator begin() const
Return const_iterator to first entry.
T * appendNew(Args &&... params)
Construct a new T object directly at the end of the array.
void ensureAttached() const
Ensure that this object is attached.
T * appendNew()
Construct a new T object at the end of the array.
bool hasRelationFrom(const StoreArray< FROM > &fromArray, DataStore::EDurability durability=DataStore::c_Event, const std::string &namedRelation="") const
Check for the existence of a relation from the given StoreArray.
bool isValid() const
Check wether the array was registered.
static std::vector< std::string > getArrayList(DataStore::EDurability durability=DataStore::c_Event)
Return list of array names with matching type.
TClonesArray ** m_storeArray
Pointer that actually holds the TClonesArray.
T * operator[](int i) const
Access to the stored objects.
ObjArrayIterator< TClonesArray, T > iterator
STL-like iterator over the T objects (not T* ).
int getEntries() const
Get the number of objects in the array.
iterator end()
Return iterator to last entry +1.
const_iterator end() const
Return const_iterator to last entry +1.
bool hasRelationTo(const StoreArray< TO > &toArray, DataStore::EDurability durability=DataStore::c_Event, const std::string &namedRelation="") const
Check for the existence of a relation to the given StoreArray.
bool create(bool replace=false)
Creating StoreArrays is unnecessary, only used internally.
StoreArray(const std::string &name="", DataStore::EDurability durability=DataStore::c_Event)
Constructor to access an array in the DataStore.
iterator begin()
Return iterator to first entry.
void ensureCreated() const
Ensure that the array has been created.
TClonesArray * getPtr() const
Raw access to the underlying TClonesArray.
void clear() override
Delete all entries in this array.
T * nextFreeAdress()
Returns address of the next free position of the array.
ObjArrayIterator< const TClonesArray, const T > const_iterator
STL-like const_iterator over the T objects (not T* ).
bool optionalRelationTo(const StoreArray< TO > &toArray, DataStore::EDurability durability=DataStore::c_Event, const std::string &namedRelation="") const
Tell the data store about a relation that we could make use of.
bool isCreated() const
Check wether the array object was created.
bool registerRelationTo(const StoreArray< TO > &toArray, DataStore::EDurability durability=DataStore::c_Event, DataStore::EStoreFlags storeFlags=DataStore::c_WriteOut, const std::string &namedRelation="") const
Register a relation to the given StoreArray.
void clearRelations(const StoreAccessorBase &array)
clear all relations touching the given array.
Abstract base class for different kinds of events.