Belle II Software development
|
Class for type safe access to objects that are referred to in relations. More...
#include <RelationVector.h>
Public Types | |
typedef ArrayIterator< RelationVector< T >, T > | iterator |
STL-like iterator over the T objects (not T* ). | |
typedef ArrayIterator< RelationVector< T >, const T > | const_iterator |
STL-like const_iterator over the T objects (not T* ). | |
Public Member Functions | |
RelationVector (const RelationVectorBase &b) | |
Constructor. | |
const std::vector< Belle2::RelationEntry > & | relations () const |
Accessor for the relations vector. | |
size_t | size () const |
Get number of relations. | |
T * | object (int index) const |
Get object with index. | |
T * | operator[] (int index) const |
Get object with index. | |
float | weight (int index) const |
Get weight with index. | |
void | remove (int index) |
Remove relation at given index. | |
void | setWeight (int index, float weight) |
Set a new weight for the given relation. | |
iterator | begin () |
Return iterator to first entry. | |
iterator | end () |
Return iterator to last entry +1. | |
const_iterator | begin () const |
Return const_iterator to first entry. | |
const_iterator | end () const |
Return const_iterator to last entry +1. | |
Protected Member Functions | |
void | add (const RelationVectorBase &other) |
add another list of relations. | |
void | apply (int index, const std::function< void(std::vector< unsigned int > &, std::vector< float > &, size_t)> &f) |
apply function to the relation associated with the RelationEntry at given index. | |
Protected Attributes | |
std::string | m_name |
entry name of array containing object these relations belong to. | |
int | m_index { -1} |
index of object these relations belong to. | |
std::vector< RelationEntry > | m_relations |
The vector of relation entries. | |
std::vector< std::string > | m_relationNames |
Names of associated relations. | |
Class for type safe access to objects that are referred to in relations.
Objects of this class are returned by RelationsObject functinons to provide type safe access to the objects in a vector of relations returned by the data store.
Besides accessing objects/weights directly using operator[](int) and weight(int), you can also iterate over the objects directly:
If you want to modify the related objects in the loop body, you can use a non-const reference instead.
Use setWeight() to modify the weight of a single relation. Use remove() to delete a relation.
Definition at line 67 of file RelationVector.h.
typedef ArrayIterator<RelationVector<T>, const T> const_iterator |
STL-like const_iterator over the T objects (not T* ).
Definition at line 72 of file RelationVector.h.
typedef ArrayIterator<RelationVector<T>, T> iterator |
STL-like iterator over the T objects (not T* ).
Definition at line 70 of file RelationVector.h.
|
inlineexplicit |
Constructor.
b | Not type-safe base class containing the data |
Definition at line 79 of file RelationVector.h.
|
protectedinherited |
add another list of relations.
(internal use)
Definition at line 59 of file RelationVector.cc.
|
protectedinherited |
apply function to the relation associated with the RelationEntry at given index.
Definition at line 13 of file RelationVector.cc.
|
inline |
Return iterator to first entry.
Definition at line 141 of file RelationVector.h.
|
inline |
Return const_iterator to first entry.
Definition at line 146 of file RelationVector.h.
|
inline |
Return iterator to last entry +1.
Definition at line 143 of file RelationVector.h.
|
inline |
|
inline |
Get object with index.
index | Index of relation. |
Definition at line 96 of file RelationVector.h.
|
inline |
Get object with index.
index | Index of relation. |
Definition at line 103 of file RelationVector.h.
|
inline |
Accessor for the relations vector.
Definition at line 85 of file RelationVector.h.
|
inline |
Remove relation at given index.
This will decrease size() by one. Iterators pointing beyond given index will be invalidated when calling this function.
Definition at line 119 of file RelationVector.h.
|
inline |
Set a new weight for the given relation.
Definition at line 131 of file RelationVector.h.
|
inline |
|
inline |
Get weight with index.
index | Index of relation. |
Definition at line 110 of file RelationVector.h.
|
protectedinherited |
index of object these relations belong to.
Definition at line 41 of file RelationVector.h.
|
protectedinherited |
entry name of array containing object these relations belong to.
Definition at line 40 of file RelationVector.h.
|
protectedinherited |
Names of associated relations.
Definition at line 43 of file RelationVector.h.
|
protectedinherited |
The vector of relation entries.
Definition at line 42 of file RelationVector.h.