Belle II Software  release-05-02-19
DataStore.h
1 /**************************************************************************
2  * BASF2 (Belle Analysis Framework 2) *
3  * Copyright(C) 2011 - Belle II Collaboration *
4  * *
5  * Author: The Belle II Collaboration *
6  * Contributors: Martin Heck, Thomas Kuhr, Martin Ritter, *
7  * *
8  * This software is provided "as is" without any warranty. *
9  **************************************************************************/
10 #pragma once
11 
12 #include <framework/datastore/StoreEntry.h>
13 #include <framework/core/BitMask.h>
14 
15 #if defined(__CINT__) || defined(__ROOTCLING__) || defined(R__DICTIONARY_FILENAME)
16 //a few methods use these, but are only included in dictionaries
17 #include <framework/datastore/RelationVector.h>
18 #include <framework/datastore/RelationEntry.h>
19 #endif
20 
21 #include <regex>
22 #include <array>
23 #include <vector>
24 #include <string>
25 #include <map>
26 
27 class TObject;
28 class TClass;
29 
30 namespace Belle2 {
35  class StoreAccessorBase;
36  class DependencyMap;
37  class RelationVectorBase;
38  template <class T> class RelationVector;
39  struct RelationEntry;
40 
53  class DataStore {
54  public:
55  //----------------------------------- enums and typedefs ---------------------------------------------------
60  enum EDurability {
63  };
65  const static int c_NDurabilityTypes = 2;
66 
71  enum EStoreFlags {
72  c_WriteOut = 0,
75  };
76 
78  enum ESearchSide {
82  };
83 
84 
87 
88  // Convenient typedefs.
89  typedef std::map<std::string, StoreEntry> StoreEntryMap;
90  typedef StoreEntryMap::iterator StoreEntryIter;
91  typedef StoreEntryMap::const_iterator StoreEntryConstIter;
92  typedef std::array<StoreEntryMap, c_NDurabilityTypes> DataStoreContents;
102  static bool s_DoCleanup;
103 
104 
105  //--------------------------------- Instance ---------------------------------------------------------------
110  static DataStore& Instance();
111 
112  //--------------------------------- default name stuff -----------------------------------------------------
113 
116  static TClass* getTClassFromDefaultObjectName(const std::string& objectName);
117 
120  static TClass* getTClassFromDefaultArrayName(const std::string& arrayName);
121 
123  static std::string defaultObjectName(const std::string& classname);
124 
126  static std::string defaultObjectName(const TClass* t);
127 
129  template<class T> static std::string defaultObjectName()
130  {
131  const static std::string s = defaultObjectName(T::Class_Name());
132  return s;
133  }
134 
136  static std::string objectName(const TClass* t, const std::string& name);
137 
139  template<class T> static std::string objectName(const std::string& name)
140  {
141  return ((name.empty()) ? defaultObjectName<T>() : name);
142  }
143 
145  static std::string defaultArrayName(const std::string& classname)
146  {
147  const std::string& objName = defaultObjectName(classname);
148  std::string s;
149  s.reserve(objName.length() + 1);
150  s += objName;
151  s += 's';
152  return s;
153  }
154 
156  static std::string defaultArrayName(const TClass* t);
157 
159  template<class T> static std::string defaultArrayName()
160  {
161  const static std::string s = defaultArrayName(defaultObjectName<T>());
162  return s;
163  }
164 
166  static std::string arrayName(const TClass* t, const std::string& name);
167 
169  template<class T> static std::string arrayName(const std::string& name)
170  {
171  return ((name.empty()) ? defaultArrayName<T>() : name);
172  }
173 
175  template<class FROM, class TO> static std::string defaultRelationName()
176  {
177  const static std::string s = relationName(defaultArrayName<FROM>(), defaultArrayName<TO>());
178  return s;
179  }
180 
182  static std::string relationName(const std::string& fromName, const std::string& toName,
183  std::string const& namedRelation = "")
184  {
185  std::string s;
186  s.reserve(fromName.length() + toName.length() + 2);
187  s += fromName;
188  s += "To";
189  s += toName;
190  if (namedRelation.length() > 0) {
191  s += "Named";
192  // Characters are not escaped here, because in registerRelation, the namedRelation
193  // given is checked to contain no special characters or white spaces
194  s += namedRelation;
195  }
196  return s;
197  }
198 
199  //------------------------------ Accessing objects and arrays ----------------------------------------------
214  bool registerEntry(const std::string& name, EDurability durability,
215  TClass* objClass, bool array, EStoreFlags storeFlags);
216 
228  bool registerRelation(const StoreAccessorBase& fromArray, const StoreAccessorBase& toArray, EDurability durability,
229  EStoreFlags storeFlags, const std::string& namedRelation);
230 
240  bool hasRelation(const StoreAccessorBase& fromArray, const StoreAccessorBase& toArray, EDurability durability,
241  const std::string& namedRelation);
242 
250  bool requireInput(const StoreAccessorBase& accessor);
251 
258  bool requireRelation(const StoreAccessorBase& fromArray, const StoreAccessorBase& toArray, EDurability durability,
259  std::string const& namedRelation);
260 
270  bool optionalInput(const StoreAccessorBase& accessor);
271 
279  bool optionalRelation(const StoreAccessorBase& fromArray, const StoreAccessorBase& toArray, EDurability durability,
280  std::string const& namedRelation);
281 
290  StoreEntry* getEntry(const StoreAccessorBase& accessor);
291 
299  TObject** getObject(const StoreAccessorBase& accessor);
300 
309  bool createObject(TObject* object, bool replace, const StoreAccessorBase& accessor);
310 
315  void replaceData(const StoreAccessorBase& from, const StoreAccessorBase& to);
316 
321  StoreEntryMap& getStoreEntryMap(EDurability durability) { return m_storeEntryMap[durability]; }
322 
323 
335  void addRelation(const TObject* fromObject, StoreEntry*& fromEntry, int& fromIndex, const TObject* toObject, StoreEntry*& toEntry,
336  int& toIndex, float weight, const std::string& namedRelation);
337 
338 
353  RelationVectorBase getRelationsWith(ESearchSide searchSide, const TObject* object, StoreEntry*& entry, int& index,
354  const TClass* withClass, const std::string& withName, const std::string& namedRelation);
355 
370  Belle2::RelationEntry getRelationWith(ESearchSide searchSide, const TObject* object, StoreEntry*& entry, int& index,
371  const TClass* withClass, const std::string& withName, const std::string& namedRelation);
372 
383  static void addRelationFromTo(const TObject* fromObject, const TObject* toObject, float weight = 1.0,
384  const std::string& namedRelation = "")
385  {
386  DataStore::StoreEntry* fromEntry = nullptr;
387  int fromIndex = -1;
388  StoreEntry* toEntry = nullptr;
389  int toIndex = -1;
390  Instance().addRelation(fromObject, fromEntry, fromIndex, toObject, toEntry, toIndex, weight, namedRelation);
391  }
392 
408  template <class T> static RelationVector<T> getRelationsWithObj(const TObject* object, const std::string& name = "",
409  const std::string& namedRelation = "")
410  {
411  StoreEntry* storeEntry = nullptr;
412  int index = -1;
413  return RelationVector<T>(Instance().getRelationsWith(c_BothSides, object, storeEntry, index, T::Class(), name, namedRelation));
414  }
415 
428  template <class T> static T* getRelated(const TObject* object, const std::string& name = "", const std::string& namedRelation = "")
429  {
430  if (!object) return nullptr;
431  StoreEntry* storeEntry = nullptr;
432  int index = -1;
433  return static_cast<T*>(DataStore::Instance().getRelationWith(c_BothSides, object, storeEntry, index, T::Class(), name,
434  namedRelation).object);
435  }
436 
437 #if defined(__CINT__) || defined(__ROOTCLING__) || defined(R__DICTIONARY_FILENAME)
438 
443  static RelationVector<TObject> getRelationsWithObj(const TObject* object, const std::string& name)
444  {
445  return getRelationsWithObj<TObject>(object, name);
446  }
447  static TObject* getRelated(const TObject* object, const std::string& name) { return getRelated<TObject>(object, name); }
449 #endif
450 
464  bool findStoreEntry(const TObject* object, StoreEntry*& entry, int& index);
465 
470  std::vector<std::string> getListOfRelatedArrays(const StoreAccessorBase& array) const;
471 
473  std::vector<std::string> getListOfArrays(const TClass* arrayClass, EDurability durability) const;
474 
479  std::vector<std::string> getListOfObjects(const TClass* objClass, EDurability durability) const;
480 
481 
482  //------------------------------ For internal use --------------------------------------------------
487  void setInitializeActive(bool active);
488 
490  bool getInitializeActive() const { return m_initializeActive; }
491 
496  void invalidateData(EDurability durability);
497 
503  void reset(EDurability durability);
504 
509  void reset();
510 
513 
514 
516  void createNewDataStoreID(const std::string& id);
518  std::string currentID() const;
520  void switchID(const std::string& id);
522  void copyEntriesTo(const std::string& id, const std::vector<std::string>& entrylist_event = {});
524  void copyContentsTo(const std::string& id, const std::vector<std::string>& entrylist_event = {});
525 
526  private:
528  explicit DataStore();
530  DataStore(const DataStore&) = delete;
532  DataStore& operator=(const DataStore&) = delete;
534  ~DataStore();
535 
544  bool checkType(const StoreEntry& entry, const StoreAccessorBase& accessor) const;
545 
552  const std::vector<std::string>& getArrayNames(const std::string& arrayName, const TClass* arrayClass,
553  EDurability durability = c_Event) const;
554 
559  static void updateRelationsObjectCache(StoreEntry& entry);
560 
566  public:
569  void clear();
571  void reset(EDurability durability);
573  void invalidateData(EDurability durability);
575  const StoreEntryMap& operator [](int durability) const { return m_entries[m_currentIdx][durability]; }
577  StoreEntryMap& operator [](int durability)
578  {
579  //reuse const implementation
580  const SwitchableDataStoreContents* this2 = this;
581  return const_cast<StoreEntryMap&>((*this2)[durability]);
582  }
583 
585  void switchID(const std::string& id);
587  const std::string& currentID() const { return m_currentID; }
589  void copyEntriesTo(const std::string& id, const std::vector<std::string>& entrylist_event = {});
591  void copyContentsTo(const std::string& id, const std::vector<std::string>& entrylist_event = {});
593  void createNewDataStoreID(const std::string& id);
594  private:
595  std::vector<DataStoreContents> m_entries;
596  std::map<std::string, int> m_idToIndexMap;
597  std::string m_currentID = "";
598  int m_currentIdx = 0;
599  };
602 
603 
609 
614  const std::regex m_regexNamedRelationCheck = std::regex("^[a-zA-Z]*$");
615 
618  };
619 
622 } // namespace Belle2
Belle2::DataStore::arrayName
static std::string arrayName(const std::string &name)
Return the storage name for an object of the given type and name.
Definition: DataStore.h:169
Belle2::DataStore::SwitchableDataStoreContents::currentID
const std::string & currentID() const
returns ID of current DataStore.
Definition: DataStore.h:587
Belle2::DataStore::c_BothSides
@ c_BothSides
Combination of c_FromSide and c_ToSide.
Definition: DataStore.h:81
Belle2::DataStore::SwitchableDataStoreContents::m_entries
std::vector< DataStoreContents > m_entries
wrapped DataStoreContents.
Definition: DataStore.h:595
Belle2::DataStore::registerRelation
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
Belle2::DataStore::updateRelationsObjectCache
static void updateRelationsObjectCache(StoreEntry &entry)
For an array containing RelationsObjects, update index and entry cache for entire contents.
Definition: DataStore.cc:387
Belle2::DataStore::m_initializeActive
bool m_initializeActive
True if modules are currently being initialized.
Definition: DataStore.h:608
Belle2::DataStore::StoreEntryIter
StoreEntryMap::iterator StoreEntryIter
Iterator for a StoreEntry map.
Definition: DataStore.h:90
Belle2::DataStore::SwitchableDataStoreContents::createNewDataStoreID
void createNewDataStoreID(const std::string &id)
creates new datastore with given id, copying the registered objects/arrays from the current one.
Definition: DataStore.cc:791
Belle2::DataStore::getInitializeActive
bool getInitializeActive() const
Are we currently initializing modules?
Definition: DataStore.h:490
Belle2::DataStore::SwitchableDataStoreContents::m_idToIndexMap
std::map< std::string, int > m_idToIndexMap
Maps DataStore ID to index in m_entries.
Definition: DataStore.h:596
Belle2::DataStore::getListOfArrays
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:667
Belle2::DataStore::getDependencyMap
DependencyMap & getDependencyMap()
Return map of depedencies between modules.
Definition: DataStore.h:512
Belle2::DataStore::currentID
std::string currentID() const
returns ID of current DataStore.
Definition: DataStore.cc:758
Belle2::DataStore::SwitchableDataStoreContents::copyEntriesTo
void copyEntriesTo(const std::string &id, const std::vector< std::string > &entrylist_event={})
copy entries (not contents) of current DataStore to the DataStore with given ID.
Definition: DataStore.cc:801
Belle2::DataStore::Instance
static DataStore & Instance()
Instance of singleton Store.
Definition: DataStore.cc:54
Belle2::DataStore::arrayName
static std::string arrayName(const TClass *t, const std::string &name)
Return the storage name for an object of the given TClass and name.
Definition: DataStore.cc:164
Belle2::DataStore::StoreEntryMap
std::map< std::string, StoreEntry > StoreEntryMap
Map for StoreEntries.
Definition: DataStore.h:89
Belle2::DependencyMap
Collect information about the dependencies between modules.
Definition: DependencyMap.h:22
Belle2::DataStore::ESearchSide
ESearchSide
Which side of relations should be returned?
Definition: DataStore.h:78
Belle2::DataStore::setInitializeActive
void setInitializeActive(bool active)
Setter for m_initializeActive.
Definition: DataStore.cc:94
Belle2::DataStore::SwitchableDataStoreContents::reset
void reset(EDurability durability)
Frees memory occupied by data store items and removes all objects from the map.
Definition: DataStore.cc:913
Belle2::DataStore::EStoreFlags
EStoreFlags
Flags describing behaviours of objects etc.
Definition: DataStore.h:71
Belle2::DataStore::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.
Definition: DataStore.cc:492
Belle2::StoreEntry
Wraps a stored array/object, stored under unique (name, durability) key.
Definition: StoreEntry.h:15
Belle2::DataStore::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'.
Definition: DataStore.cc:641
Belle2::DataStore::SwitchableDataStoreContents::m_currentID
std::string m_currentID
currently active DataStore ID.
Definition: DataStore.h:597
Belle2::DataStore::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 ...
Definition: DataStore.cc:343
Belle2::StoreAccessorBase
Base class for StoreObjPtr and StoreArray for easier common treatment.
Definition: StoreAccessorBase.h:29
Belle2::DataStore::defaultObjectName
static std::string defaultObjectName()
Return the default storage name for an object of the given type.
Definition: DataStore.h:129
Belle2::DataStore::c_DontWriteOut
@ c_DontWriteOut
Object/array should be NOT saved by output modules.
Definition: DataStore.h:73
Belle2::DataStore::getObject
TObject ** getObject(const StoreAccessorBase &accessor)
Get a pointer to a pointer of an object in the DataStore.
Definition: DataStore.cc:306
Belle2::DataStore::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.
Definition: DataStore.cc:271
Belle2::DataStore::DataStoreContents
std::array< StoreEntryMap, c_NDurabilityTypes > DataStoreContents
StoreEntry maps for each durability.
Definition: DataStore.h:92
Belle2::DataStore::getArrayNames
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.
Definition: DataStore.cc:465
Belle2::RelationVectorBase
base class for RelationVector<T>
Definition: RelationVector.h:34
Belle2::DataStore::optionalInput
bool optionalInput(const StoreAccessorBase &accessor)
Register the given object/array as an optional input.
Definition: DataStore.cc:713
Belle2::DataStore::m_dependencyMap
DependencyMap * m_dependencyMap
Collect information about the dependencies between modules.
Definition: DataStore.h:617
Belle2::DataStore::objectName
static std::string objectName(const std::string &name)
Return the storage name for an object of the given type and name.
Definition: DataStore.h:139
Belle2::DataStore::getStoreEntryMap
StoreEntryMap & getStoreEntryMap(EDurability durability)
Get a reference to the object/array map.
Definition: DataStore.h:321
Belle2::DataStore::createNewDataStoreID
void createNewDataStoreID(const std::string &id)
creates new datastore with given id, copying the registered objects/arrays from the current one.
Definition: DataStore.cc:753
Belle2::DataStore::c_WriteOut
@ c_WriteOut
Object/array should be saved by output modules.
Definition: DataStore.h:72
Belle2::DataStore::s_DoCleanup
static bool s_DoCleanup
Global flag to to decide if we can do normal cleanup.
Definition: DataStore.h:102
Belle2::DataStore::getTClassFromDefaultArrayName
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 wi...
Definition: DataStore.cc:116
Belle2::RelationEntry
Struct for relations.
Definition: RelationEntry.h:26
Belle2::DataStore::copyEntriesTo
void copyEntriesTo(const std::string &id, const std::vector< std::string > &entrylist_event={})
copy entries (not contents) of current DataStore to the DataStore with given ID.
Definition: DataStore.cc:774
Belle2::DataStore::m_regexNamedRelationCheck
const std::regex m_regexNamedRelationCheck
Regular expression to check that no special characters and no white spaces are in the string given fo...
Definition: DataStore.h:614
Belle2::DataStore::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.
Definition: DataStore.cc:672
Belle2::DataStore::SwitchableDataStoreContents::m_currentIdx
int m_currentIdx
index of currently active DataStore.
Definition: DataStore.h:598
Belle2::DataStore::getRelationsWith
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.
Definition: DataStore.cc:546
Belle2::RelationVector
Class for type safe access to objects that are referred to in relations.
Definition: DataStore.h:38
Belle2::RelationEntry::object
TObject * object
Pointer to the object.
Definition: RelationEntry.h:34
Belle2::DataStore::copyContentsTo
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.
Definition: DataStore.cc:779
Belle2::DataStore::SwitchableDataStoreContents::operator[]
const StoreEntryMap & operator[](int durability) const
Get StoreEntry map for given durability (and current DataStore ID).
Definition: DataStore.h:575
Belle2::DataStore::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 tha...
Definition: DataStore.cc:723
Belle2::DataStore::m_storeEntryMap
SwitchableDataStoreContents m_storeEntryMap
Maps (name, durability) key to StoreEntry objects.
Definition: DataStore.h:601
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19
Belle2::DataStore::SwitchableDataStoreContents::switchID
void switchID(const std::string &id)
switch to DataStore with given ID.
Definition: DataStore.cc:890
Belle2::DataStore::SwitchableDataStoreContents
Encapsulates DataStoreContents, but allows transparently switching between different versions ('DataS...
Definition: DataStore.h:565
Belle2::DataStore::SwitchableDataStoreContents::copyContentsTo
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.
Definition: DataStore.cc:849
Belle2::DataStore::getRelationsWithObj
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.
Definition: DataStore.h:408
Belle2::DataStore::defaultArrayName
static std::string defaultArrayName(const std::string &classname)
Return the default storage name for an given class name.
Definition: DataStore.h:145
Belle2::DataStore::c_NDurabilityTypes
const static int c_NDurabilityTypes
Number of Durability Types.
Definition: DataStore.h:65
Belle2::DataStore::c_ToSide
@ c_ToSide
Return relations/objects pointed to (from a given object).
Definition: DataStore.h:80
Belle2::DataStore::defaultArrayName
static std::string defaultArrayName()
Return the default storage name for an array of the given type.
Definition: DataStore.h:159
Belle2::DataStore::SwitchableDataStoreContents::clear
void clear()
same as calling reset() for all durabilities + all non-default datastore IDs are removed.
Definition: DataStore.cc:900
Belle2::DataStore::registerEntry
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
Belle2::DataStore::switchID
void switchID(const std::string &id)
switch to DataStore with given ID.
Definition: DataStore.cc:763
Belle2::DataStore::getRelated
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.
Definition: DataStore.h:428
Belle2::DataStore::operator=
DataStore & operator=(const DataStore &)=delete
no assignment operator
Belle2::DataStore::SwitchableDataStoreContents::invalidateData
void invalidateData(EDurability durability)
Clears all registered StoreEntry objects of a specified durability, invalidating all objects.
Definition: DataStore.cc:922
Belle2::DataStore::findStoreEntry
bool findStoreEntry(const TObject *object, StoreEntry *&entry, int &index)
Find an object in an array in the data store.
Definition: DataStore.cc:398
Belle2::ADD_BITMASK_OPERATORS
ADD_BITMASK_OPERATORS(DataStore::EStoreFlags)
Add bitmask operators to DataStore::EStoreFlags.
Belle2::DataStore::DataStore
DataStore()
Hidden constructor, as it is a singleton.
Definition: DataStore.cc:61
Belle2::DataStore::~DataStore
~DataStore()
Destructor.
Definition: DataStore.cc:65
Belle2::DataStore::StoreEntry
Belle2::StoreEntry StoreEntry
Wraps a stored array/object, stored under unique (name, durability) key.
Definition: DataStore.h:86
Belle2::DataStore::c_ErrorIfAlreadyRegistered
@ c_ErrorIfAlreadyRegistered
If the object/array was already registered, produce an error (aborting initialisation).
Definition: DataStore.h:74
Belle2::DataStore::relationName
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:182
Belle2::DataStore::c_Persistent
@ c_Persistent
Object is available during entire execution time.
Definition: DataStore.h:62
Belle2::DataStore::addRelationFromTo
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.
Definition: DataStore.h:383
Belle2::DataStore::getTClassFromDefaultObjectName
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.
Definition: DataStore.cc:105
Belle2::DataStore::objectName
static std::string objectName(const TClass *t, const std::string &name)
Return the storage name for an object of the given TClass and name.
Definition: DataStore.cc:151
Belle2::DataStore::StoreEntryConstIter
StoreEntryMap::const_iterator StoreEntryConstIter
const_iterator for a StoreEntry map.
Definition: DataStore.h:91
Belle2::DataStore::createObject
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
Belle2::DataStore::optionalRelation
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:740
Belle2::DataStore::getRelationWith
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.
Definition: DataStore.cc:598
Belle2::DataStore::getEntry
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
Belle2::DataStore::checkType
bool checkType(const StoreEntry &entry, const StoreAccessorBase &accessor) const
Check whether the given entry and the requested class match.
Definition: DataStore.cc:170
Belle2::DataStore::c_Event
@ c_Event
Different object in each event, all objects/arrays are invalidated after event() function has been ca...
Definition: DataStore.h:61
Belle2::DataStore::invalidateData
void invalidateData(EDurability durability)
Clears all registered StoreEntry objects of a specified durability, invalidating all objects.
Definition: DataStore.cc:689
Belle2::DataStore::reset
void reset()
Clears contents of the datastore (all durabilities)
Definition: DataStore.cc:74
Belle2::DataStore
In the store you can park objects that have to be accessed by various modules.
Definition: DataStore.h:53
Belle2::DataStore::defaultRelationName
static std::string defaultRelationName()
Return the default storage name for a relation between the given types.
Definition: DataStore.h:175
Belle2::DataStore::c_FromSide
@ c_FromSide
Return relations/objects pointed from (to a given object).
Definition: DataStore.h:79
Belle2::DataStore::requireInput
bool requireInput(const StoreAccessorBase &accessor)
Produce ERROR message if no entry of the given type is registered in the DataStore.
Definition: DataStore.cc:696
Belle2::DataStore::EDurability
EDurability
Durability types.
Definition: DataStore.h:60