LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
geo::details::geometry_element_iterator< Element, GEOIDITER > Class Template Reference

Forward iterator browsing all geometry elements in the detector. More...

#include "geometry_iterators.h"

Public Types

using id_iterator_t = GEOIDITER
 
using iterator = geometry_element_iterator< Element, id_iterator_t >
 this type More...
 
Types mirrored from the ID iterator
using LocalID_t = typename id_iterator_t::LocalID_t
 
using GeoID_t = typename id_iterator_t::GeoID_t
 
using ElementPtr_t = Element const *
 
Iterator traits
using difference_type = std::ptrdiff_t
 
using value_type = Element
 
using reference = value_type const &
 
using pointer = value_type const *
 
using iterator_category = std::forward_iterator_tag
 

Public Member Functions

 geometry_element_iterator ()=default
 Default constructor; effect not defined: assign to it before using! More...
 
 geometry_element_iterator (GeometryCore const *geo, id_iterator_t const &iter)
 Constructor: points to the same element as the specified ID iterator. More...
 
 geometry_element_iterator (GeometryCore const *geo, id_iterator_t &&iter)
 Constructor: points to the same element as the specified ID iterator. More...
 
 geometry_element_iterator (GeometryCore const *geo, GeoID_t const &start_from)
 Constructor: points to the specified geometry element. More...
 
bool operator== (iterator const &as) const
 Returns true if the two iterators point to the same object. More...
 
bool operator!= (iterator const &as) const
 Returns true if the two iterators point to different objects. More...
 
reference operator* () const
 Returns the geometry element the iterator points to. More...
 
pointer operator-> () const
 Returns a pointer to the element the iterator points to (or nullptr) 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...
 
 operator bool () const
 Returns whether the iterator is pointing to a valid geometry element. More...
 
ElementPtr_t get () const
 Returns a pointer to the geometry element, or nullptr if invalid. More...
 
LocalID_t const & ID () const
 Returns the ID of the pointed geometry element. More...
 

Private Attributes

geo::GeometryCore const * geom
 
id_iterator_t id_iterator
 

Detailed Description

template<typename Element, typename GEOIDITER>
class geo::details::geometry_element_iterator< Element, GEOIDITER >

Forward iterator browsing all geometry elements in the detector.

Template Parameters
GEOITERtype of geometry ID iterator

This iterator works as the corresponding ID iterator in the template argument. The difference is the dereferenciation operator: this one obtains the geometry element directly, or throws on failure. The boolean conversion operator checks that it can obtain a pointer to the geometry element.

In particular, get() and ID() methods still return the pointer to the geometry element and its ID, respectively.

It can also be initialized and compare with the corresponding ID iterator.

Definition at line 283 of file geometry_iterators.h.

Member Typedef Documentation

template<typename Element , typename GEOIDITER >
using geo::details::geometry_element_iterator< Element, GEOIDITER >::difference_type = std::ptrdiff_t

Definition at line 302 of file geometry_iterators.h.

template<typename Element , typename GEOIDITER >
using geo::details::geometry_element_iterator< Element, GEOIDITER >::ElementPtr_t = Element const*

Definition at line 297 of file geometry_iterators.h.

template<typename Element , typename GEOIDITER >
using geo::details::geometry_element_iterator< Element, GEOIDITER >::GeoID_t = typename id_iterator_t::GeoID_t

Definition at line 296 of file geometry_iterators.h.

template<typename Element , typename GEOIDITER >
using geo::details::geometry_element_iterator< Element, GEOIDITER >::id_iterator_t = GEOIDITER

Definition at line 285 of file geometry_iterators.h.

template<typename Element , typename GEOIDITER >
using geo::details::geometry_element_iterator< Element, GEOIDITER >::iterator = geometry_element_iterator<Element, id_iterator_t>

this type

Definition at line 291 of file geometry_iterators.h.

template<typename Element , typename GEOIDITER >
using geo::details::geometry_element_iterator< Element, GEOIDITER >::iterator_category = std::forward_iterator_tag

Definition at line 306 of file geometry_iterators.h.

template<typename Element , typename GEOIDITER >
using geo::details::geometry_element_iterator< Element, GEOIDITER >::LocalID_t = typename id_iterator_t::LocalID_t

Definition at line 295 of file geometry_iterators.h.

template<typename Element , typename GEOIDITER >
using geo::details::geometry_element_iterator< Element, GEOIDITER >::pointer = value_type const*

Definition at line 305 of file geometry_iterators.h.

template<typename Element , typename GEOIDITER >
using geo::details::geometry_element_iterator< Element, GEOIDITER >::reference = value_type const&

Definition at line 304 of file geometry_iterators.h.

template<typename Element , typename GEOIDITER >
using geo::details::geometry_element_iterator< Element, GEOIDITER >::value_type = Element

Definition at line 303 of file geometry_iterators.h.

Constructor & Destructor Documentation

template<typename Element , typename GEOIDITER >
geo::details::geometry_element_iterator< Element, GEOIDITER >::geometry_element_iterator ( )
default

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

template<typename Element , typename GEOIDITER >
geo::details::geometry_element_iterator< Element, GEOIDITER >::geometry_element_iterator ( GeometryCore const *  geo,
id_iterator_t const &  iter 
)
inline

Constructor: points to the same element as the specified ID iterator.

Definition at line 313 of file geometry_iterators.h.

314  : geom{geo}, id_iterator(iter)
315  {}
Namespace collecting geometry-related classes utilities.
template<typename Element , typename GEOIDITER >
geo::details::geometry_element_iterator< Element, GEOIDITER >::geometry_element_iterator ( GeometryCore const *  geo,
id_iterator_t &&  iter 
)
inline

Constructor: points to the same element as the specified ID iterator.

Definition at line 318 of file geometry_iterators.h.

319  : geom{geo}, id_iterator(iter)
320  {}
Namespace collecting geometry-related classes utilities.
template<typename Element , typename GEOIDITER >
geo::details::geometry_element_iterator< Element, GEOIDITER >::geometry_element_iterator ( GeometryCore const *  geo,
GeoID_t const &  start_from 
)
inline

Constructor: points to the specified geometry element.

Definition at line 323 of file geometry_iterators.h.

324  : geom{geo}, id_iterator(geom, start_from)
325  {}
Namespace collecting geometry-related classes utilities.

Member Function Documentation

template<typename Element , typename GEOIDITER >
ElementPtr_t geo::details::geometry_element_iterator< Element, GEOIDITER >::get ( ) const
inline

Returns a pointer to the geometry element, or nullptr if invalid.

Definition at line 369 of file geometry_iterators.h.

References geo::details::getElementPtr().

369 { return getElementPtr(geom, *id_iterator); }
CryostatGeo const * getElementPtr(GeometryCore const *geom, CryostatID const &id)
Definition: helpers.cxx:36
template<typename Element , typename GEOIDITER >
LocalID_t const& geo::details::geometry_element_iterator< Element, GEOIDITER >::ID ( ) const
inline

Returns the ID of the pointed geometry element.

Definition at line 372 of file geometry_iterators.h.

template<typename Element , typename GEOIDITER >
geo::details::geometry_element_iterator< Element, GEOIDITER >::operator bool ( ) const
inline

Returns whether the iterator is pointing to a valid geometry element.

Definition at line 366 of file geometry_iterators.h.

References geo::details::validElement().

366 { return validElement(geom, *id_iterator); }
bool validElement(GeometryCore const *geom, CryostatID const &id)
Definition: helpers.cxx:60
template<typename Element , typename GEOIDITER >
bool geo::details::geometry_element_iterator< Element, GEOIDITER >::operator!= ( iterator const &  as) const
inline

Returns true if the two iterators point to different objects.

Definition at line 331 of file geometry_iterators.h.

References geo::details::geometry_element_iterator< Element, GEOIDITER >::id_iterator.

331 { return id_iterator != as.id_iterator; }
template<typename Element , typename GEOIDITER >
reference geo::details::geometry_element_iterator< Element, GEOIDITER >::operator* ( ) const
inline

Returns the geometry element the iterator points to.

Returns
a constant reference to the element the iterator points to
Exceptions
cet::exception(category "geometry_iterator") if no valid geometry element is currently pointed by the iterator

Definition at line 339 of file geometry_iterators.h.

340  {
341  ElementPtr_t ptr = get();
342  if (ptr) return *ptr;
343  throw cet::exception("geometry_iterator")
344  << "iterator attempted to obtain geometry element " << std::string(ID());
345  } // operator*()
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
LocalID_t const & ID() const
Returns the ID of the pointed geometry element.
template<typename Element , typename GEOIDITER >
iterator& geo::details::geometry_element_iterator< Element, GEOIDITER >::operator++ ( )
inline

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

Definition at line 351 of file geometry_iterators.h.

352  {
353  ++id_iterator;
354  return *this;
355  }
template<typename Element , typename GEOIDITER >
iterator geo::details::geometry_element_iterator< Element, GEOIDITER >::operator++ ( int  )
inline

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

Definition at line 358 of file geometry_iterators.h.

359  {
360  iterator old(*this);
361  ++id_iterator;
362  return old;
363  }
template<typename Element , typename GEOIDITER >
pointer geo::details::geometry_element_iterator< Element, GEOIDITER >::operator-> ( ) const
inline

Returns a pointer to the element the iterator points to (or nullptr)

Definition at line 348 of file geometry_iterators.h.

348 { return get(); }
template<typename Element , typename GEOIDITER >
bool geo::details::geometry_element_iterator< Element, GEOIDITER >::operator== ( iterator const &  as) const
inline

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

Definition at line 328 of file geometry_iterators.h.

References geo::details::geometry_element_iterator< Element, GEOIDITER >::id_iterator.

328 { return id_iterator == as.id_iterator; }

Member Data Documentation

template<typename Element , typename GEOIDITER >
geo::GeometryCore const* geo::details::geometry_element_iterator< Element, GEOIDITER >::geom
private

Definition at line 375 of file geometry_iterators.h.


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