1 #ifndef LARCOREALG_GEOMETRY_DETAILS_ID_ITERATORS_H 2 #define LARCOREALG_GEOMETRY_DETAILS_ID_ITERATORS_H 16 template <
typename ID>
21 template <
typename ID>
24 template <
typename ID>
25 std::ostream& operator<<(std::ostream& out, id_sentinel<ID>
const& sentinel)
27 return out <<
"id_sentinel{ " << sentinel.
id <<
" }";
40 template <
typename LocalID,
typename GEOID,
typename IterationPolicy>
43 template <
typename GEOID,
typename IterationPolicy>
46 struct GeometryIDIteratorTag {};
52 static_assert(std::is_base_of<LocalID_t, GEOID>{},
"template type GEOID is not a LocalID_t");
68 :
id{start_from}, limit{policy.NSiblings(localID())}
99 if (++local_index() < limit)
return;
109 bool at_end()
const {
return local_index() == limit; }
113 ID_t limit = LocalID_t::InvalidID;
121 ID_t const& local_index()
const {
return localID().deepestIndex(); }
142 template <
typename LocalID,
typename GEOID,
typename IterationPolicy>
144 :
protected id_iterator_base<typename LocalID::ParentID_t, GEOID, IterationPolicy> {
152 static_assert(std::is_base_of<LocalID_t, GEOID>{},
"template type GEOID is not a LocalID_t");
171 :
upper_iterator{start_from, itPolicy}, policy{itPolicy}, limit(policy.NSiblings(localID()))
200 if (upper_iterator::at_end())
return;
203 if (++local_index() < limit)
return;
207 upper_iterator::next();
212 limit = policy.NSiblings(localID());
218 using ID_t = std::decay_t<
219 decltype(std::declval<LocalID_t>().deepestIndex())>;
222 ID_t limit = LocalID_t::InvalidID;
232 template <
typename LocalID,
typename SiblingPolicy>
235 template <
typename LocalID,
typename SiblingPolicy>
236 auto iterator_for(LocalID
const&
id, SiblingPolicy
const& siblingPolicy)
242 template <
typename T,
typename =
void>
245 template <
typename T>
249 template <
typename GEOIT>
254 return out <<
"geometry_iterator{ " << *it <<
" }";
257 template <
typename ID,
typename Policy>
259 static constexpr
bool check(
unsigned int (
Policy::*)(ID
const&)
const) {
return true; }
260 static constexpr
bool check(...) {
return false; }
265 template <
typename ID,
typename IterationPolicy>
270 if (++
id.deepestIndex() < policy.NSiblings(
id))
return;
273 id.deepestIndex() = 0;
284 template <
typename GeoID,
typename IterationPolicy>
285 GeoID
GetNextID(GeoID
const&
id, IterationPolicy
const& policy)
293 template <
typename LocalID,
typename GeoID,
typename IterationPolicy>
300 template <
typename LocalID,
typename GeoID,
typename IterationPolicy>
307 template <
typename LocalID,
typename GeoID,
typename IterationPolicy>
314 template <
typename LocalID,
typename GeoID,
typename IterationPolicy>
321 template <
typename LocalID,
typename GeoID,
typename IterationPolicy>
328 template <
typename LocalID,
typename GeoID,
typename IterationPolicy>
335 template <
typename LocalID>
341 template <
typename LocalID>
349 #endif // LARCOREALG_GEOMETRY_DETAILS_ID_ITERATORS_H IDparameter< geo::CryostatID > CryostatID
Member type of validated geo::CryostatID parameter.
id_iterator_base(GeoID_t const &start_from, IterationPolicy itPolicy)
Constructor: points to the specified element.
iterator & operator++()
Prefix increment: returns this iterator pointing to the next cryostat.
std::forward_iterator_tag iterator_category
Classes identifying readout-related concepts.
LocalID_t const & localID() const
Base forward iterator browsing all cryostat IDs in the detector.
void IncrementID(ID &id, IterationPolicy const &policy)
iterator operator++(int)
Postfix increment: returns the current iterator, then increments it.
std::ptrdiff_t difference_type
Policy
Enumeration of all supported random seed policies.
ID_t & local_index()
Returns the index (part if the ID) this iterator runs on.
bool operator==(geometry_element_iterator< Owner, Element, GEOIDITER > const &a, geometry_element_iterator< Owner, Element, GEOIDITER > const &b)
value_type const * pointer
id_iterator_base(GeoID_t const &start_from, IterationPolicy policy)
Constructor: points to the specified cryostat.
LocalID_t const & localID() const
LocalID_t & localID()
Returns the type of ID we act on.
value_type const & reference
std::decay_t< decltype(std::declval< LocalID_t >().deepestIndex())> ID_t
specific type for element ID
void next()
Skips to the next element.
value_type const & reference
std::ostream & operator<<(std::ostream &out, id_sentinel< ID > const &sentinel)
reference operator*() const
Returns the ID the iterator points to.
GeoID_t & ID()
Returns the actual type of ID we store.
id_sentinel(ID) -> id_sentinel< ID >
std::forward_iterator_tag iterator_category
auto iterator_for(LocalID const &id, SiblingPolicy const &siblingPolicy)
std::ptrdiff_t difference_type
Definition of data types for geometry description.
bool at_end() const
Returns whether this iterator has reached the end.
LocalID LocalID_t
type of the ID we change
bool operator!=(geometry_element_iterator< Owner, Element, GEOIDITER > const &a, geometry_element_iterator< Owner, Element, GEOIDITER > const &b)
iterator operator++(int)
Postfix increment: returns the current iterator, then increments it.
reference operator*() const
Returns the element ID the iterator points to.
static constexpr bool check(unsigned int(Policy::*)(ID const &) const)
unsigned int CryostatID_t
Type for the ID number.
value_type const * pointer
Stream output for all geometry ID iterator types: prints the pointed ID.
pointer operator->() const
ID_t const & local_index() const
Returns the index (part if the ID) this iterator runs on.
typename upper_iterator::GeoID_t GeoID_t
static constexpr bool check(...)
void next()
Skips to the next cryostat.
GeoID GetNextID(GeoID const &id, IterationPolicy const &policy)
Returns the ID next to the specified one.
typename LocalID_t::CryostatID_t ID_t
pointer operator->() const
GEOID GeoID_t
type of the actual ID stored in the iterator
The data type to uniquely identify a cryostat.
iterator & operator++()
Prefix increment: returns this iterator pointing to the next element.