Public Types | Public Member Functions | Protected Types | Protected Member Functions | Private Types | Private Member Functions | Private Attributes | List of all members
geo::details::wire_id_iterator_base< GEOID > Class Template Reference

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

#include <GeometryCore.h>

Inheritance diagram for geo::details::wire_id_iterator_base< GEOID >:
geo::details::plane_id_iterator_base< GEOID > geo::details::TPC_id_iterator_base< GEOID > geo::details::cryostat_id_iterator_base< GEOID > geo::details::geometry_iterator_base geo::details::geometry_iterator_types

Public Types

using ElementPtr_t = geo::WireGeo const *
 
using GeoID_t = typename upper_iterator::GeoID_t
 
using LocalID_t = geo::WireID
 type of the ID we change More...
 
using iterator = wire_id_iterator_base< 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::input_iterator_tag
 

Public Member Functions

 wire_id_iterator_base ()
 Default constructor; effect not defined: assign to it before using! More...
 
 wire_id_iterator_base (geo::GeometryCore const *geom)
 Constructor: points to begin. More...
 
 wire_id_iterator_base (geo::GeometryCore const *geom, GeoID_t const &start_from)
 Constructor: points to the specified wire. More...
 
 wire_id_iterator_base (geo::GeometryCore const *geom, BeginPos_t const)
 Constructor: points to begin. More...
 
 wire_id_iterator_base (geo::GeometryCore const *geom, EndPos_t)
 Constructor: points to end. More...
 
template<typename OTHERID >
bool operator== (wire_id_iterator_base< OTHERID > const &as) const
 Returns true if the two iterators point to the same wire. More...
 
template<typename OTHERID >
bool operator!= (wire_id_iterator_base< OTHERID > const &as) const
 Returns true if the two iterators point to different wires. More...
 
reference operator* () const
 Returns the WireID the iterator points to. More...
 
pointer operator-> () const
 Returns the WireID the iterator points to. More...
 
iteratoroperator++ ()
 Prefix increment: returns this iterator pointing to the next wire. More...
 
iterator operator++ (int)
 Postfix increment: returns the current iterator, then increments it. More...
 
 operator bool () const
 Returns whether the iterator is pointing to a valid wire. More...
 
ElementPtr_t get () const
 Returns a pointer to wire, or nullptr if invalid. More...
 

Protected Types

using ID_t = typename LocalID_t::WireID_t
 specific type for wire ID More...
 
- Protected Types inherited from geo::details::plane_id_iterator_base< GEOID >
using ID_t = typename LocalID_t::PlaneID_t
 specific type for plane ID More...
 
using ElementPtr_t = geo::PlaneGeo const *
 
using GeoID_t = typename upper_iterator::GeoID_t
 
using LocalID_t = geo::PlaneID
 type of the ID we change More...
 
using iterator = plane_id_iterator_base< GeoID_t >
 type of this iterator More...
 
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::input_iterator_tag
 
- Protected Types inherited from geo::details::TPC_id_iterator_base< GEOID >
using ID_t = typename LocalID_t::TPCID_t
 specific type for TPC ID More...
 
using ElementPtr_t = geo::TPCGeo const *
 
using GeoID_t = typename upper_iterator::GeoID_t
 
using LocalID_t = geo::TPCID
 type of the ID we change More...
 
using iterator = TPC_id_iterator_base< GeoID_t >
 type of this iterator More...
 
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::input_iterator_tag
 
- Protected Types inherited from geo::details::cryostat_id_iterator_base< GEOID >
using ID_t = typename LocalID_t::CryostatID_t
 
using ElementPtr_t = geo::CryostatGeo const *
 
using GeoID_t = GEOID
 type of the actual ID stored in the iterator More...
 
using iterator = cryostat_id_iterator_base< GeoID_t >
 this iterator More...
 
using LocalID_t = geo::CryostatID
 type of the ID we change More...
 
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::input_iterator_tag
 

Protected Member Functions

 wire_id_iterator_base (geo::GeometryCore const *geom, UndefinedPos_t)
 Constructor: position undefined (meaning undefined local limits too) More...
 
LocalID_t const & localID () const
 Returns the type of ID we act on. More...
 
void next ()
 Skips to the next wire. More...
 
ID_t const & local_index () const
 Returns the index (part if the ID) this iterator runs on. More...
 
- Protected Member Functions inherited from geo::details::plane_id_iterator_base< GEOID >
 plane_id_iterator_base (geo::GeometryCore const *geom, UndefinedPos_t)
 Constructor: position undefined (meaning undefined local limits too) More...
 
LocalID_t const & localID () const
 Returns the type of ID we act on. More...
 
void next ()
 Skips to the next plane. More...
 
ID_t const & local_index () const
 Returns the index (part if the ID) this iterator runs on. More...
 
 plane_id_iterator_base ()
 Default constructor; effect not defined: assign to it before using! More...
 
 plane_id_iterator_base (geo::GeometryCore const *geom)
 Constructor: points to begin. More...
 
 plane_id_iterator_base (geo::GeometryCore const *geom, GeoID_t const &start_from)
 Constructor: points to the specified plane. More...
 
 plane_id_iterator_base (geo::GeometryCore const *geom, BeginPos_t const)
 Constructor: points to begin. More...
 
 plane_id_iterator_base (geo::GeometryCore const *geom, EndPos_t)
 Constructor: points to end. More...
 
template<typename OTHERID >
bool operator== (plane_id_iterator_base< OTHERID > const &as) const
 Returns true if the two iterators point to the same plane. More...
 
template<typename OTHERID >
bool operator!= (plane_id_iterator_base< OTHERID > const &as) const
 Returns true if the two iterators point to different planes. More...
 
reference operator* () const
 Returns the PlaneID the iterator points to. More...
 
pointer operator-> () const
 Returns the PlaneID the iterator points to. More...
 
iteratoroperator++ ()
 Prefix increment: returns this iterator pointing to the next plane. More...
 
iterator operator++ (int)
 Postfix increment: returns the current iterator, then increments it. More...
 
 operator bool () const
 Returns whether the iterator is pointing to a valid plane. More...
 
ElementPtr_t get () const
 Returns a pointer to plane, or nullptr if invalid. More...
 
- Protected Member Functions inherited from geo::details::TPC_id_iterator_base< GEOID >
 TPC_id_iterator_base (geo::GeometryCore const *geom, UndefinedPos_t)
 Constructor: position undefined (meaning undefined local limits too) More...
 
LocalID_t const & localID () const
 Returns the type of ID we act on. More...
 
void next ()
 Skips to the next TPC. More...
 
ID_t const & local_index () const
 Returns the index (part if the ID) this iterator runs on. More...
 
 TPC_id_iterator_base ()
 Default constructor; effect not defined: assign to it before using! More...
 
 TPC_id_iterator_base (geo::GeometryCore const *geom)
 Constructor: points to begin. More...
 
 TPC_id_iterator_base (geo::GeometryCore const *geom, GeoID_t const &start_from)
 Constructor: points to the specified TPC. More...
 
 TPC_id_iterator_base (geo::GeometryCore const *geom, BeginPos_t const)
 Constructor: points to begin. More...
 
 TPC_id_iterator_base (geo::GeometryCore const *geom, EndPos_t)
 Constructor: points to end. More...
 
template<typename OTHERID >
bool operator== (TPC_id_iterator_base< OTHERID > const &as) const
 Returns true if the two iterators point to the same TPC. More...
 
template<typename OTHERID >
bool operator!= (TPC_id_iterator_base< OTHERID > const &as) const
 Returns true if the two iterators point to different TPCs. More...
 
reference operator* () const
 Returns the TPCID the iterator points to. More...
 
pointer operator-> () const
 Returns the TPCID the iterator points to. More...
 
iteratoroperator++ ()
 Prefix increment: returns this iterator pointing to the next TPC. More...
 
iterator operator++ (int)
 Postfix increment: returns the current iterator, then increments it. More...
 
 operator bool () const
 Returns whether the iterator is pointing to a valid TPC. More...
 
ElementPtr_t get () const
 Returns a pointer to TPC, or nullptr if invalid. More...
 
- Protected Member Functions inherited from geo::details::cryostat_id_iterator_base< GEOID >
 cryostat_id_iterator_base (geo::GeometryCore const *geom, UndefinedPos_t)
 Constructor: does not set the current ID. More...
 
void next ()
 Skips to the next cryostat. More...
 
bool at_end () const
 Returns whether this iterator has reached the end. More...
 
GeoID_t const & ID () const
 Returns the actual type of ID we store. More...
 
GeoID_tID ()
 
 cryostat_id_iterator_base ()
 Default constructor; effect not defined: assign to it before using! More...
 
 cryostat_id_iterator_base (geo::GeometryCore const *geom)
 Constructor: points to begin. More...
 
 cryostat_id_iterator_base (geo::GeometryCore const *geom, GeoID_t const &start_from)
 Constructor: points to the specified cryostat. More...
 
 cryostat_id_iterator_base (geo::GeometryCore const *geom, BeginPos_t const)
 Constructor: points to begin. More...
 
 cryostat_id_iterator_base (geo::GeometryCore const *geom, EndPos_t)
 Constructor: points to end. More...
 
template<typename OTHERID >
bool operator== (cryostat_id_iterator_base< OTHERID > const &as) const
 Returns true if the two iterators point to the same cryostat. More...
 
template<typename OTHERID >
bool operator!= (cryostat_id_iterator_base< OTHERID > const &as) const
 Returns true if the two iterators point to different cryostats. More...
 
reference operator* () const
 Returns the ID the iterator points to. More...
 
pointer operator-> () const
 Returns a pointer to the ID the iterator points to. More...
 
iteratoroperator++ ()
 Prefix increment: returns this iterator pointing to the next cryostat. More...
 
iterator operator++ (int)
 Postfix increment: returns the current iterator, then increments it. More...
 
 operator bool () const
 Returns whether the iterator is pointing to a valid cryostat. More...
 
ElementPtr_t get () const
 Returns a pointer to cryostat, or nullptr if invalid. More...
 
- Protected Member Functions inherited from geo::details::geometry_iterator_base
geo::GeometryCore const * geometry () const
 Returns a pointer to the geometry. More...
 
 geometry_iterator_base ()
 Default constructor; do not use a default-constructed iterator as-is! More...
 
 geometry_iterator_base (geo::GeometryCore const *geom)
 Constructor: associates with the specified geometry. More...
 

Private Types

using upper_iterator = plane_id_iterator_base< GEOID >
 

Private Member Functions

void set_local_limits ()
 Sets limit to the past-the-end wire number of current plane. More...
 
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

ID_t limit = LocalID_t::InvalidID
 maximum number of wires in the current plane More...
 

Detailed Description

template<typename GEOID>
class geo::details::wire_id_iterator_base< GEOID >

Base forward iterator browsing all wire IDs in the detector.

Template Parameters
GEOIDID type to be used

This iterator requires that GEOID is derived from geo::WireID. 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 WireID 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 587 of file GeometryCore.h.

Member Typedef Documentation

template<typename GEOID>
using geo::details::wire_id_iterator_base< GEOID >::difference_type = std::ptrdiff_t

Definition at line 617 of file GeometryCore.h.

template<typename GEOID>
using geo::details::wire_id_iterator_base< GEOID >::ElementPtr_t = geo::WireGeo const*

Definition at line 594 of file GeometryCore.h.

template<typename GEOID>
using geo::details::wire_id_iterator_base< GEOID >::GeoID_t = typename upper_iterator::GeoID_t

Definition at line 595 of file GeometryCore.h.

template<typename GEOID>
using geo::details::wire_id_iterator_base< GEOID >::ID_t = typename LocalID_t::WireID_t
protected

specific type for wire ID

Definition at line 679 of file GeometryCore.h.

template<typename GEOID>
using geo::details::wire_id_iterator_base< GEOID >::iterator = wire_id_iterator_base<GeoID_t>

type of this iterator

Definition at line 602 of file GeometryCore.h.

template<typename GEOID>
using geo::details::wire_id_iterator_base< GEOID >::iterator_category = std::input_iterator_tag

Definition at line 621 of file GeometryCore.h.

template<typename GEOID>
using geo::details::wire_id_iterator_base< GEOID >::LocalID_t = geo::WireID

type of the ID we change

Definition at line 597 of file GeometryCore.h.

template<typename GEOID>
using geo::details::wire_id_iterator_base< GEOID >::pointer = value_type const*

Definition at line 620 of file GeometryCore.h.

template<typename GEOID>
using geo::details::wire_id_iterator_base< GEOID >::reference = value_type const&

Definition at line 619 of file GeometryCore.h.

template<typename GEOID>
using geo::details::wire_id_iterator_base< GEOID >::upper_iterator = plane_id_iterator_base<GEOID>
private

Definition at line 591 of file GeometryCore.h.

template<typename GEOID>
using geo::details::wire_id_iterator_base< GEOID >::value_type = LocalID_t

Definition at line 618 of file GeometryCore.h.

Constructor & Destructor Documentation

template<typename GEOID>
geo::details::wire_id_iterator_base< GEOID >::wire_id_iterator_base ( )
inline

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

Definition at line 626 of file GeometryCore.h.

626 {}
template<typename GEOID>
geo::details::wire_id_iterator_base< GEOID >::wire_id_iterator_base ( geo::GeometryCore const *  geom)
inline

Constructor: points to begin.

Definition at line 629 of file GeometryCore.h.

629  :
static constexpr BeginPos_t begin_pos
Definition: GeometryCore.h:107
wire_id_iterator_base()
Default constructor; effect not defined: assign to it before using!
Definition: GeometryCore.h:626
template<typename GEOID>
geo::details::wire_id_iterator_base< GEOID >::wire_id_iterator_base ( geo::GeometryCore const *  geom,
GeoID_t const &  start_from 
)
inline

Constructor: points to the specified wire.

Definition at line 634 of file GeometryCore.h.

634  :
635  upper_iterator(geom, start_from)
636  { set_local_limits(); }
plane_id_iterator_base< GEOID > upper_iterator
Definition: GeometryCore.h:591
void set_local_limits()
Sets limit to the past-the-end wire number of current plane.
template<typename GEOID>
geo::details::wire_id_iterator_base< GEOID >::wire_id_iterator_base ( geo::GeometryCore const *  geom,
BeginPos_t  const 
)
inline

Constructor: points to begin.

Definition at line 639 of file GeometryCore.h.

639  :
641  { set_local_limits(); }
static constexpr BeginPos_t begin_pos
Definition: GeometryCore.h:107
plane_id_iterator_base< GEOID > upper_iterator
Definition: GeometryCore.h:591
void set_local_limits()
Sets limit to the past-the-end wire number of current plane.
template<typename GEOID>
geo::details::wire_id_iterator_base< GEOID >::wire_id_iterator_base ( geo::GeometryCore const *  geom,
EndPos_t   
)
inline

Constructor: points to end.

Definition at line 644 of file GeometryCore.h.

644  :
645  upper_iterator(geom, end_pos)
646  {} // the local limit is ill-defined and left invalid
static constexpr EndPos_t end_pos
Definition: GeometryCore.h:108
plane_id_iterator_base< GEOID > upper_iterator
Definition: GeometryCore.h:591
template<typename GEOID>
geo::details::wire_id_iterator_base< GEOID >::wire_id_iterator_base ( geo::GeometryCore const *  geom,
UndefinedPos_t   
)
inlineprotected

Constructor: position undefined (meaning undefined local limits too)

Definition at line 682 of file GeometryCore.h.

682  :
684  {}
static constexpr UndefinedPos_t undefined_pos
Definition: GeometryCore.h:109
plane_id_iterator_base< GEOID > upper_iterator
Definition: GeometryCore.h:591

Member Function Documentation

template<typename GEOID >
auto geo::details::wire_id_iterator_base< GEOID >::get ( ) const
inline

Returns a pointer to wire, or nullptr if invalid.

Definition at line 5952 of file GeometryCore.h.

CryostatGeo const * GetElementPtr(geo::CryostatID const &cryoid) const
geo::GeometryCore const * geometry() const
Returns a pointer to the geometry.
Definition: GeometryCore.h:123
LocalID_t const & localID() const
Returns the type of ID we act on.
Definition: GeometryCore.h:689
template<typename GEOID>
ID_t const& geo::details::wire_id_iterator_base< GEOID >::local_index ( ) const
inlineprotected

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

Definition at line 698 of file GeometryCore.h.

698 { return localID().Wire; }
WireID_t Wire
Index of the wire within its plane.
Definition: geo_types.h:580
LocalID_t const & localID() const
Returns the type of ID we act on.
Definition: GeometryCore.h:689
template<typename GEOID>
ID_t& geo::details::wire_id_iterator_base< GEOID >::local_index ( )
inlineprivate

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

Definition at line 712 of file GeometryCore.h.

712 { return localID().Wire; }
WireID_t Wire
Index of the wire within its plane.
Definition: geo_types.h:580
LocalID_t const & localID() const
Returns the type of ID we act on.
Definition: GeometryCore.h:689
template<typename GEOID>
LocalID_t const& geo::details::wire_id_iterator_base< GEOID >::localID ( ) const
inlineprotected

Returns the type of ID we act on.

Definition at line 689 of file GeometryCore.h.

690  { return static_cast<LocalID_t const&>(upper_iterator::ID()); }
GeoID_t const & ID() const
Returns the actual type of ID we store.
Definition: GeometryCore.h:235
geo::WireID LocalID_t
type of the ID we change
Definition: GeometryCore.h:597
template<typename GEOID>
LocalID_t& geo::details::wire_id_iterator_base< GEOID >::localID ( )
inlineprivate

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

Definition at line 709 of file GeometryCore.h.

709 { return static_cast<LocalID_t&>(ID()); }
GeoID_t const & ID() const
Returns the actual type of ID we store.
Definition: GeometryCore.h:235
geo::WireID LocalID_t
type of the ID we change
Definition: GeometryCore.h:597
template<typename GEOID >
void geo::details::wire_id_iterator_base< GEOID >::next ( )
inlineprotected

Skips to the next wire.

Definition at line 5963 of file GeometryCore.h.

5963  {
5964  // if at end (checked in the inherited context), do nothing
5965  if (upper_iterator::at_end()) return;
5966 
5967  // if after incrementing we haven't reached the limit, we are done
5968  if (++local_index() < limit) return;
5969 
5970  // we reached the end of the current elements list, we need to escalate:
5971  // - go to the next parent; if that becomes invalid, too bad, but we go on
5973  // - set the index to the first element of the new parent
5974  local_index() = 0;
5975  // - update how many elements there are
5976  // (expect 0 if it is now at_end() -- and it does not even matter)
5977  set_local_limits();
5978 } // geo::details::wire_id_iterator_base<>::next()
void next()
Skips to the next plane.
ID_t limit
maximum number of wires in the current plane
Definition: GeometryCore.h:703
void set_local_limits()
Sets limit to the past-the-end wire number of current plane.
bool at_end() const
Returns whether this iterator has reached the end.
Definition: GeometryCore.h:243
ID_t const & local_index() const
Returns the index (part if the ID) this iterator runs on.
Definition: GeometryCore.h:698
template<typename GEOID >
geo::details::wire_id_iterator_base< GEOID >::operator bool ( ) const
inline

Returns whether the iterator is pointing to a valid wire.

Definition at line 5946 of file GeometryCore.h.

5946  {
5947  return upper_iterator::geometry()
5949 } // geo::details::wire_id_iterator_base<>::operator bool()
geo::GeometryCore const * geometry() const
Returns a pointer to the geometry.
Definition: GeometryCore.h:123
bool HasElement(geo::CryostatID const &cryoid) const
LocalID_t const & localID() const
Returns the type of ID we act on.
Definition: GeometryCore.h:689
template<typename GEOID>
template<typename OTHERID >
bool geo::details::wire_id_iterator_base< GEOID >::operator!= ( wire_id_iterator_base< OTHERID > const &  as) const
inline

Returns true if the two iterators point to different wires.

Definition at line 656 of file GeometryCore.h.

657  { return localID() != as.localID(); }
static constexpr double as
Definition: Units.h:101
LocalID_t const & localID() const
Returns the type of ID we act on.
Definition: GeometryCore.h:689
template<typename GEOID>
reference geo::details::wire_id_iterator_base< GEOID >::operator* ( ) const
inline

Returns the WireID the iterator points to.

Definition at line 660 of file GeometryCore.h.

660 { return localID(); }
LocalID_t const & localID() const
Returns the type of ID we act on.
Definition: GeometryCore.h:689
template<typename GEOID>
iterator& geo::details::wire_id_iterator_base< GEOID >::operator++ ( )
inline

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

Definition at line 666 of file GeometryCore.h.

666 { next(); return *this; }
void next()
Skips to the next wire.
template<typename GEOID>
iterator geo::details::wire_id_iterator_base< GEOID >::operator++ ( int  )
inline

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

Definition at line 669 of file GeometryCore.h.

669 { iterator old(*this); next(); return old; }
void next()
Skips to the next wire.
template<typename GEOID>
pointer geo::details::wire_id_iterator_base< GEOID >::operator-> ( ) const
inline

Returns the WireID the iterator points to.

Definition at line 663 of file GeometryCore.h.

663 { return &(localID()); }
LocalID_t const & localID() const
Returns the type of ID we act on.
Definition: GeometryCore.h:689
template<typename GEOID>
template<typename OTHERID >
bool geo::details::wire_id_iterator_base< GEOID >::operator== ( wire_id_iterator_base< OTHERID > const &  as) const
inline

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

Definition at line 651 of file GeometryCore.h.

652  { return localID() == as.localID(); }
static constexpr double as
Definition: Units.h:101
LocalID_t const & localID() const
Returns the type of ID we act on.
Definition: GeometryCore.h:689
template<typename GEOID >
void geo::details::wire_id_iterator_base< GEOID >::set_local_limits ( )
inlineprivate

Sets limit to the past-the-end wire number of current plane.

Definition at line 5957 of file GeometryCore.h.

5957  {
5958  // limit is how many sibling wires there are
5960 } // geo::details::wire_id_iterator_base<>::set_local_limits()
geo::GeometryCore const * geometry() const
Returns a pointer to the geometry.
Definition: GeometryCore.h:123
unsigned int NSiblingElements(geo::CryostatID const &) const
LocalID_t const & localID() const
Returns the type of ID we act on.
Definition: GeometryCore.h:689
ID_t limit
maximum number of wires in the current plane
Definition: GeometryCore.h:703

Member Data Documentation

template<typename GEOID>
ID_t geo::details::wire_id_iterator_base< GEOID >::limit = LocalID_t::InvalidID
private

maximum number of wires in the current plane

Definition at line 703 of file GeometryCore.h.


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