Belle II Software  release-08-01-10
DataStore Class Reference

In the store you can park objects that have to be accessed by various modules. More...

#include <DataStore.h>

Collaboration diagram for DataStore:

Classes

class  SwitchableDataStoreContents
 Encapsulates DataStoreContents, but allows transparently switching between different versions ('DataStore IDs'). More...
 

Public Types

enum  EDurability {
  c_Event ,
  c_Persistent
}
 Durability types. More...
 
enum  EStoreFlags {
  c_WriteOut = 0 ,
  c_DontWriteOut = 1 ,
  c_ErrorIfAlreadyRegistered = 2
}
 Flags describing behaviours of objects etc. More...
 
enum  ESearchSide {
  c_FromSide ,
  c_ToSide ,
  c_BothSides
}
 Which side of relations should be returned? More...
 
typedef Belle2::StoreEntry StoreEntry
 Wraps a stored array/object, stored under unique (name, durability) key.
 
typedef std::map< std::string, StoreEntryStoreEntryMap
 Map for StoreEntries.
 
typedef StoreEntryMap::iterator StoreEntryIter
 Iterator for a StoreEntry map.
 
typedef StoreEntryMap::const_iterator StoreEntryConstIter
 const_iterator for a StoreEntry map.
 
typedef std::array< StoreEntryMap, c_NDurabilityTypesDataStoreContents
 StoreEntry maps for each durability.
 

Public Member Functions

bool registerEntry (const std::string &name, EDurability durability, TClass *objClass, bool array, EStoreFlags storeFlags)
 Register an entry in the DataStore map. More...
 
bool registerRelation (const StoreAccessorBase &fromArray, const StoreAccessorBase &toArray, EDurability durability, EStoreFlags storeFlags, const std::string &namedRelation)
 Register a relation in the DataStore map. More...
 
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. More...
 
bool requireInput (const StoreAccessorBase &accessor)
 Produce ERROR message if no entry of the given type is registered in the DataStore. More...
 
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 that direction). More...
 
bool optionalInput (const StoreAccessorBase &accessor)
 Register the given object/array as an optional input. More...
 
bool optionalRelation (const StoreAccessorBase &fromArray, const StoreAccessorBase &toArray, EDurability durability, std::string const &namedRelation)
 Register the given relation as an optional input. More...
 
StoreEntrygetEntry (const StoreAccessorBase &accessor)
 Check whether an entry with the correct type is registered in the DataStore map and return it. More...
 
TObject ** getObject (const StoreAccessorBase &accessor)
 Get a pointer to a pointer of an object in the DataStore. More...
 
bool createObject (TObject *object, bool replace, const StoreAccessorBase &accessor)
 Create a new object/array in the DataStore or add an existing one. More...
 
void replaceData (const StoreAccessorBase &from, const StoreAccessorBase &to)
 For two StoreAccessors of same type, move all data in 'from' into 'to', discarding previous contents of 'to' and leaving 'from' empty. More...
 
StoreEntryMapgetStoreEntryMap (EDurability durability)
 Get a reference to the object/array map. More...
 
void addRelation (const TObject *fromObject, StoreEntry *&fromEntry, int &fromIndex, const TObject *toObject, StoreEntry *&toEntry, int &toIndex, float weight, const std::string &namedRelation)
 Add a relation from an object in a store array to another object in a store array. More...
 
RelationVectorBase getRelationsWith (ESearchSide searchSide, const TObject *object, StoreEntry *&entry, int &index, const TClass *withClass, const std::string &withName, const std::string &namedRelation)
 Get the relations between an object and other objects in a store array. More...
 
Belle2::RelationEntry getRelationWith (ESearchSide searchSide, const TObject *object, StoreEntry *&entry, int &index, const TClass *withClass, const std::string &withName, const std::string &namedRelation)
 Get the first relation between an object and another object in a store array. More...
 
bool findStoreEntry (const TObject *object, StoreEntry *&entry, int &index)
 Find an object in an array in the data store. More...
 
std::vector< std::string > getListOfRelatedArrays (const StoreAccessorBase &array) const
 Returns a list of names of arrays which have registered relations that point to or from 'array'. More...
 
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.
 
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. More...
 
std::vector< std::string > getListOfRelations (EDurability durability) const
 Returns a list of names of StoreObjPtr-objects whose class is (or inherits from) RelationContainer.
 
std::vector< std::string > getSortedListOfDataStore (EDurability durability) const
 Returns a (sorted) list of all the content of the DataStore (Objs-Arrays-Relations).
 
void setInitializeActive (bool active)
 Setter for m_initializeActive. More...
 
bool getInitializeActive () const
 Are we currently initializing modules?
 
void invalidateData (EDurability durability)
 Clears all registered StoreEntry objects of a specified durability, invalidating all objects. More...
 
void reset (EDurability durability)
 Frees memory occupied by data store items and removes all objects from the map. More...
 
void reset ()
 Clears contents of the datastore (all durabilities) More...
 
DependencyMapgetDependencyMap ()
 Return map of depedencies between modules.
 
void createNewDataStoreID (const std::string &id)
 creates new datastore with given id, copying the registered objects/arrays from the current one.
 
void createEmptyDataStoreID (const std::string &id)
 creates empty datastore with given id.
 
std::string currentID () const
 returns ID of current DataStore.
 
void switchID (const std::string &id)
 switch to DataStore with given ID.
 
void copyEntriesTo (const std::string &id, const std::vector< std::string > &entrylist_event={}, bool mergeEntries=false)
 copy entries (not contents) of current DataStore to the DataStore with given ID.
 
void copyContentsTo (const std::string &id, const std::vector< std::string > &entrylist_event={})
 copy contents (actual array / object contents) of current DataStore to the DataStore with given ID.
 
void mergeContentsTo (const std::string &id, const std::vector< std::string > &entrylist_event={})
 merge contents (actual array / object contents) of current DataStore to the DataStore with given ID.
 

Static Public Member Functions

static DataStoreInstance ()
 Instance of singleton Store. More...
 
static TClass * getTClassFromDefaultObjectName (const std::string &objectName)
 Tries to deduce the TClass from a default object name, which is generally the name of the C++ class. More...
 
static TClass * getTClassFromDefaultArrayName (const std::string &arrayName)
 Tries to deduce the TClass from a default array name, which is generally the name of the C++ class with an appended 's'. More...
 
static std::string defaultObjectName (const std::string &classname)
 Return the default storage name for given class name.
 
static std::string defaultObjectName (const TClass *t)
 Return the default storage name for an object of the given TClass.
 
template<class T >
static std::string defaultObjectName ()
 Return the default storage name for an object of the given type.
 
static std::string objectName (const TClass *t, const std::string &name)
 Return the storage name for an object of the given TClass and name.
 
template<class T >
static std::string objectName (const std::string &name)
 Return the storage name for an object of the given type and name.
 
static std::string defaultArrayName (const std::string &classname)
 Return the default storage name for an given class name.
 
static std::string defaultArrayName (const TClass *t)
 Return the default storage name for an array of the given TClass.
 
template<class T >
static std::string defaultArrayName ()
 Return the default storage name for an array of the given type.
 
static std::string arrayName (const TClass *t, const std::string &name)
 Return the storage name for an object of the given TClass and name.
 
template<class T >
static std::string arrayName (const std::string &name)
 Return the storage name for an object of the given type and name.
 
template<class FROM , class TO >
static std::string defaultRelationName ()
 Return the default storage name for a relation between the given types.
 
static std::string relationName (const std::string &fromName, const std::string &toName, std::string const &namedRelation="")
 Return storage name for a relation between two arrays of the given names.
 
static void addRelationFromTo (const TObject *fromObject, const TObject *toObject, float weight=1.0, const std::string &namedRelation="")
 Add a relation from an object in a store array to another object in a store array. More...
 
template<class T >
static RelationVector< T > getRelationsWithObj (const TObject *object, const std::string &name="", const std::string &namedRelation="")
 Get the relations between an object and other objects in a store array. More...
 
template<class T >
static T * getRelated (const TObject *object, const std::string &name="", const std::string &namedRelation="")
 Get the object to or from which another object has a relation. More...
 

Static Public Attributes

static const int c_NDurabilityTypes = 2
 Number of Durability Types. More...
 
static bool s_DoCleanup = false
 Global flag to to decide if we can do normal cleanup. More...
 

Private Member Functions

 DataStore ()
 Hidden constructor, as it is a singleton.
 
 DataStore (const DataStore &)=delete
 no copy constructor
 
DataStoreoperator= (const DataStore &)=delete
 no assignment operator
 
 ~DataStore ()
 Destructor.
 
bool checkType (const StoreEntry &entry, const StoreAccessorBase &accessor) const
 Check whether the given entry and the requested class match. More...
 
const std::vector< std::string > & getArrayNames (const std::string &arrayName, const TClass *arrayClass, EDurability durability=c_Event) const
 Returns a vector with the names of store arrays matching the given name and class. More...
 

Static Private Member Functions

static void updateRelationsObjectCache (StoreEntry &entry)
 For an array containing RelationsObjects, update index and entry cache for entire contents. More...
 

Private Attributes

SwitchableDataStoreContents m_storeEntryMap
 Maps (name, durability) key to StoreEntry objects.
 
bool m_initializeActive
 True if modules are currently being initialized. More...
 
const std::regex m_regexNamedRelationCheck = std::regex("^[a-zA-Z]*$")
 Regular expression to check that no special characters and no white spaces are in the string given for namedRelations.
 
DependencyMapm_dependencyMap
 Collect information about the dependencies between modules.
 

Detailed Description

In the store you can park objects that have to be accessed by various modules.

Normal users should access the store via StoreAccessorBase-derived classes like StoreObjPtr or StoreArray.

Nomenclature:

See also
EDurability StoreObjPtr StoreArray RelationsObject

Definition at line 51 of file DataStore.h.

Member Enumeration Documentation

◆ EDurability

Durability types.

Defines how long an object should be valid.

Enumerator
c_Event 

Different object in each event, all objects/arrays are invalidated after event() function has been called on last module in path.


c_Persistent 

Object is available during entire execution time.

Objects are never invalidated and are accessible even after process(Path) returns.

Definition at line 58 of file DataStore.h.

58  {
59  c_Event,
61  };
@ 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

◆ ESearchSide

Which side of relations should be returned?

Enumerator
c_FromSide 

Return relations/objects pointed from (to a given object).

c_ToSide 

Return relations/objects pointed to (from a given object).

c_BothSides 

Combination of c_FromSide and c_ToSide.

Definition at line 76 of file DataStore.h.

◆ EStoreFlags

Flags describing behaviours of objects etc.

Bitwise operators (|, &, etc.) are provided via ADD_BITMASK_OPERATORS.

Enumerator
c_WriteOut 

Object/array should be saved by output modules.

(default)

c_DontWriteOut 

Object/array should be NOT saved by output modules.

Can be overridden using the 'branchNames' parameter of RootOutput.

c_ErrorIfAlreadyRegistered 

If the object/array was already registered, produce an error (aborting initialisation).

Definition at line 69 of file DataStore.h.

Member Function Documentation

◆ addRelation()

void addRelation ( const TObject *  fromObject,
StoreEntry *&  fromEntry,
int &  fromIndex,
const TObject *  toObject,
StoreEntry *&  toEntry,
int &  toIndex,
float  weight,
const std::string &  namedRelation 
)

Add a relation from an object in a store array to another object in a store array.

Parameters
fromObjectPointer to the object from which the relation points.
fromEntryData store entry that contains the fromObject. Used for caching. Will be set if NULL.
fromIndexIndex in TClonesArray that contains the fromObject. Used for caching. Will be set if < 0.
toObjectPointer to the object to which the relation points.
toEntryData store entry that contains the toObject. Used for caching. Will be set if NULL.
toIndexIndex in TClonesArray that contains the toObject. Used for caching. Will be set if < 0.
weightWeight of the relation.
namedRelationAdditional name for the relation, or "" for the default naming

Definition at line 492 of file DataStore.cc.

494 {
495  if (!fromObject or !toObject)
496  return;
497 
498  // get entry from which the relation points
499  if (!findStoreEntry(fromObject, fromEntry, fromIndex)) {
500  B2FATAL("Couldn't find from-side entry for relation between " << fromObject->ClassName() << " and " << toObject->ClassName() <<
501  ". Please make sure the object is part of a StoreArray before adding a relation.");
502  }
503 
504  // get entry to which the relation points
505  if (!findStoreEntry(toObject, toEntry, toIndex)) {
506  B2FATAL("Couldn't find to-side entry for relation between " << fromObject->ClassName() << " and " << toObject->ClassName() <<
507  ". Please make sure the object is part of a StoreArray before adding a relation.");
508  }
509 
510  // get the relations from -> to
511  const string& relationsName = relationName(fromEntry->name, toEntry->name, namedRelation);
512  const StoreEntryIter& it = m_storeEntryMap[c_Event].find(relationsName);
513  if (it == m_storeEntryMap[c_Event].end()) {
514  B2FATAL("No relation '" << relationsName <<
515  "' found. Please register it (using StoreArray::registerRelationTo()) before trying to add relations.");
516  }
517  StoreEntry* entry = &(it->second);
518 
519  // auto create relations if needed (both if null pointer, or uninitialised object read from TTree)
520  if (!entry->ptr)
521  entry->recreate();
522  auto* relContainer = static_cast<RelationContainer*>(entry->ptr);
523  if (relContainer->isDefaultConstructed()) {
524  relContainer->setFromName(fromEntry->name);
525  relContainer->setFromDurability(c_Event);
526  relContainer->setToName(toEntry->name);
527  relContainer->setToDurability(c_Event);
528  }
529 
530  // add relation
531  TClonesArray& relations = relContainer->elements();
532  new (relations.AddrAt(relations.GetLast() + 1)) RelationElement(fromIndex, toIndex, weight);
533 
534  std::shared_ptr<RelationIndexContainer<TObject, TObject>> relIndex =
535  RelationIndexManager::Instance().getIndexIfExists<TObject, TObject>(relationsName, c_Event);
536  if (relIndex) {
537  // add it to index (so we avoid expensive rebuilding later)
538  relIndex->index().emplace(fromIndex, toIndex, fromObject, toObject, weight);
539  } else {
540  //mark for rebuilding later on
541  relContainer->setModified(true);
542  }
543 }
bool findStoreEntry(const TObject *object, StoreEntry *&entry, int &index)
Find an object in an array in the data store.
Definition: DataStore.cc:398
StoreEntryMap::iterator StoreEntryIter
Iterator for a StoreEntry map.
Definition: DataStore.h:88
static std::string relationName(const std::string &fromName, const std::string &toName, std::string const &namedRelation="")
Return storage name for a relation between two arrays of the given names.
Definition: DataStore.h:180
SwitchableDataStoreContents m_storeEntryMap
Maps (name, durability) key to StoreEntry objects.
Definition: DataStore.h:621
Class to store relations between StoreArrays in the DataStore.
void setFromName(const std::string &name)
Set name of the StoreArray we relate from.
Class to store a single element of a relation.
std::shared_ptr< RelationIndexContainer< FROM, TO > > getIndexIfExists(const std::string &name, DataStore::EDurability durability) const
if the index exists in the cache, it is returned; otherwise NULL.
static RelationIndexManager & Instance()
Returns the singleton instance.
Wraps a stored array/object, stored under unique (name, durability) key.
Definition: StoreEntry.h:22
TObject * ptr
The pointer to the returned object, either equal to 'object' or null, depending on wether the object ...
Definition: StoreEntry.h:51
std::string name
Name of the entry.
Definition: StoreEntry.h:53
void recreate()
Reset stored object to defaults, set ptr to new object.
Definition: StoreEntry.cc:68

◆ addRelationFromTo()

static void addRelationFromTo ( const TObject *  fromObject,
const TObject *  toObject,
float  weight = 1.0,
const std::string &  namedRelation = "" 
)
inlinestatic

Add a relation from an object in a store array to another object in a store array.

Note
If possible, use RelationsObject members instead, as they allow more efficent caching. Currently this should only be necessary if fromObject is of type genfit::...
See also
RelationsObject::addRelationTo
Parameters
fromObjectPointer to the object from which the relation points.
toObjectPointer to the object to which the relation points.
weightWeight of the relation.
namedRelationAdditional name for the relation, or "" for the default naming

Definition at line 387 of file DataStore.h.

◆ checkType()

bool checkType ( const StoreEntry entry,
const StoreAccessorBase accessor 
) const
private

Check whether the given entry and the requested class match.

Name and durability are not checked.

Parameters
entryThe existing DataStore entry.
accessorEncapsulates name, durability, and type
Returns
True if both types match.

Definition at line 170 of file DataStore.cc.

◆ createObject()

bool createObject ( TObject *  object,
bool  replace,
const StoreAccessorBase accessor 
)

Create a new object/array in the DataStore or add an existing one.

A matching map entry must already exist. Otherwise an error will be generated.

Parameters
objectPointer to the object that should be stored. If 0, a new default object is created.
replaceIf an object already exists, it will be replaced if this is true. If false, an error will be printed.
accessorEncapsulates name, durability, and type
Returns
Wether the object was successfully inserted/created

Definition at line 316 of file DataStore.cc.

◆ findStoreEntry()

bool findStoreEntry ( const TObject *  object,
DataStore::StoreEntry *&  entry,
int &  index 
)

Find an object in an array in the data store.

entry/index are used to return the found array and index, should be set to NULL and -1, or some cached values (will be checked).

Given non-NULL entry and index>=0, this function returns immediately if the object is found at the given position.

Parameters
objectPointer to the object.
entryThe DataStore entry that contains the object.
indexThe index of the object in the array.
Returns
True if the object was found in the data store

Definition at line 398 of file DataStore.cc.

◆ getArrayNames()

const std::vector< std::string > & getArrayNames ( const std::string &  arrayName,
const TClass *  arrayClass,
EDurability  durability = c_Event 
) const
private

Returns a vector with the names of store arrays matching the given name and class.

Note that the returned reference is only valid until the next call.

Parameters
arrayNameA given array name, the special string "ALL" for all arrays deriving from the given class, or an empty string for the default array name.
arrayClassThe class of the array(s).
durabilityDecide with which durability map you want to perform the requested action.

Definition at line 465 of file DataStore.cc.

◆ getEntry()

DataStore::StoreEntry * getEntry ( const StoreAccessorBase accessor)

Check whether an entry with the correct type is registered in the DataStore map and return it.

If the map of requested durability already contains an object under the key name with a DIFFERENT type than the given type one, an error will be reported.

Parameters
accessorEncapsulates name, durability, and type
Returns
StoreEntry, or NULL if not found

Definition at line 294 of file DataStore.cc.

◆ getListOfObjects()

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.

(this does NOT include the internal RelationContainer objects.)

Definition at line 671 of file DataStore.cc.

◆ getListOfRelatedArrays()

std::vector< std::string > getListOfRelatedArrays ( const StoreAccessorBase array) const

Returns a list of names of arrays which have registered relations that point to or from 'array'.

This may be useful for internal purposes when modifying array contents.

Definition at line 640 of file DataStore.cc.

◆ getObject()

TObject ** getObject ( const StoreAccessorBase accessor)

Get a pointer to a pointer of an object in the DataStore.

If the map of requested durability already contains an object under the key name with a DIFFERENT type than the given type one, an error will be reported.

Parameters
accessorEncapsulates name, durability, and type
Returns
Pointer to pointer to object, NULL if none exists

Definition at line 306 of file DataStore.cc.

◆ getRelated()

static T* getRelated ( const TObject *  object,
const std::string &  name = "",
const std::string &  namedRelation = "" 
)
inlinestatic

Get the object to or from which another object has a relation.

Note
If possible, use RelationsObject members instead, as they allow more efficent caching. Currently this should only be necessary if type(object) == genfit::..
Parameters
objectPointer to the object to or from which the relation points.
Template Parameters
TThe class of objects to or from which the relation points.
Parameters
nameThe name of the store array to or from which the relation points. If empty the default store array name for class T will be used. If the special name "ALL" is given all store arrays containing objects of type T are considered.
namedRelationAdditional name for the relation, or "" for the default naming
Returns
The related object or a null pointer.

Definition at line 432 of file DataStore.h.

◆ getRelationsWith()

RelationVectorBase getRelationsWith ( ESearchSide  searchSide,
const TObject *  object,
DataStore::StoreEntry *&  entry,
int &  index,
const TClass *  withClass,
const std::string &  withName,
const std::string &  namedRelation 
)

Get the relations between an object and other objects in a store array.

Parameters
searchSideSearch objects of type withClass on this side of relations (with 'object' on the other side).
objectPointer to the object from or to which the relations point.
entryData store entry that contains the object. Used for caching. Will be set if 0.
indexIndex in TClonesArray that contains the object. Used for caching. Will be set if < 0.
withClassClass of the objects to or from which the relations point.
withNameThe name of the store array to or from which the relations point. If empty the default store array name for withClass will be used. If the special name "ALL" is given all store arrays containing object of type withClass are considered.
namedRelationAdditional name for the relation, or "" for the default naming. If withName is "ALL", the namedRelation parameter is ignored and all related objects are returned.
Returns
Vector of relation entry objects (not type-safe).

Definition at line 545 of file DataStore.cc.

◆ getRelationsWithObj()

static RelationVector<T> getRelationsWithObj ( const TObject *  object,
const std::string &  name = "",
const std::string &  namedRelation = "" 
)
inlinestatic

Get the relations between an object and other objects in a store array.

Relations in both directions are returned.

Note
Using this function should only be necessary if type(object) == genfit::.... If possible, use RelationsObject members instead, as they allow more efficent caching.
See also
RelationsObject::getRelationsWith
Parameters
objectPointer to the object from or to which the relations point.
Template Parameters
TClass of the objects to or from which the relations point.
Parameters
nameThe name of the store array to or from which the relations point. If empty the default store array name for withClass will be used. If the special name "ALL" is given all store arrays containing objects of type T are considered.
namedRelationAdditional name for the relation, or "" for the default naming
Returns
Vector of relation entry objects.

Definition at line 412 of file DataStore.h.

◆ getRelationWith()

RelationEntry getRelationWith ( ESearchSide  searchSide,
const TObject *  object,
DataStore::StoreEntry *&  entry,
int &  index,
const TClass *  withClass,
const std::string &  withName,
const std::string &  namedRelation 
)

Get the first relation between an object and another object in a store array.

Parameters
searchSideSearch objects of type withClass on this side of relations (with 'object' on the other side).
objectPointer to the object from or to which the relation points.
entryData store entry that contains the object. Used for caching. Will be set if 0.
indexIndex in TClonesArray that contains the object. Used for caching. Will be set if < 0.
withClassClass of the objects to or from which the relation points.
withNameThe name of the store array to or from which the relation points. If empty the default store array name for withClass will be used. If the special name "ALL" is given all store arrays containing object of type withClass are considered.
namedRelationAdditional name for the relation, or "" for the default naming. If withName is "ALL", the namedRelation parameter is ignored and all related objects are returned.
Returns
The entry of the first related object.

Definition at line 597 of file DataStore.cc.

◆ getStoreEntryMap()

StoreEntryMap& getStoreEntryMap ( EDurability  durability)
inline

Get a reference to the object/array map.

This is intended to be used for input/output or other framework-internal modules.

Definition at line 325 of file DataStore.h.

◆ getTClassFromDefaultArrayName()

TClass * getTClassFromDefaultArrayName ( const std::string &  arrayName)
static

Tries to deduce the TClass from a default array name, which is generally the name of the C++ class with an appended 's'.

The namespace qualification Belle2:: can be ommitted

Definition at line 116 of file DataStore.cc.

◆ getTClassFromDefaultObjectName()

TClass * getTClassFromDefaultObjectName ( const std::string &  objectName)
static

Tries to deduce the TClass from a default object name, which is generally the name of the C++ class.

The namespace qualification Belle2:: can be ommitted.

Definition at line 105 of file DataStore.cc.

◆ hasRelation()

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.

Parameters
fromArrayOrigin of the relation
toArrayTarget of the relation
durabilityDecide with which durability map you want to perform the requested action.
namedRelationAdditional name for the relation, or "" for the default naming.
Returns
True if there is a registered relation.
See also
DependencyMap

Definition at line 271 of file DataStore.cc.

◆ Instance()

DataStore & Instance ( )
static

Instance of singleton Store.

This method is used to access the DataStore directly. It is used internally in the Store accessor classes.

Definition at line 54 of file DataStore.cc.

◆ invalidateData()

void invalidateData ( EDurability  durability)

Clears all registered StoreEntry objects of a specified durability, invalidating all objects.

Called by the framework once the given durability is over. Users should usually not use this function without a good reason.

Definition at line 715 of file DataStore.cc.

◆ optionalInput()

bool optionalInput ( const StoreAccessorBase accessor)

Register the given object/array as an optional input.

Mainly useful for creating diagrams of module inputs and outputs.

Parameters
accessorEncapsulates name, durability, and type
Returns
True if the requested object exists.
See also
DependencyMap

Definition at line 739 of file DataStore.cc.

◆ optionalRelation()

bool optionalRelation ( const StoreAccessorBase fromArray,
const StoreAccessorBase toArray,
EDurability  durability,
std::string const &  namedRelation 
)

Register the given relation as an optional input.

Mainly useful for creating diagrams of module inputs and outputs.

Parameters
fromArrayOrigin of the relation
toArrayTarget of the relation
durabilityDecide with which durability map you want to perform the requested action.
namedRelationAdditional name for the relation, or "" for the default naming1
Returns
True if the requested object exists.
See also
DependencyMap

Definition at line 766 of file DataStore.cc.

◆ registerEntry()

bool registerEntry ( const std::string &  name,
EDurability  durability,
TClass *  objClass,
bool  array,
EStoreFlags  storeFlags 
)

Register an entry in the DataStore map.

If the map of requested durability already contains an object under the key name with a DIFFERENT type than the given type, an error will be reported.
Otherwise a new map slot is created. This must be called in the initialization phase. Otherwise an error is returned.

Parameters
nameName under which you want to save the object in the DataStore.
durabilityDecide with which durability map you want to perform the requested action.
objClassThe class of the object.
arrayWhether it is a TClonesArray or not.
storeFlagsORed combination of DataStore::EStoreFlags.
Returns
True if the registration succeeded.
See also
DependencyMap

Definition at line 190 of file DataStore.cc.

◆ registerRelation()

bool registerRelation ( const StoreAccessorBase fromArray,
const StoreAccessorBase toArray,
EDurability  durability,
EStoreFlags  storeFlags,
const std::string &  namedRelation 
)

Register a relation in the DataStore map.

This must be called in the initialization phase. Otherwise an error is returned.

Parameters
fromArrayOrigin of the relation
toArrayTarget of the relation
durabilityDecide with which durability map you want to perform the requested action.
storeFlagsORed combination of DataStore::EStoreFlags.
namedRelationAdditional name for the relation, or "" for the default naming
Returns
True if the registration succeeded.
See also
DependencyMap

Definition at line 244 of file DataStore.cc.

◆ replaceData()

void replaceData ( const StoreAccessorBase from,
const StoreAccessorBase to 
)

For two StoreAccessors of same type, move all data in 'from' into 'to', discarding previous contents of 'to' and leaving 'from' empty.

Meta-data like c_DontWriteOut flags or info about associated arrays for RelationContainers is not replaced.

Definition at line 343 of file DataStore.cc.

◆ requireInput()

bool requireInput ( const StoreAccessorBase accessor)

Produce ERROR message if no entry of the given type is registered in the DataStore.

Note
can only be used in initialize() function
Parameters
accessorEncapsulates name, durability, and type
Returns
True if the requested object exists.
See also
DependencyMap

Definition at line 722 of file DataStore.cc.

◆ requireRelation()

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 that direction).

Note
can only be used in initialize() function
Parameters
fromArrayOrigin of the relation
toArrayTarget of the relation
durabilityDecide with which durability map you want to perform the requested action.
namedRelationAdditional name for the relation, or "" for the default naming
Returns
True if the requested object exists.
See also
DependencyMap

Definition at line 749 of file DataStore.cc.

◆ reset() [1/2]

void reset ( void  )

Clears contents of the datastore (all durabilities)

Called by the framework. Users should usually not use this function without good reason.

Definition at line 74 of file DataStore.cc.

◆ reset() [2/2]

void reset ( EDurability  durability)

Frees memory occupied by data store items and removes all objects from the map.

Afterwards, m_storeEntryMap[durability] is empty. Called by the framework. Users should usually not use this function without good reason.

Definition at line 86 of file DataStore.cc.

◆ setInitializeActive()

void setInitializeActive ( bool  active)

Setter for m_initializeActive.

This should only be called by EventProcessor.

Definition at line 94 of file DataStore.cc.

◆ updateRelationsObjectCache()

void updateRelationsObjectCache ( StoreEntry entry)
staticprivate

For an array containing RelationsObjects, update index and entry cache for entire contents.

You must ensure the array actually contains objects inheriting from RelationsObject!

Definition at line 387 of file DataStore.cc.

Member Data Documentation

◆ c_NDurabilityTypes

const int c_NDurabilityTypes = 2
static

Number of Durability Types.


Definition at line 63 of file DataStore.h.

◆ m_initializeActive

bool m_initializeActive
private

True if modules are currently being initialized.

Creating new map slots is only allowed in a Module's initialize() function.

Definition at line 628 of file DataStore.h.

◆ s_DoCleanup

bool s_DoCleanup = false
static

Global flag to to decide if we can do normal cleanup.

If the normal basf2 execution is bypassed, e.g. in tests or separate binaries, we cannot guarantee that exit handlers are called in the correct order. Since this may lead to double deletion of objects through ROOT and misleading error stack traces, we will skip cleanup in these exceptional cases.

Definition at line 100 of file DataStore.h.


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