Belle II Software light-2406-ragdoll
|
Provides access to fast ( O(log n) ) bi-directional lookups on a specified relation. More...
#include <RelationIndex.h>
Public Types | |
typedef RelationIndexContainer< FROM, TO >::Element | Element |
Struct representing a single element in the index. | |
typedef RelationIndexContainer< FROM, TO >::ElementIndex | ElementIndex |
Class representing a the index on the relation. | |
typedef ElementIndex::template nth_index< 0 >::type | index_from |
Typedef for easy access to the from side of the index. | |
typedef ElementIndex::template nth_index< 1 >::type | index_to |
Typedef for easy access to the to side of the index. | |
typedef index_from::const_iterator | iterator_from |
Element iterator of the from side index. | |
typedef index_to::const_iterator | iterator_to |
Element iterator of the to side index. | |
typedef boost::iterator_range< iterator_from > | range_from |
Iterator range [first,second) of the from side. | |
typedef boost::iterator_range< iterator_to > | range_to |
Iterator range [first,second) of the to side. | |
Public Member Functions | |
RelationIndex (const std::string &name=(DataStore::defaultRelationName< FROM, TO >()), DataStore::EDurability durability=DataStore::c_Event) | |
Constructor. | |
RelationIndex (const StoreArray< FROM > &from, const StoreArray< TO > &to, const std::string &name="", DataStore::EDurability durability=DataStore::c_Event) | |
Constructor with checks. | |
operator bool () const | |
check if index is based on valid relation. | |
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. | |
range_to | getElementsTo (const TO *to) const |
Return a range of all elements pointing to the given object. | |
range_to | getElementsTo (const TO &to) const |
Return a range of all elements pointing to the given object. | |
const Element * | getFirstElementFrom (const FROM &from) const |
Return a pointer to the first relation Element of the given object. | |
const Element * | getFirstElementFrom (const FROM *from) const |
Return a pointer to the first relation Element of the given object. | |
const Element * | getFirstElementTo (const TO &to) const |
Return a pointer to the first relation Element of the given object. | |
const Element * | getFirstElementTo (const TO *to) const |
Return a pointer to the first relation Element of the given object. | |
AccessorParams | getAccessorParams () const |
Get the AccessorParams of the underlying relation. | |
const AccessorParams & | getFromAccessorParams () const |
Get the AccessorParams of the StoreArray the relation points from. | |
const AccessorParams & | getToAccessorParams () const |
Get the AccessorParams of the StoreArray the relation points to. | |
size_t | size () const |
Get the size of the index. | |
Protected Attributes | |
const std::shared_ptr< RelationIndexContainer< FROM, TO > > | m_index |
Reference to the IndexContainer. | |
const index_from & | m_from |
Reference to the from index. | |
const index_to & | m_to |
Reference to the to index. | |
Provides access to fast ( O(log n) ) bi-directional lookups on a specified relation.
Relations connect objects stored in two StoreArrays with each other, with the possibility of n:n connections and individual weights.
This class provides bidirectional access to a given relation to ease use of Relations for the normal user. There is no support for changing or adding Elements of the relation, this should be done directly using RelationArray.
Given an object of type FROM or TO, RelationIndex can easily find objects on the other side connected to it. If there can be at most one relation from/to the given objects, this is especially simple:
If more than one associated object exists, one can loop over them using range-based for. For example, when one instead wants to find the CDCSimHits belonging to a particle, one can use:
The documentation of the relation element type used by getFirstElementTo()/ getFirstElementFrom() or during the for loop can be found in RelationIndexContainer<FROM, TO>::Element.
Definition at line 76 of file RelationIndex.h.
typedef RelationIndexContainer<FROM,TO>::Element Element |
Struct representing a single element in the index.
Definition at line 79 of file RelationIndex.h.
typedef RelationIndexContainer<FROM,TO>::ElementIndex ElementIndex |
Class representing a the index on the relation.
Definition at line 82 of file RelationIndex.h.
typedef ElementIndex::template nth_index<0>::type index_from |
Typedef for easy access to the from side of the index.
Definition at line 85 of file RelationIndex.h.
typedef ElementIndex::template nth_index<1>::type index_to |
Typedef for easy access to the to side of the index.
Definition at line 88 of file RelationIndex.h.
typedef index_from::const_iterator iterator_from |
Element iterator of the from side index.
Definition at line 95 of file RelationIndex.h.
typedef index_to::const_iterator iterator_to |
Element iterator of the to side index.
Definition at line 98 of file RelationIndex.h.
typedef boost::iterator_range<iterator_from> range_from |
Iterator range [first,second) of the from side.
Definition at line 101 of file RelationIndex.h.
typedef boost::iterator_range<iterator_to> range_to |
Iterator range [first,second) of the to side.
Definition at line 104 of file RelationIndex.h.
|
inlineexplicit |
Constructor.
name | Name of the relation. Empty string will be replaced with the default relation name for the given types |
durability | Durabiliy of the relation |
Definition at line 113 of file RelationIndex.h.
|
inline |
Constructor with checks.
This constructor takes the StoreArrays as arguments to perform additional sanity checks if the relation is correct.
from | StoreArray the relation is supposed to point from |
to | StoreArray the relation is supposed to point to |
name | Name of the relation. Empty string will be replaced with the default relation name for the given types |
durability | Durabiliy of the relation |
Definition at line 131 of file RelationIndex.h.
|
inline |
|
inline |
Return a range of all elements pointing from the given object.
Can be used with range-based for, see RelationIndex class documentation for an example.
from | Reference for which to get the relation |
Definition at line 160 of file RelationIndex.h.
|
inline |
Return a range of all elements pointing from the given object.
Can be used with range-based for, see RelationIndex class documentation for an example.
from | Pointer for which to get the relation. |
Definition at line 149 of file RelationIndex.h.
|
inline |
Return a range of all elements pointing to the given object.
Can be used with range-based for, see RelationIndex class documentation for an example.
to | Reference for which to get the relation |
Definition at line 182 of file RelationIndex.h.
|
inline |
Return a range of all elements pointing to the given object.
Can be used with range-based for, see RelationIndex class documentation for an example.
to | Pointer for which to get the relation |
Definition at line 171 of file RelationIndex.h.
|
inline |
Return a pointer to the first relation Element of the given object.
Useful if there is at most one relation
from | Reference for which to get the Relation |
Definition at line 191 of file RelationIndex.h.
|
inline |
Return a pointer to the first relation Element of the given object.
Useful if there is at most one relation
from | Pointer for which to get the Relation |
Definition at line 200 of file RelationIndex.h.
|
inline |
Return a pointer to the first relation Element of the given object.
Useful if there is at most one relation
to | Reference for which to get the Relation |
Definition at line 214 of file RelationIndex.h.
|
inline |
Return a pointer to the first relation Element of the given object.
Useful if there is at most one relation
to | Pointer for which to get the Relation |
Definition at line 223 of file RelationIndex.h.
|
inline |
Get the AccessorParams of the StoreArray the relation points from.
Definition at line 234 of file RelationIndex.h.
|
inline |
Get the AccessorParams of the StoreArray the relation points to.
Definition at line 237 of file RelationIndex.h.
|
inline |
|
inline |
|
protected |
Reference to the from index.
Definition at line 246 of file RelationIndex.h.
|
protected |
Reference to the IndexContainer.
Definition at line 243 of file RelationIndex.h.
|
protected |
Reference to the to index.
Definition at line 249 of file RelationIndex.h.