4 #include <experimental/array>
5 #include <SimoxUtility/meta/eigen.h>
6 #include <boost/hana/adapt_struct.hpp>
8 #include <boost/preprocessor/seq/for_each.hpp>
9 #include <boost/preprocessor/variadic/to_seq.hpp>
15 template <
typename T,
typename =
void>
18 static constexpr
auto value = [](
auto ...t)
20 return std::experimental::make_array<T>(std::forward<decltype(t)>(t)...);
26 static constexpr
auto value = [](
auto ...t)
28 return std::experimental::make_array<float>(std::forward<decltype(t)>(t)...);
36 #define _detail_AX_MK_CFG_rem_paren(...) __VA_ARGS__
39 #define _detail_AX_MK_CFG_t0(e0, ...) e0
41 #define _detail_AX_MK_CFG_tail(e0, ...) __VA_ARGS__
43 #define _detail_AX_MK_CFG_applicator_i2(m, ...) m(__VA_ARGS__)
44 #define _detail_AX_MK_CFG_applicator_i1(...) \
45 _detail_AX_MK_CFG_applicator_i2(__VA_ARGS__)
48 #define _detail_AX_MK_CFG_applicator(r, tup, elem) \
49 _detail_AX_MK_CFG_applicator_i1( \
50 _detail_AX_MK_CFG_t0 tup, \
52 _detail_AX_MK_CFG_tail tup, \
53 _detail_AX_MK_CFG_rem_paren elem \
60 #define _detail_AX_MK_CFG_appl_FOR_EACH(stype, elemmacro, ...) \
61 BOOST_PP_SEQ_FOR_EACH( \
62 _detail_AX_MK_CFG_applicator, \
64 BOOST_PP_VARIADIC_TO_SEQ(__VA_ARGS__) \
70 #define _detail_AX_MK_CFG_member_def(R, sname, type, vname, ...) type vname;
71 #define _detail_AX_MK_CFG_struct_def(Namespace, Name, ...) \
77 _detail_AX_MK_CFG_appl_FOR_EACH( \
79 _detail_AX_MK_CFG_member_def, \
83 Name(Name&&) = default; \
84 Name(const Name&) = default; \
85 Name& operator=(Name&&) = default; \
86 Name& operator=(const Name&) = default; \
88 } static_assert(true, "force the usage of a trailing semicolon")
90 #define _detail_AX_MK_CFG_ctor_def(Namespace, Name, ...) \
95 armarx::meta::cfg::struct_default<Name>::set(*this); \
97 } static_assert(true, "force the usage of a trailing semicolon")
101 #define ARMARX_CONFIG_STRUCT_CONFIGURE(Namespace, Name, ...) \
102 namespace armarx::meta::cfg \
105 _detail_AX_MK_CFG_appl_FOR_EACH( \
107 _detail_AX_MK_CFG_cfg_elem, \
110 } static_assert(true, "force the usage of a trailing semicolon")
113 #define _detail_AX_MK_CFG_cfg_elem_app_i4(sname, type, vname, m, ...) \
114 m(sname, type, vname, __VA_ARGS__)
116 #define _detail_AX_MK_CFG_cfg_elem_app_i3(...) \
117 _detail_AX_MK_CFG_cfg_elem_app_i4(__VA_ARGS__)
119 #define _detail_AX_MK_CFG_cfg_elem_app_i2(sname, type, vname, ...) \
120 _detail_AX_MK_CFG_cfg_elem_app_i3( \
121 sname, type, vname, \
122 _detail_AX_MK_CFG_cfg_elem_app_ ## __VA_ARGS__)
124 #define _detail_AX_MK_CFG_cfg_elem_app_i1(...) \
125 _detail_AX_MK_CFG_cfg_elem_app_i2(__VA_ARGS__)
128 #define _detail_AX_MK_CFG_cfg_elem_app(r, tup, elem) \
129 _detail_AX_MK_CFG_cfg_elem_app_i1( \
130 _detail_AX_MK_CFG_rem_paren tup, \
137 #define _detail_AX_MK_CFG_DEFER(x) x BOOST_PP_EMPTY()
138 #define _detail_AX_MK_CFG_SEQ_FOR_EACH_R_ID() BOOST_PP_SEQ_FOR_EACH_R
140 #define _detail_AX_MK_CFG_cfg_elem(R, sname, type, vname, ...) \
141 _detail_AX_MK_CFG_DEFER(_detail_AX_MK_CFG_SEQ_FOR_EACH_R_ID)()( \
142 R, _detail_AX_MK_CFG_cfg_elem_app, (sname, type, vname), \
143 BOOST_PP_VARIADIC_TO_SEQ(__VA_ARGS__) \
147 #define _detail_AX_MK_CFG_cfg_elem_app_AX_DEFAULT(...) \
148 _detail_AX_MK_CFG_cfg_elem_app_AX_DEFAULT_i, __VA_ARGS__
150 #define _detail_AX_MK_CFG_cfg_elem_app_AX_DEFAULT_i(sname, type, vname, ...) \
152 struct element_default<sname, type, &sname::vname> : std::true_type \
156 return type(__VA_ARGS__); \
158 static void set(sname& s) \
165 #define _detail_AX_MK_CFG_cfg_elem_app_(...)
168 #define _detail_AX_MK_CFG_cfg_elem_app_AX_MIN(...) \
169 _detail_AX_MK_CFG_cfg_elem_app_AX_MIN_i, __VA_ARGS__
171 #define _detail_AX_MK_CFG_cfg_elem_app_AX_MIN_i(sname, type, vname, ...) \
172 template<> constexpr auto element_min<sname, type, &sname::vname> = \
173 armarx::meta::detail::make_array<type>::value(__VA_ARGS__);
176 #define _detail_AX_MK_CFG_cfg_elem_app_AX_MAX(...) \
177 _detail_AX_MK_CFG_cfg_elem_app_AX_MAX_i, __VA_ARGS__
179 #define _detail_AX_MK_CFG_cfg_elem_app_AX_MAX_i(sname, type, vname, ...) \
180 template<> constexpr auto element_max<sname, type, &sname::vname> = \
181 armarx::meta::detail::make_array<type>::value(__VA_ARGS__);
184 #define _detail_AX_MK_CFG_cfg_elem_app_AX_DESCRIPTION(...) \
185 _detail_AX_MK_CFG_cfg_elem_app_AX_DESCRIPTION_i, __VA_ARGS__
187 #define _detail_AX_MK_CFG_cfg_elem_app_AX_DESCRIPTION_i(sname, type, vname, ...)\
188 template<> constexpr const char* \
189 element_description<sname, type, &sname::vname> = __VA_ARGS__;
192 #define _detail_AX_MK_CFG_cfg_elem_app_AX_PROPERTY_NAME(...) \
193 _detail_AX_MK_CFG_cfg_elem_app_AX_PROP_NAME_i, __VA_ARGS__
195 #define _detail_AX_MK_CFG_cfg_elem_app_AX_PROP_NAME_i(sname, type, vname, ...) \
196 template<> constexpr const char* \
197 element_property_name<sname, type, &sname::vname> = __VA_ARGS__;
200 #define _detail_AX_MK_CFG_cfg_elem_app_AX_DECIMALS(...) \
201 _detail_AX_MK_CFG_cfg_elem_app_AX_DECIMALS_i, __VA_ARGS__
203 #define _detail_AX_MK_CFG_cfg_elem_app_AX_DECIMALS_i(sname, type, vname, ...) \
204 template<> constexpr auto element_decimals<sname, type, &sname::vname> = \
205 std::experimental::make_array<int>(__VA_ARGS__);
208 #define _detail_AX_MK_CFG_cfg_elem_app_AX_STEPS(...) \
209 _detail_AX_MK_CFG_cfg_elem_app_AX_STEPS_i, __VA_ARGS__
211 #define _detail_AX_MK_CFG_cfg_elem_app_AX_STEPS_i(sname, type, vname, ...) \
212 template<> constexpr auto element_steps<sname, type, &sname::vname> = \
213 std::experimental::make_array<int>(__VA_ARGS__);
216 #define _detail_AX_MK_CFG_cfg_elem_app_AX_LABEL(...) \
217 _detail_AX_MK_CFG_cfg_elem_app_AX_LABEL_i, __VA_ARGS__
219 #define _detail_AX_MK_CFG_cfg_elem_app_AX_LABEL_i(sname, type, vname, ...) \
220 template<> constexpr const char* \
221 element_label<sname, type, &sname::vname> = {__VA_ARGS__};
224 #define _detail_AX_MK_CFG_cfg_elem_app_AX_NO_PROPERTY(...) \
225 _detail_AX_MK_CFG_cfg_elem_app_AX_NO_PROPERTY_i, __VA_ARGS__
227 #define _detail_AX_MK_CFG_cfg_elem_app_AX_NO_PROPERTY_i(sname, type, vname, ...)\
228 template<> constexpr std::true_type \
229 element_no_prop<sname, type, &sname::vname> = {};
231 #define _detail_AX_MK_CFG_cfg_elem_app_AX_NO_REMOTE_GUI(...) \
232 _detail_AX_MK_CFG_cfg_elem_app_AX_NO_REMOTE_GUI_i, __VA_ARGS__
234 #define _detail_AX_MK_CFG_cfg_elem_app_AX_NO_REMOTE_GUI_i(sname, type, vname, ...) \
235 template<> constexpr std::true_type \
236 element_no_rem_gui<sname, type, &sname::vname> = {};
238 #define _detail_AX_MK_CFG_cfg_elem_app_AX_EXCLUDE_FROM_ALL(...) \
239 _detail_AX_MK_CFG_cfg_elem_app_AX_EXCLUDE_FROM_ALL_i, __VA_ARGS__
241 #define _detail_AX_MK_CFG_cfg_elem_app_AX_EXCLUDE_FROM_ALL_i(sname, type, vname, ...) \
242 template<> constexpr std::true_type \
243 element_no_prop<sname, type, &sname::vname> = {}; \
244 template<> constexpr std::true_type \
245 element_no_rem_gui<sname, type, &sname::vname> = {}; \
249 #define _detail_AX_MK_CFG_member_names(R, sname, type, name, ...) , name
250 #define ARMARX_CONFIG_STRUCT_ADAPT(Namespace, Name, ...) \
251 BOOST_HANA_ADAPT_STRUCT( \
253 _detail_AX_MK_CFG_appl_FOR_EACH( \
255 _detail_AX_MK_CFG_member_names, \
268 #define ARMARX_CONFIG_STRUCT_DEFINE_ADAPT(Namespace, Name, ...) \
269 _detail_AX_MK_CFG_struct_def (Namespace, Name, __VA_ARGS__); \
270 ARMARX_CONFIG_STRUCT_ADAPT (Namespace, Name, __VA_ARGS__); \
271 _detail_AX_MK_CFG_ctor_def (Namespace, Name, __VA_ARGS__)
280 #define ARMARX_CONFIG_STRUCT_DEFINE_ADAPT_CONFIGURE(Namespace, Name, ...) \
281 ARMARX_CONFIG_STRUCT_DEFINE_ADAPT(Namespace, Name, __VA_ARGS__); \
282 ARMARX_CONFIG_STRUCT_CONFIGURE (Namespace, Name, __VA_ARGS__)
291 #define ARMARX_CONFIG_STRUCT_CONFIGURE_ADAPT(Namespace, Name, ...) \
292 ARMARX_CONFIG_STRUCT_ADAPT (Namespace, Name, __VA_ARGS__); \
293 ARMARX_CONFIG_STRUCT_CONFIGURE(Namespace, Name, __VA_ARGS__)
295 #define ARMARX_CONFIG_STRUCT_ADAPT_CONFIGURE(Namespace, Name, ...) \
296 ARMARX_CONFIG_STRUCT_CONFIGURE_ADAPT(Namespace, Name, __VA_ARGS__)