 |
Belle II Software
release-05-02-19
|
12 #include <framework/datastore/RelationIndexManager.h>
14 #include <boost/range/iterator_range.hpp>
21 template <
class T>
class StoreArray;
77 template<
class FROM,
class TO>
class RelationIndex {
80 typedef typename RelationIndexContainer<FROM, TO>::Element
Element;
86 typedef typename ElementIndex::template nth_index<0>::type
index_from;
89 typedef typename ElementIndex::template nth_index<1>::type
index_to;
99 typedef typename index_to::const_iterator
iterator_to;
102 typedef boost::iterator_range<iterator_from>
range_from;
105 typedef boost::iterator_range<iterator_to>
range_to;
114 explicit RelationIndex(
const std::string& name = (DataStore::defaultRelationName<FROM, TO>()),
139 operator bool()
const {
return *(
m_index.get()); }
204 if (it ==
m_from.end())
return 0;
227 if (it ==
m_to.end())
return 0;
241 size_t size()
const {
return m_index->index().size(); }
244 const std::shared_ptr<RelationIndexContainer<FROM, TO>>
m_index;
Low-level class to create/modify relations between StoreArrays.
ElementIndex::template nth_index< 0 >::type index_from
Typedef for easy access to the from side of the index.
const Element * getFirstElementTo(const TO &to) const
Return a pointer to the first relation Element of the given object.
index_from::const_iterator iterator_from
Element iterator of the from side index.
RelationIndexContainer< FROM, TO >::ElementIndex ElementIndex
Class representing a the index on the relation.
RelationIndex(const std::string &name=(DataStore::defaultRelationName< FROM, TO >()), DataStore::EDurability durability=DataStore::c_Event)
Constructor.
RelationIndexContainer< FROM, TO >::Element Element
Struct representing a single element in the index.
const Element * getFirstElementFrom(const FROM &from) const
Return a pointer to the first relation Element of the given object.
Manager to keep a cache of existing RelationIndexContainers.
range_to getElementsTo(const TO *to) const
Return a range of all elements pointing to the given object.
size_t size() const
Get the size of the index.
const index_to & m_to
Reference to the to index.
const AccessorParams & getToAccessorParams() const
Get the AccessorParams of the StoreArray the relation points to.
std::pair< std::string, DataStore::EDurability > AccessorParams
Pair of parameters needed to find an object in the DataStore.
range_from getElementsFrom(const FROM *from) const
Return a range of all elements pointing from the given object.
const std::shared_ptr< RelationIndexContainer< FROM, TO > > m_index
Reference to the IndexContainer.
const AccessorParams & getAccessorParams() const
Get the AccessorParams of the underlying relation.
boost::iterator_range< iterator_from > range_from
Iterator range [first,second) of the from side.
Abstract base class for different kinds of events.
const AccessorParams & getFromAccessorParams() const
Get the AccessorParams of the StoreArray the relation points from.
const index_from & m_from
Reference to the from index.
index_to::const_iterator iterator_to
Element iterator of the to side index.
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.
Accessor to arrays stored in the data store.
@ c_Event
Different object in each event, all objects/arrays are invalidated after event() function has been ca...
boost::iterator_range< iterator_to > range_to
Iterator range [first,second) of the to side.
EDurability
Durability types.
ElementIndex::template nth_index< 1 >::type index_to
Typedef for easy access to the to side of the index.