11#include <framework/datastore/RelationIndexManager.h>
13#include <boost/range/iterator_range.hpp>
20 template <
class T>
class StoreArray;
85 typedef typename ElementIndex::template nth_index<0>::type
index_from;
88 typedef typename ElementIndex::template nth_index<1>::type
index_to;
104 typedef boost::iterator_range<iterator_to>
range_to;
113 explicit RelationIndex(
const std::string& name = (DataStore::defaultRelationName<FROM, TO>()),
138 operator bool()
const {
return *(
m_index.get()); }
203 if (it ==
m_from.end())
return 0;
226 if (it ==
m_to.end())
return 0;
243 const std::shared_ptr<RelationIndexContainer<FROM, TO>>
m_index;
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.
boost::multi_index::multi_index_container< Element, boost::multi_index::indexed_by< boost::multi_index::ordered_non_unique< boost::multi_index::member< Element, const FROM *, &Element::from > >, boost::multi_index::ordered_non_unique< boost::multi_index::member< Element, const TO *, &Element::to > > > > ElementIndex
Boost MultiIndex container to keep the bidirectional index.
Manager to keep a cache of existing RelationIndexContainers.
Provides access to fast ( O(log n) ) bi-directional lookups on a specified relation.
RelationIndex(const std::string &name=(DataStore::defaultRelationName< FROM, TO >()), DataStore::EDurability durability=DataStore::c_Event)
Constructor.
const AccessorParams & getFromAccessorParams() const
Get the AccessorParams of the StoreArray the relation points from.
const Element * getFirstElementFrom(const FROM &from) const
Return a pointer to the first relation Element of the given object.
ElementIndex::template nth_index< 0 >::type index_from
Typedef for easy access to the from side of the index.
ElementIndex::template nth_index< 1 >::type index_to
Typedef for easy access to the to side of the index.
const std::shared_ptr< RelationIndexContainer< FROM, TO > > m_index
Reference to the IndexContainer.
RelationIndexContainer< FROM, TO >::ElementIndex ElementIndex
Class representing a the index on the relation.
size_t size() const
Get the size of the index.
const AccessorParams & getToAccessorParams() const
Get the AccessorParams of the StoreArray the relation points to.
index_from::const_iterator iterator_from
Element iterator of the from side index.
range_from getElementsFrom(const FROM &from) const
Return a range of all elements pointing from the given object.
range_from getElementsFrom(const FROM *from) const
Return a range of all elements pointing from the given object.
const Element * getFirstElementFrom(const FROM *from) const
Return a pointer to the first relation Element of the given object.
RelationIndex(const StoreArray< FROM > &from, const StoreArray< TO > &to, const std::string &name="", DataStore::EDurability durability=DataStore::c_Event)
Constructor with checks.
const Element * getFirstElementTo(const TO &to) const
Return a pointer to the first relation Element of the given object.
boost::iterator_range< iterator_from > range_from
Iterator range [first,second) of the from side.
range_to getElementsTo(const TO &to) const
Return a range of all elements pointing to the given object.
RelationIndexContainer< FROM, TO >::Element Element
Struct representing a single element in the index.
AccessorParams getAccessorParams() const
Get the AccessorParams of the underlying relation.
boost::iterator_range< iterator_to > range_to
Iterator range [first,second) of the to side.
index_to::const_iterator iterator_to
Element iterator of the to side index.
const index_to & m_to
Reference to the to index.
range_to getElementsTo(const TO *to) const
Return a range of all elements pointing to the given object.
const index_from & m_from
Reference to the from index.
const Element * getFirstElementTo(const TO *to) const
Return a pointer to the first relation Element of the given object.
Accessor to arrays stored in the data store.
std::pair< std::string, DataStore::EDurability > AccessorParams
Pair of parameters needed to find an object in the DataStore.
Abstract base class for different kinds of events.
Element type for the index.