LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
geometry_iterator_maker.h
Go to the documentation of this file.
1 #ifndef LARCOREALG_GEOMETRY_DETAILS_GEOMETRY_ITERATOR_MAKER_H
2 #define LARCOREALG_GEOMETRY_DETAILS_GEOMETRY_ITERATOR_MAKER_H
3 
6 
7 #include <type_traits>
8 
9 namespace geo::details {
10  template <typename BaseID, typename GeoID>
11  static constexpr bool is_base_of_strict{std::is_base_of<BaseID, GeoID>{} &&
12  !std::is_same<BaseID, GeoID>{}};
13 
14  template <typename T, typename = void>
15  struct IteratorMaker {
16  using ID_t = typename T::ID_t;
20 
21  template <typename Geom>
22  static begin_type create_begin(Geom const* geom)
23  {
24  return {geom, id_iterator<ID_t>{geom, geom->template GetBeginID<ID_t>()}};
25  }
26 
27  template <typename Geom>
28  static end_type create_end(Geom const* geom)
29  {
30  return {geom, id_iterator<ID_t>{geom, geom->template GetEndID<ID_t>()}};
31  }
32 
33  template <typename Geom>
34  static range_type create_range(Geom const* geom)
35  {
36  return {create_begin(geom), create_end(geom)};
37  }
38 
39  template <typename Geom, typename BaseID>
40  static begin_type create_begin(Geom const* geom, BaseID const& id)
41  {
42  static_assert(is_base_of_strict<BaseID, ID_t>);
43  return {geom, id_iterator<ID_t>{geom, geom->template GetBeginID<ID_t>(id)}};
44  }
45 
46  template <typename Geom, typename BaseID>
47  static end_type create_end(Geom const* geom, BaseID const& id)
48  {
49  static_assert(is_base_of_strict<BaseID, ID_t>);
50  return {geom, id_iterator<ID_t>{geom, geom->template GetEndID<ID_t>(id)}};
51  }
52 
53  template <typename Geom, typename BaseID>
54  static range_type create_range(Geom const* geom, BaseID const& id)
55  {
56  return {create_begin(geom, id), create_end(geom, id)};
57  }
58  };
59 
60  template <typename T>
61  struct IteratorMaker<T, std::enable_if_t<std::is_base_of_v<CryostatID, T>>> {
65 
66  template <typename Geom>
67  static begin_type create_begin(Geom const* geom)
68  {
69  return {geom, geom->template GetBeginID<T>()};
70  }
71 
72  template <typename Geom>
73  static end_type create_end(Geom const* geom)
74  {
75  return {geom, geom->template GetEndID<T>()};
76  }
77 
78  template <typename Geom>
79  static range_type create_range(Geom const* geom)
80  {
81  return {create_begin(geom), create_end(geom)};
82  }
83 
84  template <typename Geom, typename BaseID>
85  static begin_type create_begin(Geom const* geom, BaseID const& id)
86  {
87  static_assert(is_base_of_strict<BaseID, T>);
88  return {geom, geom->template GetBeginID<T>(id)};
89  }
90 
91  template <typename Geom, typename BaseID>
92  static end_type create_end(Geom const* geom, BaseID const& id)
93  {
94  static_assert(is_base_of_strict<BaseID, T>);
95  return {geom, geom->template GetEndID<T>(id)};
96  }
97 
98  template <typename Geom, typename BaseID>
99  static range_type create_range(Geom const* geom, BaseID const& id)
100  {
101  return {create_begin(geom, id), create_end(geom, id)};
102  }
103  };
104 
105  template <typename T>
107 
108  template <typename T>
110 
111  template <typename T>
113 }
114 
115 #endif /* LARCOREALG_GEOMETRY_DETAILS_GEOMETRY_ITERATOR_MAKER_H */
An object with a begin and end iterator.
Base forward iterator browsing all cryostat IDs in the detector.
STL namespace.
Simple class with a begin and an end.
Definition: span.h:129
static end_type create_end(Geom const *geom)
static end_type create_end(Geom const *geom, BaseID const &id)
typename IteratorMaker< T >::begin_type begin_type
static begin_type create_begin(Geom const *geom)
static constexpr bool is_base_of_strict
static range_type create_range(Geom const *geom, BaseID const &id)
typename IteratorMaker< T >::end_type end_type
static begin_type create_begin(Geom const *geom, BaseID const &id)
Forward iterator browsing all geometry elements in the detector.
typename IteratorMaker< T >::range_type range_type
static range_type create_range(Geom const *geom)