GetValue.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <SimoxUtility/meta/enum/adapt_enum.h>
4 
5 #include "../Storage.h"
6 #include "Common.h"
7 
8 namespace armarx::RemoteGui
9 {
10  template <class T>
11  std::enable_if_t<meta::cfg::gui_definition_enabled_v<T>, void>
12  getValueFromMap(T& cfg, RemoteGui::ValueMap const& values, std::string const& name)
13  {
15  namespace hana = boost::hana;
16  static constexpr auto accessors = hana::accessors<T>();
17  hana::for_each(accessors,
18  [&](auto& e)
19  {
21  using elem_det = decltype(armarx::meta::cfg::to_element_detail(e));
22  if constexpr (!elem_det::no_remote_gui)
23  {
24  const auto varname = hana::to<char const*>(hana::first(e));
25  const auto& id = armarx::meta::cfg::ConcatID(name, varname);
26  auto& elem = hana::second(e)(cfg);
28  getValueFromMap(elem, values, id);
29  }
30  else
31  {
32  // do nothing
33  }
34  });
35  }
36 
37  template <class T>
38  simox::meta::enable_if_enum_adapted_t<T>
39  getValueFromMap(T& cfg, RemoteGui::ValueMap const& values, std::string const& name)
40  {
42  cfg = simox::meta::enum_names<T>.from_name(getAndReturnValue<std::string>(values, name));
43  }
44 
45  inline void
46  getValueFromMap(long unsigned int& val, ValueMap const& values, std::string const& name)
47  {
48  int value;
50  val = value;
51  }
52 
53 } // namespace armarx::RemoteGui
armarx::RemoteGui
Definition: LightweightRemoteGuiComponentPlugin.h:30
Common.h
ProsthesisInterface.values
values
Definition: ProsthesisInterface.py:190
armarx::RemoteGui::ValueMap
std::map< std::string, ValueVariant > ValueMap
Definition: RemoteGuiVisitors.h:41
ARMARX_TRACE_LITE
#define ARMARX_TRACE_LITE
Definition: trace.h:98
ARMARX_TRACE
#define ARMARX_TRACE
Definition: trace.h:77
cxxopts::value
std::shared_ptr< Value > value()
Definition: cxxopts.hpp:855
armarx::meta::cfg::ConcatID
std::string ConcatID(const std::string &prefix, const std::string &suffix)
Definition: ConcatID.h:8
armarx::meta::cfg::to_element_detail
element_details< CL, MT, ptr > to_element_detail(const boost::hana::pair< VarName, boost::hana::struct_detail::member_ptr< MT CL::*, ptr >> &)
T
float T
Definition: UnscentedKalmanFilterTest.cpp:38
armarx::RemoteGui::getValueFromMap
std::enable_if_t< meta::cfg::gui_definition_enabled_v< T >, void > getValueFromMap(T &cfg, RemoteGui::ValueMap const &values, std::string const &name)
Definition: GetValue.h:12