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
9 namespace armarx::meta::cfg
10 {
11  template <class CL, class MT, MT CL::*ptr>
13 }
14 
15 //possible details
16 namespace 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&
28  get()
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&
73  get()
74  {
75  static const CL cl;
76  set(cl);
77  return cl;
78  }
79  };
80 } // namespace armarx::meta::cfg
armarx::meta::cfg::element_default::set
static void set(CL &cl)
Definition: element_details.h:48
armarx::meta::cfg::element_default
Definition: config_struct_details.h:12
armarx::meta::cfg::struct_default< CL, std::enable_if_t< simox::meta::has_hana_accessor_v< CL > > >::set
static void set(CL &cl)
Definition: config_struct_details.h:61
armarx::meta::cfg::struct_default::set
static void set(CL &cl)
Definition: config_struct_details.h:35
armarx::meta::cfg::struct_default< CL, std::enable_if_t< simox::meta::has_hana_accessor_v< CL > > >::get
static const CL & get()
Definition: config_struct_details.h:73
ARMARX_TRACE_LITE
#define ARMARX_TRACE_LITE
Definition: trace.h:98
armarx::meta::cfg
Definition: PluginCfgStruct.h:31
armarx::meta::cfg::struct_default::get
static const CL & get()
Definition: config_struct_details.h:28
armarx::meta::cfg::struct_default
Definition: config_struct_details.h:25
armarx::meta::cfg::element_widget
undefined_t element_widget
Definition: config_struct_details.h:19
std
Definition: Application.h:66
common.h
armarx::meta::cfg::undefined_t
::simox::meta::undefined_t undefined_t
Definition: common.h:17
armarx::meta::cfg::config_layout
undefined_t config_layout
Definition: config_struct_details.h:22