Belle II Software light-2406-ragdoll
StoreArray< T > Class Template Reference

Accessor to arrays stored in the data store. More...

#include <StoreArray.h>

Inheritance diagram for StoreArray< T >:
Collaboration diagram for StoreArray< T >:

Public Types

typedef ObjArrayIterator< TClonesArray, T > iterator
 STL-like iterator over the T objects (not T* ).
 
typedef ObjArrayIterator< const TClonesArray, const T > const_iterator
 STL-like const_iterator over the T objects (not T* ).
 

Public Member Functions

 StoreArray (const std::string &name="", DataStore::EDurability durability=DataStore::c_Event)
 Constructor to access an array in the DataStore.
 
template<class TO >
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.
 
template<class TO >
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.
 
template<class TO >
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.
 
template<class TO >
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.
 
template<class FROM >
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.
 
void clear () override
 Delete all entries in this array.
 
int getEntries () const
 Get the number of objects in the array.
 
T * operator[] (int i) const
 Access to the stored objects.
 
T * appendNew ()
 Construct a new T object at the end of the array.
 
template<class ... Args>
T * appendNew (Args &&... params)
 Construct a new T object directly at the end of the array.
 
bool isValid () const
 Check wether the array was registered.
 
 operator bool () const
 Check wether the array was registered.
 
TClonesArray * getPtr () const
 Raw access to the underlying TClonesArray.
 
iterator begin ()
 Return iterator to first entry.
 
iterator end ()
 Return iterator to last entry +1.
 
const_iterator begin () const
 Return const_iterator to first entry.
 
const_iterator end () const
 Return const_iterator to last entry +1.
 
bool registerInDataStore (DataStore::EStoreFlags storeFlags=DataStore::c_WriteOut)
 Register the object/array in the DataStore.
 
bool registerInDataStore (const std::string &name, DataStore::EStoreFlags storeFlags=DataStore::c_WriteOut)
 Register the object/array 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.
 
bool assign (TObject *object, bool replace=false)
 Assign 'object' to this accessor.
 
const std::string & getName () const
 Return name under which the object is saved in the DataStore.
 
DataStore::EDurability getDurability () const
 Return durability with which the object is saved in the DataStore.
 
AccessorParams getAccessorParams () const
 Return pair of name and durability under which stored object is saved.
 
virtual bool operator== (const StoreAccessorBase &other) const
 Check if two store accessors point to the same object/array.
 
virtual bool operator!= (const StoreAccessorBase &other) const
 Check if two store accessors point to a different object/array.
 
TClass * getClass () const
 The underlying object's type.
 
bool isArray () const
 Is this an accessor for an array?
 
bool notWrittenOut () const
 Returns true if this object/array should not be saved by output modules.
 
std::string readableName () const
 Convert this acessor into a readable string (for messages).
 

Static Public Member Functions

static std::vector< std::string > getArrayList (DataStore::EDurability durability=DataStore::c_Event)
 Return list of array names with matching type.
 

Protected Attributes

std::string m_name
 Store name under which this object/array is saved.
 
DataStore::EDurability m_durability
 Store durability under which the object/array is saved.
 
TClass * m_class
 The underlying object's type.
 
bool m_isArray
 Is this an accessor for an array?
 

Private Member Functions

bool create (bool replace=false)
 Creating StoreArrays is unnecessary, only used internally.
 
T * nextFreeAdress ()
 Returns address of the next free position of the array.
 
void ensureAttached () const
 Ensure that this object is attached.
 
void ensureCreated () const
 Ensure that the array has been created.
 
bool isCreated () const
 Check wether the array object was created.
 

Private Attributes

TClonesArray ** m_storeArray
 Pointer that actually holds the TClonesArray.
 

Detailed Description

template<class T>
class Belle2::StoreArray< T >

Accessor to arrays stored in the data store.

StoreArrays (like StoreObjPtrs) are uniquely identified by their name and durability. In most cases, arrays are created with durability DataStore::c_Event and the default name corresponding to their type. (i.e. typename + 's') Thus, calling the constructor StoreArray<MyType>() will connect this StoreArray with the array called 'MyTypes' in the data store, with a lifetime of one event.

Accessing elements of an existing array

Stored objects can be accessed directly using their array index and operator[]. For example, the following code snippet loops over all entries in an array of CDCSimHits:

//loop over all CDC simhits
for(int iCDC = 0; iCDC < cdcsimhits.getEntries(); iCDC++) {
const CDCSimHit* hit = cdcsimhits[iCDC]; //get iCDC'th entry in StoreArray
// Use hit's data here...
}
//or using range-based for:
for(const CDCSimHit& hit : cdcsimhits) {
// Use hit's data here...
}
Accessor to arrays stored in the data store.
Definition: StoreArray.h:113
int getEntries() const
Get the number of objects in the array.
Definition: StoreArray.h:216
Note
Remember to use references or pointers when iterating, otherwise accessing, e.g., relations will not work.

Objects linked together using relations can also be obtained by querying the objects themselves, since they should derive from RelationsObject (See class documentation for usage examples.)

Adding elements

Elements can be added to the array in a few ways. The easiest is to use something like:

//...
CDCSimHit* newhit = cdcsimhits.appendNew();
//fill newhit with data here...
T * appendNew()
Construct a new T object at the end of the array.
Definition: StoreArray.h:246

appendNew() can also use non-default constructors, e.g. if there is a constructor that takes the arguments (int, float), you can use appendNew(int, float) instead.

Registration of arrays

Note that you have to register an array in the initialize method of a module first (using registerInDataStore()) before you can use it. This procedure is the same as for objects handled by StoreObjPtr.

Using StoreArray as a module member variable

To avoid some overhead involved in re-creating the StoreArray e.g. in each event() function call, you can also make StoreArray a member variable of your class. If it is of non-event durability, you'll need to add the appropriate constructor call to the initializer list, e.g. (here with default name):

MyModule::MyModule():
m_fooHits("", DataStore::c_Persistent)
{}
In the store you can park objects that have to be accessed by various modules.
Definition: DataStore.h:51

In initialize(), you should also use registerInDataStore() or isOptional()/isRequired() to specify wether it is an input or output. For non-default names (which you might not know in the constructor, e.g. in the case of module parameters), set the 'name' argument of any of these three functions to permanently bind the StoreArray to the array with the given name.

See also
Objects in different arrays can be linked using relations, see RelationsInterface, RelationsObject
See StoreObjPtr for a way store single objects
Data can also be accessed from Python modules using PyStoreArray
While individual elements cannot be removed directly from StoreArray, SelectSubset can be used to filter it.

Definition at line 113 of file StoreArray.h.

Member Typedef Documentation

◆ const_iterator

typedef ObjArrayIterator<const TClonesArray, const T> const_iterator

STL-like const_iterator over the T objects (not T* ).

Definition at line 118 of file StoreArray.h.

◆ iterator

typedef ObjArrayIterator<TClonesArray, T> iterator

STL-like iterator over the T objects (not T* ).

Definition at line 116 of file StoreArray.h.

Constructor & Destructor Documentation

◆ StoreArray()

StoreArray ( const std::string &  name = "",
DataStore::EDurability  durability = DataStore::c_Event 
)
inlineexplicit

Constructor to access an array in the DataStore.

Parameters
nameName under which the array is stored in the DataStore. If an empty string is supplied, the type name will be used.
durabilityDecides durability map used for getting the accessed array.

Definition at line 126 of file StoreArray.h.

126 :
127 StoreAccessorBase(DataStore::arrayName<T>(name), durability, T::Class(), true), m_storeArray(0) {}
StoreAccessorBase(const std::string &name, DataStore::EDurability durability, TClass *objClass, bool isArray)
Constructor to access an object or array in the DataStore.
TClonesArray ** m_storeArray
Pointer that actually holds the TClonesArray.
Definition: StoreArray.h:368

Member Function Documentation

◆ appendNew() [1/2]

T * appendNew ( )
inline

Construct a new T object at the end of the array.

Appends a new object to the array, and returns a pointer so it can be filled with data. The default constructor is used for the object's creation.

Returns
pointer to the created object

Definition at line 246 of file StoreArray.h.

246{ return new (nextFreeAdress()) T(); }
T * nextFreeAdress()
Returns address of the next free position of the array.
Definition: StoreArray.h:335

◆ appendNew() [2/2]

T * appendNew ( Args &&...  params)
inline

Construct a new T object directly at the end of the array.

This is done by forwarding all arguments to the constructor of the type T. If there is a constructor which takes the given combination of arguments then this call will succeed, otherwise it fails on compilation.

This method imposes no overhead as no temporary has to be constructed and should be the preferred solution for creating new objects.

It handles just like the (C++11) standard library's emplace..() functions:

myStoreArray.appendNew(some ctor arguments);
Note
since all arguments are passed to the constructor of class T, doing something like appendNew(T(ctor arguments)) is unnecessary. This would construct a temporary object of class T, then copy-construct another T object in the array and destroy the temporary object again.
Returns
pointer to the created object

Definition at line 268 of file StoreArray.h.

269 {
270 return new (nextFreeAdress()) T(std::forward<Args>(params)...);
271 }

◆ assign()

bool assign ( TObject *  object,
bool  replace = false 
)
inherited

Assign 'object' to this accessor.

(takes ownership).

Parameters
objectThe object that should be put in the DataStore, should be of same type as the one used by this accessor.
replaceShould an existing object be replaced? (if existing and supplied object are equal, this has no effect)
Returns
True if the assignment succeeded. If false, assign() will delete 'object', do not use it afterwards.

Definition at line 33 of file StoreAccessorBase.cc.

34{
35 if (not object)
36 return false;
37
38 bool success = false;
39 const bool objIsArray = (object->IsA() == TClonesArray::Class());
40 TClass* objClass = objIsArray ? (static_cast<TClonesArray*>(object))->GetClass() : object->IsA();
41 if (objIsArray != isArray()) {
42 B2ERROR("Cannot assign an object to an array (or vice versa); while assigning to " << readableName());
43 } else if (objClass != getClass()) {
44 B2ERROR("Cannot assign() an object of type '" << objClass->GetName() << "' to " << readableName() << " of type '" <<
45 getClass()->GetName() << "'!");
46 } else {
47 success = DataStore::Instance().createObject(object, replace, *this);
48 }
49 if (!success)
50 delete object;
51 return success;
52}
static DataStore & Instance()
Instance of singleton Store.
Definition: DataStore.cc:54
bool createObject(TObject *object, bool replace, const StoreAccessorBase &accessor)
Create a new object/array in the DataStore or add an existing one.
Definition: DataStore.cc:316
std::string readableName() const
Convert this acessor into a readable string (for messages).
TClass * getClass() const
The underlying object's type.
bool isArray() const
Is this an accessor for an array?

◆ begin() [1/2]

iterator begin ( )
inline

Return iterator to first entry.

Definition at line 318 of file StoreArray.h.

void ensureAttached() const
Ensure that this object is attached.
Definition: StoreArray.h:342
ObjArrayIterator< TClonesArray, T > iterator
STL-like iterator over the T objects (not T* ).
Definition: StoreArray.h:116

◆ begin() [2/2]

const_iterator begin ( ) const
inline

Return const_iterator to first entry.

Definition at line 323 of file StoreArray.h.

ObjArrayIterator< const TClonesArray, const T > const_iterator
STL-like const_iterator over the T objects (not T* ).
Definition: StoreArray.h:118

◆ clear()

void clear ( )
inlineoverridevirtual

Delete all entries in this array.

Any relations to objects in this array are also removed.

Reimplemented from StoreAccessorBase.

Definition at line 207 of file StoreArray.h.

208 {
209 if (getEntries() != 0) {
210 (*m_storeArray)->Delete();
212 }
213 }
void clearRelations(const StoreAccessorBase &array)
clear all relations touching the given array.
Definition: StoreArray.cc:16

◆ create()

bool create ( bool  replace = false)
inlineprivate

Creating StoreArrays is unnecessary, only used internally.

Definition at line 329 of file StoreArray.h.

329{ return StoreAccessorBase::create(replace); }
bool create(bool replace=false)
Create a default object in the data store.

◆ end() [1/2]

iterator end ( )
inline

Return iterator to last entry +1.

Definition at line 320 of file StoreArray.h.

320{ ensureAttached(); return iterator(m_storeArray, true); }

◆ end() [2/2]

const_iterator end ( ) const
inline

Return const_iterator to last entry +1.

Definition at line 325 of file StoreArray.h.

325{ ensureAttached(); return const_iterator(m_storeArray, true); }

◆ ensureAttached()

void ensureAttached ( ) const
inlineprivate

Ensure that this object is attached.

Definition at line 342 of file StoreArray.h.

343 {
344 if (!m_storeArray) {
345 const_cast<StoreArray*>(this)->m_storeArray = reinterpret_cast<TClonesArray**>(DataStore::Instance().getObject(*this));
346 }
347 }
TObject ** getObject(const StoreAccessorBase &accessor)
Get a pointer to a pointer of an object in the DataStore.
Definition: DataStore.cc:306
StoreArray(const std::string &name="", DataStore::EDurability durability=DataStore::c_Event)
Constructor to access an array in the DataStore.
Definition: StoreArray.h:126

◆ ensureCreated()

void ensureCreated ( ) const
inlineprivate

Ensure that the array has been created.

Called automatically by write operations.

Definition at line 352 of file StoreArray.h.

353 {
354 if (!isCreated()) {
355 if (!const_cast<StoreArray*>(this)->create())
356 throw std::runtime_error("Write access to " + readableName() + " failed, did you remember to call registerInDataStore()?");
357 }
358 }
bool create(bool replace=false)
Creating StoreArrays is unnecessary, only used internally.
Definition: StoreArray.h:329
bool isCreated() const
Check wether the array object was created.
Definition: StoreArray.h:361

◆ getAccessorParams()

AccessorParams getAccessorParams ( ) const
inlineinherited

Return pair of name and durability under which stored object is saved.


Definition at line 134 of file StoreAccessorBase.h.

134{ return make_pair(m_name, m_durability);}
DataStore::EDurability m_durability
Store durability under which the object/array is saved.
std::string m_name
Store name under which this object/array is saved.

◆ getArrayList()

static std::vector< std::string > getArrayList ( DataStore::EDurability  durability = DataStore::c_Event)
inlinestatic

Return list of array names with matching type.


Definition at line 275 of file StoreArray.h.

276 {
277 return DataStore::Instance().getListOfArrays(T::Class(), durability);
278 }
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.
Definition: DataStore.cc:666

◆ getClass()

TClass * getClass ( ) const
inlineinherited

The underlying object's type.

Definition at line 149 of file StoreAccessorBase.h.

149{ return m_class; }
TClass * m_class
The underlying object's type.

◆ getDurability()

DataStore::EDurability getDurability ( ) const
inlineinherited

Return durability with which the object is saved in the DataStore.

Definition at line 131 of file StoreAccessorBase.h.

131{ return m_durability; }

◆ getEntries()

int getEntries ( ) const
inline

Get the number of objects in the array.

Definition at line 216 of file StoreArray.h.

216{ return isCreated() ? ((*m_storeArray)->GetEntriesFast()) : 0;}

◆ getName()

const std::string & getName ( ) const
inlineinherited

Return name under which the object is saved in the DataStore.

Definition at line 128 of file StoreAccessorBase.h.

128{ return m_name; }

◆ getPtr()

TClonesArray * getPtr ( ) const
inline

Raw access to the underlying TClonesArray.

Warning
TClonesArray is dangerously easy to misuse. Whatever you do will probably be slow, leak memory, and murder your pets. In most cases, you'll want to use StoreArray functions like operator[], getEntries() or appendNew() instead.
Returns
pointer to TClonesArray, or NULL if this array was not registered in the data store

Definition at line 311 of file StoreArray.h.

312 {
314 return (m_storeArray ? *m_storeArray : nullptr);
315 }
void ensureCreated() const
Ensure that the array has been created.
Definition: StoreArray.h:352

◆ hasRelationFrom()

bool hasRelationFrom ( const StoreArray< FROM > &  fromArray,
DataStore::EDurability  durability = DataStore::c_Event,
const std::string &  namedRelation = "" 
) const
inline

Check for the existence of a relation from the given StoreArray.

Parameters
fromArrayArray the relation should point to (from this StoreArray)
durabilityDurability of the relation.
namedRelationAdditional name for the relation, or "" for the default naming

Definition at line 197 of file StoreArray.h.

199 {
200 return DataStore::Instance().hasRelation(fromArray, *this, durability, namedRelation);
201 }
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.
Definition: DataStore.cc:271

◆ hasRelationTo()

bool hasRelationTo ( const StoreArray< TO > &  toArray,
DataStore::EDurability  durability = DataStore::c_Event,
const std::string &  namedRelation = "" 
) const
inline

Check for the existence of a relation to the given StoreArray.

Parameters
toArrayArray the relation should point to (from this StoreArray)
durabilityDurability of the relation.
namedRelationAdditional name for the relation, or "" for the default naming

Definition at line 185 of file StoreArray.h.

187 {
188 return DataStore::Instance().hasRelation(*this, toArray, durability, namedRelation);
189 }

◆ isArray()

bool isArray ( ) const
inlineinherited

Is this an accessor for an array?

Definition at line 152 of file StoreAccessorBase.h.

152{ return m_isArray; }
bool m_isArray
Is this an accessor for an array?

◆ isCreated()

bool isCreated ( ) const
inlineprivate

Check wether the array object was created.


Definition at line 361 of file StoreArray.h.

362 {
364 return m_storeArray && *m_storeArray;
365 }

◆ isOptional()

bool isOptional ( const std::string &  name = "")
inlineinherited

Tell the DataStore about an optional input.

Mainly useful for creating diagrams of module inputs and outputs.

Parameters
nameIf not empty, set non-default name for this object/array. This is permanent, so that e.g. after using registerInDataStore("myName") in initialize(), this object will continue refer to 'myName' in event().
Returns
True if the object/array exists.

Definition at line 93 of file StoreAccessorBase.h.

94 {
95 if (!name.empty())
96 m_name = name;
97 return DataStore::Instance().optionalInput(*this);
98 }
bool optionalInput(const StoreAccessorBase &accessor)
Register the given object/array as an optional input.
Definition: DataStore.cc:739

◆ isRequired()

bool isRequired ( const std::string &  name = "")
inlineinherited

Ensure this array/object has been registered previously.

Will cause an ERROR if it does not exist. This must be called in the initialization phase.

Parameters
nameIf not empty, set non-default name for this object/array. This is permanent, so that e.g. after using registerInDataStore("myName") in initialize(), this object will continue refer to 'myName' in event().
Returns
True if the object/array exists.

Definition at line 78 of file StoreAccessorBase.h.

79 {
80 if (!name.empty())
81 m_name = name;
82 return DataStore::Instance().requireInput(*this);
83 }
bool requireInput(const StoreAccessorBase &accessor)
Produce ERROR message if no entry of the given type is registered in the DataStore.
Definition: DataStore.cc:722

◆ isValid()

bool isValid ( ) const
inline

Check wether the array was registered.

Note
Iterating over the array or calling getEntries() is safe even if this returns false. (getEntries() will return 0)
Returns
True if the array was registered.

Definition at line 288 of file StoreArray.h.

289 {
291 return m_storeArray;
292 }

◆ nextFreeAdress()

T * nextFreeAdress ( )
inlineprivate

Returns address of the next free position of the array.

Returns
pointer to address just past the last array element

Definition at line 335 of file StoreArray.h.

336 {
338 return static_cast<T*>((*m_storeArray)->AddrAt(getEntries()));
339 }

◆ notWrittenOut()

bool notWrittenOut ( ) const
inherited

Returns true if this object/array should not be saved by output modules.

See DataStore::c_DontWriteOut. Can be changed by re-registering it with/without the flag.

Definition at line 53 of file StoreAccessorBase.cc.

54{
56 if (!entry) {
57 B2ERROR("notWrittenOut(): " << readableName() << " doesn't seem to be registered");
58 return false;
59 }
60 return entry->dontWriteOut;
61}
StoreEntry * getEntry(const StoreAccessorBase &accessor)
Check whether an entry with the correct type is registered in the DataStore map and return it.
Definition: DataStore.cc:294
Wraps a stored array/object, stored under unique (name, durability) key.
Definition: StoreEntry.h:22
bool dontWriteOut
Flag that indicates whether the object should be written to the output by default.
Definition: StoreEntry.h:40

◆ operator bool()

operator bool ( ) const
inline

Check wether the array was registered.

Note
Iterating over the array or calling getEntries() is safe even if this returns false. (getEntries() will return 0)
Returns
True if the array was registered.

Definition at line 301 of file StoreArray.h.

301{ return isValid(); }
bool isValid() const
Check wether the array was registered.
Definition: StoreArray.h:288

◆ operator!=()

virtual bool operator!= ( const StoreAccessorBase other) const
inlinevirtualinherited

Check if two store accessors point to a different object/array.

Definition at line 143 of file StoreAccessorBase.h.

144 {
145 return !(*this == other);
146 }

◆ operator==()

virtual bool operator== ( const StoreAccessorBase other) const
inlinevirtualinherited

Check if two store accessors point to the same object/array.

Definition at line 137 of file StoreAccessorBase.h.

138 {
139 return getAccessorParams() == other.getAccessorParams();
140 }
AccessorParams getAccessorParams() const
Return pair of name and durability under which stored object is saved.

◆ operator[]()

T * operator[] ( int  i) const
inline

Access to the stored objects.

Out-of-bounds accesses throw an std::out_of_range exception

Note that using iterators (or range-based for) avoids the range-check internally, and thus might be slightly faster.

Parameters
iArray index, should be in 0..getEntries()-1
Returns
pointer to the object

Definition at line 228 of file StoreArray.h.

229 {
231 //At() checks for out-of-range and returns NULL in that case
232 TObject* obj = (*m_storeArray)->At(i);
233 if (obj == nullptr)
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); //type was checked by DataStore, so the cast is safe.
236 }

◆ optionalRelationTo()

bool optionalRelationTo ( const StoreArray< TO > &  toArray,
DataStore::EDurability  durability = DataStore::c_Event,
const std::string &  namedRelation = "" 
) const
inline

Tell the data store about a relation that we could make use of.

(aka. optional input)

Mainly useful for creating diagrams of module inputs and outputs.

Parameters
toArrayArray the relation should point to (from this StoreArray)
durabilityDurability of the relation.
namedRelationAdditional name for the relation, or "" for the default naming
Returns
True if the relations exists.

Definition at line 172 of file StoreArray.h.

175 {
176 return DataStore::Instance().optionalRelation(*this, toArray, durability, namedRelation);
177 }
bool optionalRelation(const StoreAccessorBase &fromArray, const StoreAccessorBase &toArray, EDurability durability, std::string const &namedRelation)
Register the given relation as an optional input.
Definition: DataStore.cc:766

◆ readableName()

std::string readableName ( ) const
inherited

Convert this acessor into a readable string (for messages).

e.g. "object EventMetaData (durability: event)"

Definition at line 18 of file StoreAccessorBase.cc.

19{
20 std::string str(isArray() ? "array" : "object");
21 str += " '" + getName() + "' (durability: ";
22 switch (getDurability()) {
24 str += "event";
25 break;
27 str += "persistent";
28 break;
29 }
30 return str + ")";
31}
@ c_Persistent
Object is available during entire execution time.
Definition: DataStore.h:60
@ c_Event
Different object in each event, all objects/arrays are invalidated after event() function has been ca...
Definition: DataStore.h:59
DataStore::EDurability getDurability() const
Return durability with which the object is saved in the DataStore.
const std::string & getName() const
Return name under which the object is saved in the DataStore.

◆ registerInDataStore() [1/2]

bool registerInDataStore ( const std::string &  name,
DataStore::EStoreFlags  storeFlags = DataStore::c_WriteOut 
)
inlineinherited

Register the object/array in the DataStore.

This must be called in the initialization phase.

Parameters
nameIf not empty, set non-default name for this object/array. This is permanent, so that e.g. after using registerInDataStore("myName") in initialize(), this object will continue refer to 'myName' in event().
storeFlagsORed combination of DataStore::EStoreFlags.
Returns
True if the registration succeeded.

Definition at line 64 of file StoreAccessorBase.h.

65 {
66 if (!name.empty())
67 m_name = name;
69 }
bool registerEntry(const std::string &name, EDurability durability, TClass *objClass, bool array, EStoreFlags storeFlags)
Register an entry in the DataStore map.
Definition: DataStore.cc:190

◆ registerInDataStore() [2/2]

bool registerInDataStore ( DataStore::EStoreFlags  storeFlags = DataStore::c_WriteOut)
inlineinherited

Register the object/array in the DataStore.

This must be called in the initialization phase.

Parameters
storeFlagsORed combination of DataStore::EStoreFlags.
Returns
True if the registration succeeded.

Definition at line 52 of file StoreAccessorBase.h.

53 {
55 }

◆ registerRelationTo()

bool registerRelationTo ( const StoreArray< TO > &  toArray,
DataStore::EDurability  durability = DataStore::c_Event,
DataStore::EStoreFlags  storeFlags = DataStore::c_WriteOut,
const std::string &  namedRelation = "" 
) const
inline

Register a relation to the given StoreArray.

Use this if you want to create relate objects in this array to objects in 'toArray'. Must be called in the initialization phase.

Parameters
toArrayArray the relation should point to (from this StoreArray)
durabilityDurability of the relation.
storeFlagsORed combination of DataStore::EStoreFlags
namedRelationAdditional name for the relation, or "" for the default naming

Definition at line 140 of file StoreArray.h.

142 {
143 return DataStore::Instance().registerRelation(*this, toArray, durability, storeFlags, namedRelation);
144 }
bool registerRelation(const StoreAccessorBase &fromArray, const StoreAccessorBase &toArray, EDurability durability, EStoreFlags storeFlags, const std::string &namedRelation)
Register a relation in the DataStore map.
Definition: DataStore.cc:244

◆ requireRelationTo()

bool requireRelationTo ( const StoreArray< TO > &  toArray,
DataStore::EDurability  durability = DataStore::c_Event,
const std::string &  namedRelation = "" 
) const
inline

Produce error if no relation from this array to 'toArray' has been registered.

Must be called in initialization phase, aborts job if it fails. (allowing you to catch problems early)

Parameters
toArrayArray the relation should point to (from this StoreArray)
durabilityDurability of the relation.
namedRelationAdditional name for the relation, or "" for the default naming
Returns
True if the relations exists.

Definition at line 155 of file StoreArray.h.

158 {
159 return DataStore::Instance().requireRelation(*this, toArray, durability, namedRelation);
160 }
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...
Definition: DataStore.cc:749

Member Data Documentation

◆ m_class

TClass* m_class
protectedinherited

The underlying object's type.

Definition at line 172 of file StoreAccessorBase.h.

◆ m_durability

DataStore::EDurability m_durability
protectedinherited

Store durability under which the object/array is saved.

Definition at line 169 of file StoreAccessorBase.h.

◆ m_isArray

bool m_isArray
protectedinherited

Is this an accessor for an array?

Definition at line 175 of file StoreAccessorBase.h.

◆ m_name

std::string m_name
protectedinherited

Store name under which this object/array is saved.

Definition at line 166 of file StoreAccessorBase.h.

◆ m_storeArray

TClonesArray** m_storeArray
private

Pointer that actually holds the TClonesArray.

Definition at line 368 of file StoreArray.h.


The documentation for this class was generated from the following files: