 |
Belle II Software
release-05-02-19
|
12 #include <framework/datastore/RelationIndexContainer.h>
31 class RelationIndexManager {
46 template<
class FROM,
class TO> std::shared_ptr<RelationIndexContainer<FROM, TO>>
get(
const RelationArray& relation)
48 const static bool doTypeCheck = (FROM::Class() != TObject::Class() or TO::Class() != TObject::Class());
52 const std::
string& name = relation.getName();
53 DataStore::EDurability durability = relation.getDurability();
57 if (it != relations.end()) {
59 indexContainer = std::dynamic_pointer_cast<RelationIndexContainer<FROM, TO>>(it->second);
61 if (!indexContainer) {
63 relations[name] = indexContainer;
67 return indexContainer;
102 template<
class FROM,
class TO> std::shared_ptr<RelationIndexContainer<FROM, TO>>
getIndexIfExists(
const std::string& name,
106 RelationMap::const_iterator it = relations.find(name);
107 if (it != relations.end()) {
108 return std::dynamic_pointer_cast<RelationIndexContainer<FROM, TO>>(it->second);
121 typedef std::map<std::string, std::shared_ptr<RelationIndexBase>>
RelationMap;
123 typedef std::array<RelationMap, DataStore::c_NDurabilityTypes>
RelationCache;
static RelationIndexManager & Instance()
Returns the singleton instance.
RelationIndexManager()=default
No Constructor hidden.
std::array< RelationMap, DataStore::c_NDurabilityTypes > RelationCache
Cachetype for all Containers.
std::map< std::string, std::shared_ptr< RelationIndexBase > > RelationMap
Maptype to keep track of all Containers of one durability.
void reset()
Reset the cache completely, that is clear all caches and don't even keep the Index objects around.
void rebuild(bool force=false)
Rebuild the index.
std::shared_ptr< RelationIndexContainer< FROM, TO > > get(const RelationArray &relation)
Get a RelationIndexContainer.
Abstract base class for different kinds of events.
RelationIndexManager & operator=(const RelationIndexManager &)=delete
Also no assignment.
const static int c_NDurabilityTypes
Number of Durability Types.
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.
void clear(DataStore::EDurability durability=DataStore::c_Event)
Clear the cache of RelationIndexContainers with the given durability.
Class to store a bidirectional index between two StoreArrays.
~RelationIndexManager()
Clean cache on exit.
@ c_Event
Different object in each event, all objects/arrays are invalidated after event() function has been ca...
In the store you can park objects that have to be accessed by various modules.
RelationCache m_cache
Cache for all Containers.
EDurability
Durability types.