ATLAS Offline Software
Public Member Functions | Private Attributes | List of all members
TrigConf::ConstIter< V, T > Class Template Referencefinal

Forward iterator over an iterable of type V returning an object of type T. More...

#include <ConstIter.h>

Collaboration diagram for TrigConf::ConstIter< V, T >:

Public Member Functions

 ConstIter (const V &buf, size_t offset=0, std::function< T(const typename V::value_type &)> f=[](auto &x) ->T{return {x};})
 Constructor. More...
 
bool operator== (const ConstIter &i) const
 Comparison operator. More...
 
bool operator!= (const ConstIter &i) const
 Not-equal operator. More...
 
ConstIteroperator++ ()
 Pre-increment operator. More...
 
const T & operator* () const
 Dereference operator Creates object of type T from the current object in the container on the fly using the creation function m_f. More...
 

Private Attributes

const V & m_buf
 Const reference to the underlying data container. More...
 
std::size_t m_offset
 Current position of the iterator. More...
 
CxxUtils::CachedValue< T > m_data
 Holder of the transformed data. More...
 
std::function< T(const typename V::value_type &)> m_f
 Function to turn a single datum from the container into the output type. More...
 
V::const_iterator m_bufIt
 Iterator over the container. More...
 

Detailed Description

template<typename V, typename T>
class TrigConf::ConstIter< V, T >

Forward iterator over an iterable of type V returning an object of type T.

By its nature this is a generator, returning values of type T, computed on the fly https://en.wikipedia.org/wiki/Generator_(computer_programming)

Objects of type T must be creatable from V::value_type, either by having a constuctor T(V::valuetype) or by supplying an explicit conversion function to the constructor of the iterator

This is being used by HLTMenu, L1Menu, and L1TopoMenu

Definition at line 32 of file ConstIter.h.

Constructor & Destructor Documentation

◆ ConstIter()

template<typename V , typename T >
TrigConf::ConstIter< V, T >::ConstIter ( const V &  buf,
size_t  offset = 0,
std::function< T(const typename V::value_type &)>  f = [](auto & x)->T{return {x};} 
)
inline

Constructor.

Parameters
bufReference to the underlying iterable data container
offsetPosition of the current element at construction time
fFunction to create an object of type T from type V::value_type, the default calls a contstructor T(V::value_type)

Iterators pointing to the front and back of the container, assuming that T can be created from the elements of V are created like this

ConstIter<V, T> begin( v );
ConstIter<V, T> end( v, v.size() );

An example for iterating over chains of an HLTMenu

ptree & chains = hltmenu.data().get_child("chains");
ConstIter<ptree, TrigConf::HLTChain> begin( v, 0, [](auto x){return HLTChain(x.second));
ConstIter<ptree, TrigConf::HLTChain> end( chains, chains.size(), [](auto x){return HLTChain(x.second) );

Definition at line 53 of file ConstIter.h.

54  {return {x};}) :
55  m_buf(buf),
57  m_data(),
58  m_f(f),
59  m_bufIt(buf.begin())
60  {}

Member Function Documentation

◆ operator!=()

template<typename V , typename T >
bool TrigConf::ConstIter< V, T >::operator!= ( const ConstIter< V, T > &  i) const
inline

Not-equal operator.

Definition at line 68 of file ConstIter.h.

68  {
69  return !(*this == i);
70  }

◆ operator*()

template<typename V , typename T >
const T& TrigConf::ConstIter< V, T >::operator* ( ) const
inline

Dereference operator Creates object of type T from the current object in the container on the fly using the creation function m_f.

Definition at line 83 of file ConstIter.h.

83  {
84  if( ! m_data.isValid() ) {
85  m_data.set (m_f(*m_bufIt));
86  }
87  return *m_data.ptr();
88  }

◆ operator++()

template<typename V , typename T >
ConstIter& TrigConf::ConstIter< V, T >::operator++ ( )
inline

Pre-increment operator.

Definition at line 73 of file ConstIter.h.

73  {
74  ++m_offset;
75  ++m_bufIt;
76  m_data.reset();
77  return *this;
78  }

◆ operator==()

template<typename V , typename T >
bool TrigConf::ConstIter< V, T >::operator== ( const ConstIter< V, T > &  i) const
inline

Comparison operator.

Definition at line 63 of file ConstIter.h.

63  {
64  return &i.m_buf == &m_buf && i.m_offset == m_offset;
65  }

Member Data Documentation

◆ m_buf

template<typename V , typename T >
const V& TrigConf::ConstIter< V, T >::m_buf
private

Const reference to the underlying data container.

Definition at line 91 of file ConstIter.h.

◆ m_bufIt

template<typename V , typename T >
V::const_iterator TrigConf::ConstIter< V, T >::m_bufIt
private

Iterator over the container.

Definition at line 95 of file ConstIter.h.

◆ m_data

template<typename V , typename T >
CxxUtils::CachedValue<T> TrigConf::ConstIter< V, T >::m_data
private

Holder of the transformed data.

Definition at line 93 of file ConstIter.h.

◆ m_f

template<typename V , typename T >
std::function<T(const typename V::value_type &)> TrigConf::ConstIter< V, T >::m_f
private

Function to turn a single datum from the container into the output type.

Definition at line 94 of file ConstIter.h.

◆ m_offset

template<typename V , typename T >
std::size_t TrigConf::ConstIter< V, T >::m_offset
private

Current position of the iterator.

Definition at line 92 of file ConstIter.h.


The documentation for this class was generated from the following file:
TrigConf::ConstIter::m_buf
const V & m_buf
Const reference to the underlying data container.
Definition: ConstIter.h:91
TrigConf::ConstIter::m_offset
std::size_t m_offset
Current position of the iterator.
Definition: ConstIter.h:92
python.CaloRecoConfig.f
f
Definition: CaloRecoConfig.py:127
PlotCalibFromCool.begin
begin
Definition: PlotCalibFromCool.py:94
TrigConf::ConstIter::m_f
std::function< T(const typename V::value_type &)> m_f
Function to turn a single datum from the container into the output type.
Definition: ConstIter.h:94
x
#define x
trigbs_dumpPrescaleBits.HLTChain
HLTChain
Definition: trigbs_dumpPrescaleBits.py:41
mergePhysValFiles.end
end
Definition: DataQuality/DataQualityUtils/scripts/mergePhysValFiles.py:93
lumiFormat.i
int i
Definition: lumiFormat.py:92
python.DecayParser.buf
buf
print ("=> [%s]"cmd)
Definition: DecayParser.py:27
ptree
boost::property_tree::ptree ptree
Definition: JsonFileLoader.cxx:16
python.copyTCTOutput.chains
chains
Definition: copyTCTOutput.py:81
python.PyAthena.v
v
Definition: PyAthena.py:157
TrigConf::ConstIter::m_bufIt
V::const_iterator m_bufIt
Iterator over the container.
Definition: ConstIter.h:95
convertTimingResiduals.offset
offset
Definition: convertTimingResiduals.py:71
TrigConf::ConstIter::m_data
CxxUtils::CachedValue< T > m_data
Holder of the transformed data.
Definition: ConstIter.h:93