11#include <framework/datastore/RelationIndexContainer.h>
45 template<
class FROM,
class TO> std::shared_ptr<RelationIndexContainer<FROM, TO>>
get(
const RelationArray& relation)
47 const static bool doTypeCheck = (FROM::Class() != TObject::Class() or TO::Class() != TObject::Class());
51 const std::string& name = relation.
getName();
54 std::shared_ptr<RelationIndexContainer<FROM, TO>> indexContainer;
55 RelationMap::iterator it = relations.find(name);
56 if (it != relations.end()) {
58 indexContainer = std::dynamic_pointer_cast<RelationIndexContainer<FROM, TO>>(it->second);
60 if (!indexContainer) {
62 relations[name] = indexContainer;
64 indexContainer->rebuild(
false);
66 return indexContainer;
101 template<
class FROM,
class TO> std::shared_ptr<RelationIndexContainer<FROM, TO>>
getIndexIfExists(
const std::string& name,
105 RelationMap::const_iterator it = relations.find(name);
106 if (it != relations.end()) {
107 return std::dynamic_pointer_cast<RelationIndexContainer<FROM, TO>>(it->second);
120 typedef std::map<std::string, std::shared_ptr<RelationIndexBase>>
RelationMap;
122 typedef std::array<RelationMap, DataStore::c_NDurabilityTypes>
RelationCache;
In the store you can park objects that have to be accessed by various modules.
static const int c_NDurabilityTypes
Number of Durability Types.
EDurability
Durability types.
@ c_Event
Different object in each event, all objects/arrays are invalidated after event() function has been ca...
Low-level class to create/modify relations between StoreArrays.
bool isValid() const
Check whether the object was created.
Class to store a bidirectional index between two StoreArrays.
Manager to keep a cache of existing RelationIndexContainers.
std::array< RelationMap, DataStore::c_NDurabilityTypes > RelationCache
Cachetype for all Containers.
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.
RelationCache m_cache
Cache for all Containers.
RelationIndexManager(const RelationIndexManager &)=delete
No copy-constructor.
RelationIndexManager(RelationIndexManager &&)=delete
No move constructor.
std::shared_ptr< RelationIndexContainer< FROM, TO > > get(const RelationArray &relation)
Get a RelationIndexContainer.
~RelationIndexManager()
Clean cache on exit.
static RelationIndexManager & Instance()
Returns the singleton instance.
RelationIndexManager & operator=(const RelationIndexManager &)=delete
Also no assignment.
std::map< std::string, std::shared_ptr< RelationIndexBase > > RelationMap
Maptype to keep track of all Containers of one durability.
void clear(DataStore::EDurability durability=DataStore::c_Event)
Clear the cache of RelationIndexContainers with the given durability.
void reset()
Reset the cache completely, that is clear all caches and don't even keep the Index objects around.
RelationIndexManager()=default
No Constructor hidden.
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.
Abstract base class for different kinds of events.