 |
Belle II Software
release-05-02-19
|
13 #include <framework/datastore/StoreAccessorBase.h>
14 #include <framework/datastore/DataStore.h>
16 #include <framework/utilities/ArrayIterator.h>
18 #include <TClonesArray.h>
27 namespace _StoreArrayImpl {
115 class StoreArray :
public StoreAccessorBase {
118 typedef ObjArrayIterator<TClonesArray, T>
iterator;
120 typedef ObjArrayIterator<const TClonesArray, const T>
const_iterator;
159 const std::string& namedRelation =
"")
const
176 const std::string& namedRelation =
"")
const
188 const std::string& namedRelation =
"")
const
199 template <
class FROM>
bool hasRelationFrom(
const StoreArray<FROM>& fromArray,
209 void clear()
override
212 (*m_storeArray)->Delete();
218 inline int getEntries()
const {
return isCreated() ? ((*m_storeArray)->GetEntriesFast()) : 0;}
234 TObject* obj = (*m_storeArray)->At(i);
236 throw std::out_of_range(
"Out-of-range access in StoreArray::operator[], for " + readableName() +
", index " + std::to_string(i));
237 return static_cast<T*
>(obj);
270 template<
class ...Args> T*
appendNew(Args&& ... params)
303 inline operator bool()
const {
return isValid(); }
313 TClonesArray*
getPtr()
const
340 return static_cast<T*
>((*m_storeArray)->AddrAt(
getEntries()));
358 throw std::runtime_error(
"Write access to " + readableName() +
" failed, did you remember to call registerInDataStore()?");
T * appendNew()
Construct a new T object at the end of the array.
void ensureAttached() const
Ensure that this object is attached.
bool registerRelation(const StoreAccessorBase &fromArray, const StoreAccessorBase &toArray, EDurability durability, EStoreFlags storeFlags, const std::string &namedRelation)
Register a relation in the DataStore map.
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.
StoreArray(const std::string &name="", DataStore::EDurability durability=DataStore::c_Event)
Constructor to access an array in the DataStore.
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.
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.
static DataStore & Instance()
Instance of singleton Store.
TClonesArray ** m_storeArray
Pointer that actually holds the TClonesArray.
EStoreFlags
Flags describing behaviours of objects etc.
static std::vector< std::string > getArrayList(DataStore::EDurability durability=DataStore::c_Event)
Return list of array names with matching type.
Base class for StoreObjPtr and StoreArray for easier common treatment.
TObject ** getObject(const StoreAccessorBase &accessor)
Get a pointer to a pointer of an object in the DataStore.
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.
void clearRelations(const StoreAccessorBase &array)
clear all relations touching the given array.
@ c_WriteOut
Object/array should be saved by output modules.
void ensureCreated() const
Ensure that the array has been created.
bool create(bool replace=false)
Create a default object in the data store.
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...
void clear() override
Delete all entries in this array.
Abstract base class for different kinds of events.
ObjArrayIterator< TClonesArray, T > iterator
STL-like iterator over the T objects (not T* ).
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.
T * operator[](int i) const
Access to the stored objects.
iterator begin()
Return iterator to first entry.
bool isValid() const
Check wether the array was registered.
iterator end()
Return iterator to last entry +1.
TClonesArray * getPtr() const
Raw access to the underlying TClonesArray.
ObjArrayIterator< const TClonesArray, const T > const_iterator
STL-like const_iterator over the T objects (not T* ).
T * nextFreeAdress()
Returns address of the next free position of the array.
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.
Accessor to arrays stored in the data store.
bool optionalRelation(const StoreAccessorBase &fromArray, const StoreAccessorBase &toArray, EDurability durability, std::string const &namedRelation)
Register the given relation as an optional input.
@ c_Event
Different object in each event, all objects/arrays are invalidated after event() function has been ca...
In the store you can park objects that have to be accessed by various modules.
bool create(bool replace=false)
Creating StoreArrays is unnecessary, only used internally.
int getEntries() const
Get the number of objects in the array.
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 isCreated() const
Check wether the array object was created.
EDurability
Durability types.