Public Types | Public Member Functions | Private Attributes | Friends | List of all members
gar::geo::details::geometry_element_iterator< GEOIDITER > Class Template Reference

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

#include <GeometryCore.h>

Inheritance diagram for gar::geo::details::geometry_element_iterator< GEOIDITER >:
gar::geo::details::geometry_iterator_types

Public Types

using id_iterator_t = GEOIDITER
 
using iterator = geometry_element_iterator< id_iterator_t >
 this type More...
 
using Element_t = typename std::remove_pointer< ElementPtr_t >::type
 Geometry class pointed by the iterator. More...
 
using LocalID_t = typename id_iterator_t::LocalID_t
 types mirrored from the ID iterator More...
 
using GeoID_t = typename id_iterator_t::GeoID_t
 
using UndefinedPos_t = typename id_iterator_t::UndefinedPos_t
 
using BeginPos_t = typename id_iterator_t::BeginPos_t
 
using EndPos_t = typename id_iterator_t::EndPos_t
 
using ElementPtr_t = typename id_iterator_t::ElementPtr_t
 

Public Member Functions

 geometry_element_iterator ()=default
 Default constructor; effect not defined: assign to it before using! More...
 
 geometry_element_iterator (gar::geo::GeometryCore const *geom)
 Constructor: points to begin. More...
 
 geometry_element_iterator (gar::geo::GeometryCore const *geom, GeoID_t const &start_from)
 Constructor: points to the specified geometry element. More...
 
 geometry_element_iterator (gar::geo::GeometryCore const *geom, BeginPos_t const pos)
 Constructor: points to beginning. More...
 
 geometry_element_iterator (gar::geo::GeometryCore const *geom, EndPos_t const pos)
 Constructor: points to end. 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...
 
Element_t const & operator* () const
 Returns the geometry element the iterator points to. More...
 
Element_t const * 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...
 
 geometry_element_iterator (id_iterator_t const &iter)
 Constructor: points to the same element as the specified ID iterator. More...
 
 geometry_element_iterator (id_iterator_t &&iter)
 

Protected Member Functions

id_iterator_t const & id_iterator () const
 Access to the base ID iterator. More...
 
id_iterator_tid_iterator ()
 

Private Attributes

id_iterator_t id_iter
 iterator performing the job More...
 

Friends

bool geo::details::operator== (iterator const &iter, id_iterator_t const &id_iter)
 
bool geo::details::operator== (id_iterator_t const &id_iter, iterator const &iter)
 
bool geo::details::operator!= (iterator const &iter, id_iterator_t const &id_iter)
 
bool geo::details::operator!= (id_iterator_t const &id_iter, iterator const &iter)
 

Additional Inherited Members

- Static Public Attributes inherited from gar::geo::details::geometry_iterator_types
static constexpr BeginPos_t begin_pos = {}
 
static constexpr EndPos_t end_pos = {}
 
static constexpr UndefinedPos_t undefined_pos = {}
 

Detailed Description

template<typename GEOIDITER>
class gar::geo::details::geometry_element_iterator< 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 192 of file GeometryCore.h.

Member Typedef Documentation

template<typename GEOIDITER>
using gar::geo::details::geometry_element_iterator< GEOIDITER >::BeginPos_t = typename id_iterator_t::BeginPos_t

Definition at line 258 of file GeometryCore.h.

template<typename GEOIDITER>
using gar::geo::details::geometry_element_iterator< GEOIDITER >::Element_t = typename std::remove_pointer<ElementPtr_t>::type

Geometry class pointed by the iterator.

Definition at line 271 of file GeometryCore.h.

template<typename GEOIDITER>
using gar::geo::details::geometry_element_iterator< GEOIDITER >::ElementPtr_t = typename id_iterator_t::ElementPtr_t

Definition at line 260 of file GeometryCore.h.

template<typename GEOIDITER>
using gar::geo::details::geometry_element_iterator< GEOIDITER >::EndPos_t = typename id_iterator_t::EndPos_t

Definition at line 259 of file GeometryCore.h.

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

Definition at line 256 of file GeometryCore.h.

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

Definition at line 243 of file GeometryCore.h.

this type

Definition at line 251 of file GeometryCore.h.

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

types mirrored from the ID iterator

Definition at line 255 of file GeometryCore.h.

template<typename GEOIDITER>
using gar::geo::details::geometry_element_iterator< GEOIDITER >::UndefinedPos_t = typename id_iterator_t::UndefinedPos_t

Definition at line 257 of file GeometryCore.h.

Constructor & Destructor Documentation

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

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

template<typename GEOIDITER>
gar::geo::details::geometry_element_iterator< GEOIDITER >::geometry_element_iterator ( gar::geo::GeometryCore const *  geom)
inline

Constructor: points to begin.

Definition at line 277 of file GeometryCore.h.

278  : id_iter(geom) {}
id_iterator_t id_iter
iterator performing the job
Definition: GeometryCore.h:364
template<typename GEOIDITER>
gar::geo::details::geometry_element_iterator< GEOIDITER >::geometry_element_iterator ( id_iterator_t const &  iter)
inline

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

Definition at line 282 of file GeometryCore.h.

282 : id_iter(iter) {}
id_iterator_t id_iter
iterator performing the job
Definition: GeometryCore.h:364
template<typename GEOIDITER>
gar::geo::details::geometry_element_iterator< GEOIDITER >::geometry_element_iterator ( id_iterator_t &&  iter)
inline

Definition at line 283 of file GeometryCore.h.

283 : id_iter(iter) {}
id_iterator_t id_iter
iterator performing the job
Definition: GeometryCore.h:364
template<typename GEOIDITER>
gar::geo::details::geometry_element_iterator< GEOIDITER >::geometry_element_iterator ( gar::geo::GeometryCore const *  geom,
GeoID_t const &  start_from 
)
inline

Constructor: points to the specified geometry element.

Definition at line 288 of file GeometryCore.h.

289  : id_iter(geom, start_from)
290  {}
id_iterator_t id_iter
iterator performing the job
Definition: GeometryCore.h:364
template<typename GEOIDITER>
gar::geo::details::geometry_element_iterator< GEOIDITER >::geometry_element_iterator ( gar::geo::GeometryCore const *  geom,
BeginPos_t const  pos 
)
inline

Constructor: points to beginning.

Definition at line 294 of file GeometryCore.h.

295  : id_iter(geom, pos)
296  {}
id_iterator_t id_iter
iterator performing the job
Definition: GeometryCore.h:364
template<typename GEOIDITER>
gar::geo::details::geometry_element_iterator< GEOIDITER >::geometry_element_iterator ( gar::geo::GeometryCore const *  geom,
EndPos_t const  pos 
)
inline

Constructor: points to end.

Definition at line 300 of file GeometryCore.h.

301  : id_iter(geom, pos)
302  {}
id_iterator_t id_iter
iterator performing the job
Definition: GeometryCore.h:364

Member Function Documentation

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

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

Definition at line 342 of file GeometryCore.h.

342 { return id_iterator().get(); }
id_iterator_t const & id_iterator() const
Access to the base ID iterator.
Definition: GeometryCore.h:359
template<typename GEOIDITER>
LocalID_t const& gar::geo::details::geometry_element_iterator< GEOIDITER >::ID ( ) const
inline

Returns the ID of the pointed geometry element.

Definition at line 345 of file GeometryCore.h.

345 { return *(id_iterator()); }
id_iterator_t const & id_iterator() const
Access to the base ID iterator.
Definition: GeometryCore.h:359
template<typename GEOIDITER>
id_iterator_t const& gar::geo::details::geometry_element_iterator< GEOIDITER >::id_iterator ( ) const
inlineprotected

Access to the base ID iterator.

Definition at line 359 of file GeometryCore.h.

359 { return id_iter; }
id_iterator_t id_iter
iterator performing the job
Definition: GeometryCore.h:364
template<typename GEOIDITER>
id_iterator_t& gar::geo::details::geometry_element_iterator< GEOIDITER >::id_iterator ( )
inlineprotected

Definition at line 360 of file GeometryCore.h.

360 { return id_iter; }
id_iterator_t id_iter
iterator performing the job
Definition: GeometryCore.h:364
template<typename GEOIDITER>
gar::geo::details::geometry_element_iterator< GEOIDITER >::operator bool ( ) const
inline

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

Definition at line 338 of file GeometryCore.h.

339  { return bool(id_iterator()) && (id_iterator().get() != nullptr); }
id_iterator_t const & id_iterator() const
Access to the base ID iterator.
Definition: GeometryCore.h:359
int bool
Definition: qglobal.h:345
template<typename GEOIDITER>
bool gar::geo::details::geometry_element_iterator< GEOIDITER >::operator!= ( iterator const &  as) const
inline

Returns true if the two iterators point to different objects.

Definition at line 309 of file GeometryCore.h.

310  { return id_iterator() != as.id_iterator(); }
static constexpr double as
Definition: Units.h:101
id_iterator_t const & id_iterator() const
Access to the base ID iterator.
Definition: GeometryCore.h:359
template<typename GEOIDITER>
Element_t const& gar::geo::details::geometry_element_iterator< 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 318 of file GeometryCore.h.

319  {
320  ElementPtr_t ptr = get();
321  if (ptr) return *ptr;
322  throw cet::exception("geometry_iterator")
323  << "iterator attempted to obtain geometry element "
324  << std::string(ID());
325  } // operator*()
std::string string
Definition: nybbler.cc:12
typename id_iterator_t::ElementPtr_t ElementPtr_t
Definition: GeometryCore.h:260
LocalID_t const & ID() const
Returns the ID of the pointed geometry element.
Definition: GeometryCore.h:345
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
template<typename GEOIDITER>
iterator& gar::geo::details::geometry_element_iterator< GEOIDITER >::operator++ ( )
inline

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

Definition at line 331 of file GeometryCore.h.

331 { ++id_iterator(); return *this; }
id_iterator_t const & id_iterator() const
Access to the base ID iterator.
Definition: GeometryCore.h:359
template<typename GEOIDITER>
iterator gar::geo::details::geometry_element_iterator< GEOIDITER >::operator++ ( int  )
inline

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

Definition at line 334 of file GeometryCore.h.

335  { iterator old(*this); ++id_iterator(); return old; }
id_iterator_t const & id_iterator() const
Access to the base ID iterator.
Definition: GeometryCore.h:359
template<typename GEOIDITER>
Element_t const* gar::geo::details::geometry_element_iterator< GEOIDITER >::operator-> ( ) const
inline

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

Definition at line 328 of file GeometryCore.h.

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

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

Definition at line 305 of file GeometryCore.h.

306  { return id_iterator() == as.id_iterator(); }
static constexpr double as
Definition: Units.h:101
id_iterator_t const & id_iterator() const
Access to the base ID iterator.
Definition: GeometryCore.h:359

Friends And Related Function Documentation

template<typename GEOIDITER>
bool geo::details::operator!= ( iterator const &  iter,
id_iterator_t const &  id_iter 
)
friend
template<typename GEOIDITER>
bool geo::details::operator!= ( id_iterator_t const &  id_iter,
iterator const &  iter 
)
friend
template<typename GEOIDITER>
bool geo::details::operator== ( iterator const &  iter,
id_iterator_t const &  id_iter 
)
friend
template<typename GEOIDITER>
bool geo::details::operator== ( id_iterator_t const &  id_iter,
iterator const &  iter 
)
friend

Member Data Documentation

template<typename GEOIDITER>
id_iterator_t gar::geo::details::geometry_element_iterator< GEOIDITER >::id_iter
private

iterator performing the job

Definition at line 364 of file GeometryCore.h.


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