PODIO v00-16-03
An Event-Data-Model Toolkit for High Energy Physics Experiments
Loading...
Searching...
No Matches
podio::RelationRange< ReferenceType > Class Template Reference

#include <RelationRange.h>

Public Types

using ConstIteratorType = typename std::vector< ReferenceType >::const_iterator
 

Public Member Functions

 RelationRange ()=delete
 
 RelationRange (ConstIteratorType begin, ConstIteratorType end)
 
ConstIteratorType begin () const
 begin of the range (necessary for range-based for loop)
 
ConstIteratorType end () const
 end of the range (necessary for range-based for loop)
 
size_t size () const
 convenience overload for size
 
bool empty () const
 convenience overload to check if the range is empty
 
ReferenceType operator[] (size_t i) const
 Indexed access.
 
ReferenceType at (size_t i) const
 Indexed access with range check.
 

Detailed Description

template<typename ReferenceType>
class podio::RelationRange< ReferenceType >

A simple helper class that allows to return related objects in a way that makes it possible to use the return type in a range-based for loop.

Definition at line 13 of file RelationRange.h.

Member Typedef Documentation

◆ ConstIteratorType

template<typename ReferenceType >
using podio::RelationRange< ReferenceType >::ConstIteratorType = typename std::vector<ReferenceType>::const_iterator

Definition at line 15 of file RelationRange.h.

Constructor & Destructor Documentation

◆ RelationRange() [1/2]

template<typename ReferenceType >
podio::RelationRange< ReferenceType >::RelationRange ( )
delete

◆ RelationRange() [2/2]

template<typename ReferenceType >
podio::RelationRange< ReferenceType >::RelationRange ( ConstIteratorType  begin,
ConstIteratorType  end 
)
inline

Definition at line 19 of file RelationRange.h.

19 :
20 m_begin(begin), m_end(end), m_size(std::distance(m_begin, m_end)) {
21 }
ConstIteratorType end() const
end of the range (necessary for range-based for loop)
Definition: RelationRange.h:28
ConstIteratorType begin() const
begin of the range (necessary for range-based for loop)
Definition: RelationRange.h:24

Member Function Documentation

◆ at()

template<typename ReferenceType >
ReferenceType podio::RelationRange< ReferenceType >::at ( size_t  i) const
inline

Indexed access with range check.

Definition at line 46 of file RelationRange.h.

46 {
47 if (i < m_size) {
48 auto it = m_begin;
49 std::advance(it, i);
50 return *it;
51 }
52 throw std::out_of_range("index out of bounds for RelationRange");
53 }

◆ begin()

template<typename ReferenceType >
ConstIteratorType podio::RelationRange< ReferenceType >::begin ( ) const
inline

begin of the range (necessary for range-based for loop)

Definition at line 24 of file RelationRange.h.

24 {
25 return m_begin;
26 }

◆ empty()

template<typename ReferenceType >
bool podio::RelationRange< ReferenceType >::empty ( ) const
inline

convenience overload to check if the range is empty

Definition at line 36 of file RelationRange.h.

36 {
37 return m_begin == m_end;
38 }

◆ end()

template<typename ReferenceType >
ConstIteratorType podio::RelationRange< ReferenceType >::end ( ) const
inline

end of the range (necessary for range-based for loop)

Definition at line 28 of file RelationRange.h.

28 {
29 return m_end;
30 }

◆ operator[]()

template<typename ReferenceType >
ReferenceType podio::RelationRange< ReferenceType >::operator[] ( size_t  i) const
inline

Indexed access.

Definition at line 40 of file RelationRange.h.

40 {
41 auto it = m_begin;
42 std::advance(it, i);
43 return *it;
44 }

◆ size()

template<typename ReferenceType >
size_t podio::RelationRange< ReferenceType >::size ( ) const
inline

convenience overload for size

Definition at line 32 of file RelationRange.h.

32 {
33 return m_size;
34 }

The documentation for this class was generated from the following file: