LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
geo::details::id_iterator_base< LocalID, GEOID > Class Template Reference

Base forward iterator browsing all cryostat IDs in the detector. More...

#include "geometry_iterators.h"

Public Types

using GeoID_t = typename upper_iterator::GeoID_t
 
using LocalID_t = LocalID
 type of the ID we change More...
 
using iterator = id_iterator_base< LocalID_t, GeoID_t >
 type of this iterator More...
 
Iterator traits
using difference_type = std::ptrdiff_t
 
using value_type = LocalID_t
 
using reference = value_type const &
 
using pointer = value_type const *
 
using iterator_category = std::forward_iterator_tag
 

Public Member Functions

 id_iterator_base ()=default
 Default constructor; effect not defined: assign to it before using! More...
 
 id_iterator_base (GeometryCore const *geo, GeoID_t const &start_from)
 Constructor: points to the specified element. More...
 
bool operator== (id_iterator_base const &as) const
 Returns true if the two iterators point to the same element. More...
 
bool operator!= (id_iterator_base const &as) const
 Returns true if the two iterators point to different elements. More...
 
reference operator* () const
 Returns the element ID the iterator points to. More...
 
pointer operator-> () const
 Returns the element ID the iterator points to. More...
 
iteratoroperator++ ()
 Prefix increment: returns this iterator pointing to the next element. More...
 
iterator operator++ (int)
 Postfix increment: returns the current iterator, then increments it. More...
 

Protected Types

using ID_t = std::remove_reference_t< decltype(std::declval< LocalID_t >().deepestIndex())>
 specific type for element ID More...
 

Protected Member Functions

LocalID_t const & localID () const
 Returns the type of ID we act on. More...
 
void next ()
 Skips to the next element. More...
 
ID_t const & local_index () const
 Returns the index (part if the ID) this iterator runs on. More...
 

Private Types

using upper_iterator = id_iterator_base< typename LocalID::ParentID_t, GEOID >
 

Private Member Functions

LocalID_tlocalID ()
 Returns the type of ID we act on (non-const version) More...
 
ID_tlocal_index ()
 Returns the index (part if the ID) this iterator runs on (non-const) More...
 

Private Attributes

geo::GeometryCore const * geom
 
ID_t limit = LocalID_t::InvalidID
 maximum number of elements in the current cryostat More...
 

Detailed Description

template<typename LocalID, typename GEOID>
class geo::details::id_iterator_base< LocalID, GEOID >

Base forward iterator browsing all cryostat IDs in the detector.

Base forward iterator browsing all TPC IDs in the detector.

Template Parameters
GEOIDID type to be used

This iterator assumes that GEOID is derived from geo::CryostatID. Note that no polymorphic behaviour is required, or expected, from GEOID.

This iterator is designed to carry on, untouched, anything else that the GEOID type defines beyond the required CryostatID data.

Currently, backward iterations are not supported.

Template Parameters
GEOIDID type to be used

This iterator requires that GEOID is derived from geo::TPCID. Note that no polymorphic behaviour is required, or expected, from GEOID.

This iterator is designed to carry on, untouched, anything else that the GEOID type defines beyond the required TPCID data.

Note
A number of "local" methods are overloaded: since there is no polymorphism here and they are not virtual functions, these are designed not to replace the inherited methods except within the non-inherited and explicitly redefined methods.

Currently, backward iterations are not supported.

Definition at line 48 of file geometry_iterators.h.

Member Typedef Documentation

template<typename LocalID , typename GEOID >
using geo::details::id_iterator_base< LocalID, GEOID >::difference_type = std::ptrdiff_t

Definition at line 171 of file geometry_iterators.h.

template<typename LocalID , typename GEOID >
using geo::details::id_iterator_base< LocalID, GEOID >::GeoID_t = typename upper_iterator::GeoID_t

Definition at line 162 of file geometry_iterators.h.

template<typename LocalID , typename GEOID >
using geo::details::id_iterator_base< LocalID, GEOID >::ID_t = std::remove_reference_t< decltype(std::declval<LocalID_t>().deepestIndex())>
protected

specific type for element ID

Definition at line 218 of file geometry_iterators.h.

template<typename LocalID , typename GEOID >
using geo::details::id_iterator_base< LocalID, GEOID >::iterator = id_iterator_base<LocalID_t, GeoID_t>

type of this iterator

Definition at line 167 of file geometry_iterators.h.

template<typename LocalID , typename GEOID >
using geo::details::id_iterator_base< LocalID, GEOID >::iterator_category = std::forward_iterator_tag

Definition at line 175 of file geometry_iterators.h.

template<typename LocalID , typename GEOID >
using geo::details::id_iterator_base< LocalID, GEOID >::LocalID_t = LocalID

type of the ID we change

Definition at line 164 of file geometry_iterators.h.

template<typename LocalID , typename GEOID >
using geo::details::id_iterator_base< LocalID, GEOID >::pointer = value_type const*

Definition at line 174 of file geometry_iterators.h.

template<typename LocalID , typename GEOID >
using geo::details::id_iterator_base< LocalID, GEOID >::reference = value_type const&

Definition at line 173 of file geometry_iterators.h.

template<typename LocalID , typename GEOID >
using geo::details::id_iterator_base< LocalID, GEOID >::upper_iterator = id_iterator_base<typename LocalID::ParentID_t, GEOID>
private

Definition at line 159 of file geometry_iterators.h.

template<typename LocalID , typename GEOID >
using geo::details::id_iterator_base< LocalID, GEOID >::value_type = LocalID_t

Definition at line 172 of file geometry_iterators.h.

Constructor & Destructor Documentation

template<typename LocalID , typename GEOID >
geo::details::id_iterator_base< LocalID, GEOID >::id_iterator_base ( )
default

Default constructor; effect not defined: assign to it before using!

template<typename LocalID , typename GEOID >
geo::details::id_iterator_base< LocalID, GEOID >::id_iterator_base ( GeometryCore const *  geo,
GeoID_t const &  start_from 
)
inline

Constructor: points to the specified element.

Definition at line 182 of file geometry_iterators.h.

References geo::details::NSiblings().

183  : upper_iterator{geo, start_from}, geom{geo}, limit(NSiblings(geom, localID()))
184  {}
id_iterator_base< typename LocalID::ParentID_t, GEOID > upper_iterator
unsigned int NSiblings(GeometryCore const *geom, CryostatID const &id)
Definition: helpers.cxx:6
LocalID_t const & localID() const
Returns the type of ID we act on.
ID_t limit
maximum number of elements in the current cryostat
geo::GeometryCore const * geom
Namespace collecting geometry-related classes utilities.

Member Function Documentation

template<typename LocalID , typename GEOID >
ID_t const& geo::details::id_iterator_base< LocalID, GEOID >::local_index ( ) const
inlineprotected

Returns the index (part if the ID) this iterator runs on.

Definition at line 240 of file geometry_iterators.h.

240 { return localID().deepestIndex(); }
LocalID_t const & localID() const
Returns the type of ID we act on.
template<typename LocalID , typename GEOID >
ID_t& geo::details::id_iterator_base< LocalID, GEOID >::local_index ( )
inlineprivate

Returns the index (part if the ID) this iterator runs on (non-const)

Definition at line 251 of file geometry_iterators.h.

251 { return localID().deepestIndex(); }
LocalID_t const & localID() const
Returns the type of ID we act on.
template<typename LocalID , typename GEOID >
LocalID_t const& geo::details::id_iterator_base< LocalID, GEOID >::localID ( ) const
inlineprotected
template<typename LocalID , typename GEOID >
LocalID_t& geo::details::id_iterator_base< LocalID, GEOID >::localID ( )
inlineprivate

Returns the type of ID we act on (non-const version)

Definition at line 248 of file geometry_iterators.h.

248 { return upper_iterator::ID(); }
template<typename LocalID , typename GEOID >
void geo::details::id_iterator_base< LocalID, GEOID >::next ( )
inlineprotected

Skips to the next element.

Definition at line 221 of file geometry_iterators.h.

References geo::details::NSiblings().

222  {
223  // if at end (checked in the inherited context), do nothing
224  if (upper_iterator::at_end()) return;
225 
226  // if after incrementing we haven't reached the limit, we are done
227  if (++local_index() < limit) return;
228 
229  // we reached the end of the current elements list, we need to escalate:
230  // - go to the next parent; if that becomes invalid, too bad, but we go on
232  // - set the index to the first element of the new parent
233  local_index() = 0;
234  // - update how many elements there are
235  // (expect 0 if it is now at_end() -- and it does not even matter)
236  limit = NSiblings(geom, localID());
237  }
ID_t const & local_index() const
Returns the index (part if the ID) this iterator runs on.
unsigned int NSiblings(GeometryCore const *geom, CryostatID const &id)
Definition: helpers.cxx:6
LocalID_t const & localID() const
Returns the type of ID we act on.
ID_t limit
maximum number of elements in the current cryostat
void next()
Skips to the next element.
geo::GeometryCore const * geom
template<typename LocalID , typename GEOID >
bool geo::details::id_iterator_base< LocalID, GEOID >::operator!= ( id_iterator_base< LocalID, GEOID > const &  as) const
inline

Returns true if the two iterators point to different elements.

Definition at line 190 of file geometry_iterators.h.

References geo::operator==().

190 { return !operator==(as); }
bool operator==(id_iterator_base const &as) const
Returns true if the two iterators point to the same element.
template<typename LocalID , typename GEOID >
reference geo::details::id_iterator_base< LocalID, GEOID >::operator* ( ) const
inline

Returns the element ID the iterator points to.

Definition at line 193 of file geometry_iterators.h.

193 { return localID(); }
LocalID_t const & localID() const
Returns the type of ID we act on.
template<typename LocalID , typename GEOID >
iterator& geo::details::id_iterator_base< LocalID, GEOID >::operator++ ( )
inline

Prefix increment: returns this iterator pointing to the next element.

Definition at line 199 of file geometry_iterators.h.

200  {
201  next();
202  return *this;
203  }
void next()
Skips to the next element.
template<typename LocalID , typename GEOID >
iterator geo::details::id_iterator_base< LocalID, GEOID >::operator++ ( int  )
inline

Postfix increment: returns the current iterator, then increments it.

Definition at line 206 of file geometry_iterators.h.

207  {
208  iterator old(*this);
209  next();
210  return old;
211  }
void next()
Skips to the next element.
template<typename LocalID , typename GEOID >
pointer geo::details::id_iterator_base< LocalID, GEOID >::operator-> ( ) const
inline

Returns the element ID the iterator points to.

Definition at line 196 of file geometry_iterators.h.

196 { return &(localID()); }
LocalID_t const & localID() const
Returns the type of ID we act on.
template<typename LocalID , typename GEOID >
bool geo::details::id_iterator_base< LocalID, GEOID >::operator== ( id_iterator_base< LocalID, GEOID > const &  as) const
inline

Returns true if the two iterators point to the same element.

Definition at line 187 of file geometry_iterators.h.

References geo::details::id_iterator_base< LocalID, GEOID >::localID().

187 { return localID() == as.localID(); }
LocalID_t const & localID() const
Returns the type of ID we act on.

Member Data Documentation

template<typename LocalID , typename GEOID >
geo::GeometryCore const* geo::details::id_iterator_base< LocalID, GEOID >::geom
private

Definition at line 243 of file geometry_iterators.h.

template<typename LocalID , typename GEOID >
ID_t geo::details::id_iterator_base< LocalID, GEOID >::limit = LocalID_t::InvalidID
private

maximum number of elements in the current cryostat

Definition at line 245 of file geometry_iterators.h.


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