config_struct_details.h
Go to the documentation of this file.
1#pragma once
2
3#include <boost/hana/for_each.hpp>
4
5#include "../trace.h"
6#include "common.h"
7
8//fwd
9namespace armarx::meta::cfg
10{
11 template <class CL, class MT, MT CL::*ptr>
12 struct element_default;
13}
14
15//possible details
16namespace armarx::meta::cfg
17{
18 template <class CL, class MT, MT CL::*ptr>
20
21 template <class T>
23
24 template <class CL, class = void>
25 struct struct_default : std::false_type
26 {
27 static const CL&
29 {
30 static const CL cl;
31 return cl;
32 }
33
34 static void
35 set(CL& cl)
36 {
37 cl = get();
38 }
39 };
40
41 template <class CL>
42 struct struct_default<CL, std::enable_if_t<simox::meta::has_hana_accessor_v<CL>>> :
43 std::false_type
44 {
45 private:
46 template <class VarName, class MT, MT CL::*ptr>
47 static void
48 DoSetElement(
49 const boost::hana::pair<VarName,
50 boost::hana::struct_detail::member_ptr<MT CL::*, ptr>>&,
51 CL& val)
52 {
54 {
56 }
57 }
58
59 public:
60 static void
61 set(CL& cl)
62 {
63 static constexpr auto accessors = boost::hana::accessors<CL>();
64 boost::hana::for_each(accessors,
65 [&](auto& e)
66 {
68 DoSetElement(e, cl);
69 });
70 }
71
72 static const CL&
74 {
75 static const CL cl;
76 set(cl);
77 return cl;
78 }
79 };
80} // namespace armarx::meta::cfg
::simox::meta::undefined_t undefined_t
Definition common.h:17
#define ARMARX_TRACE_LITE
Definition trace.h:98