7 #ifndef CALORECGPU_CALOGPUCLUSTERANDCELLDATAMONITOROPTIONS_H
8 #define CALORECGPU_CALOGPUCLUSTERANDCELLDATAMONITOROPTIONS_H
19 #include <type_traits>
25 #include "GaudiKernel/StatusCode.h"
27 #include <Gaudi/Parsers/Factory.h>
49 template<
class T>
inline static constexpr
51 template<
class T>
inline static constexpr
54 template <
class T>
inline static constexpr
57 template<
class T>
inline static constexpr
59 template<
class T>
inline static constexpr
61 template <
class T>
inline static constexpr
62 bool to_tuple_exists = std::is_pointer_v<decltype( to_tuple_checker<T>(
nullptr) )>;
64 template<
class T>
inline static constexpr
66 template<
class T>
inline static constexpr
68 template <
class T>
inline static constexpr
71 template<
class T>
inline static constexpr
73 template<
class T>
inline static constexpr
75 template <
class T>
inline static constexpr
78 inline constexpr
static bool value = tuple_type_exists<Check> && to_tuple_exists<Check> && from_tuple_exists<Check> && tuple_size_exists<Check>;
96 #define CALORECGPU_VARSB_APPENDER(THIS, PREFIX, IGNORE) , CRGPU_CONCAT(PREFIX, THIS)
97 #define CALORECGPU_VARSB_ASSIGNER(THIS, IGNORE1, IGNORE2) tuple_safe_copy(CRGPU_CONCAT(b, THIS), CRGPU_CONCAT(a, THIS));
99 #define CALORECGPU_VARSB_ENCAPSULATOR_A(...) CRGPU_MACRO_EXPANSION(CALORECGPU_VARSB_APPENDER, a, __VA_ARGS__ )
100 #define CALORECGPU_VARSB_ENCAPSULATOR_B(...) CRGPU_MACRO_EXPANSION(CALORECGPU_VARSB_APPENDER, b, __VA_ARGS__ )
102 #define CALORECGPU_VARSB_ENCAPSULATOR_ASSIGN(...) CRGPU_MACRO_EXPANSION(CALORECGPU_VARSB_ASSIGNER, _ , __VA_ARGS__, )
105 #define CALORECGPU_VARSB_EXPANDER(THIS_NUM, IGNORE, SMALLER_NUMS) \
106 template <> struct struct_tuple_conversion<THIS_NUM> \
108 template <class T, class TupleT> \
109 static void s2t(const T & t, TupleT & tup) \
111 const auto & [CRGPU_CONCAT(a, THIS_NUM) CALORECGPU_VARSB_ENCAPSULATOR_A SMALLER_NUMS] = t; \
112 auto & [CRGPU_CONCAT(b, THIS_NUM) CALORECGPU_VARSB_ENCAPSULATOR_B SMALLER_NUMS] = tup; \
113 tuple_safe_copy(CRGPU_CONCAT(b, THIS_NUM), CRGPU_CONCAT(a, THIS_NUM)); \
114 CALORECGPU_VARSB_ENCAPSULATOR_ASSIGN SMALLER_NUMS \
116 template <class TupleT, class T> \
117 static void t2s(const TupleT & tup, T & t) \
119 const auto & [CRGPU_CONCAT(a, THIS_NUM) CALORECGPU_VARSB_ENCAPSULATOR_A SMALLER_NUMS] = tup; \
120 auto & [CRGPU_CONCAT(b, THIS_NUM) CALORECGPU_VARSB_ENCAPSULATOR_B SMALLER_NUMS] = t; \
121 tuple_safe_copy(CRGPU_CONCAT(b, THIS_NUM), CRGPU_CONCAT(a, THIS_NUM)); \
122 CALORECGPU_VARSB_ENCAPSULATOR_ASSIGN SMALLER_NUMS \
133 template <
class T,
class TupleT>
134 static void s2t(
const T &, TupleT &) { }
135 template <
class T,
class TupleT>
136 static T
t2s(
const TupleT &, T &) { }
139 CRGPU_RECURSIVE_MACRO(
CRGPU_MACRO_EXPANSION(
CALORECGPU_VARSB_EXPANDER,
_, 9, 8, 7, 6, 5, 4, 3, 2, 1))
143 std::enable_if_t<
impl::class_can_be_tuple_v<T>>* =
nullptr>
150 std::enable_if_t< impl::class_can_be_tuple_v<T>>* =
nullptr>
157 std::enable_if_t< impl::class_can_be_tuple_v<T>>* =
nullptr>
158 void tuple_safe_copy(std::vector<typename T::TupleType> & t_v,
const std::vector<T> & s_v)
160 t_v.resize(s_v.size());
161 for (
size_t i = 0;
i < s_v.size(); ++
i)
168 std::enable_if_t< impl::class_can_be_tuple_v<T>>* =
nullptr>
169 void tuple_safe_copy(std::vector<T> & s_v,
const std::vector<typename T::TupleType> & t_v)
171 s_v.resize(t_v.size());
172 for (
size_t i = 0;
i < t_v.size(); ++
i)
193 std::enable_if_t< impl::class_can_be_tuple_v<T>>* =
nullptr>
196 return std::vector<typename T::TupleType> {};
216 inline static constexpr
size_t TupleSize =
sizeof...(Elems);
241 template <
class Stream,
class T>
248 template <
class Stream,
class T>
252 for (
size_t i = 0;
i <
v.size(); ++
i)
277 template <
typename Iterator,
typename Skipper,
class T>
278 struct Grammar_< Iterator,
T, Skipper,
typename std::enable_if_t < impl::class_can_be_tuple_v<T> > >
280 using Grammar =
typename Grammar_<Iterator, typename T::TupleType, Skipper>::Grammar;
283 template <
class ... Tup>
286 return parse_(tup,
input);
298 template <
class ... Tup>
299 std::ostream &
operator<<(std::ostream &
s,
const std::tuple<Tup...> & tup )
317 std::enable_if_t< impl::class_can_be_tuple_v<T>>* =
nullptr>
320 return s << T::to_tuple(
t);
346 #define CALORECGPU_OPTIONCLASS_CONSTRUCTORS(CLASSNAME) \
347 CLASSNAME() = default; \
348 CLASSNAME(const TupleType & t) \
350 (*this) = from_tuple(t); \
383 #endif //CALORECGPU_CALOGPUCLUSTERANDCELLDATAMONITOROPTIONS_H