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
8namespace 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;
49 getValueFromMap(value, values, name);
50 val = value;
51 }
52
53} // namespace armarx::RemoteGui
T getAndReturnValue(ValueMap const &values, std::string const &name)
Definition Storage.h:190
std::map< std::string, ValueVariant > ValueMap
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
element_details< CL, MT, ptr > to_element_detail(const boost::hana::pair< VarName, boost::hana::struct_detail::member_ptr< MT CL::*, ptr > > &)
std::string ConcatID(const std::string &prefix, const std::string &suffix)
Definition ConcatID.h:8
#define ARMARX_TRACE
Definition trace.h:77
#define ARMARX_TRACE_LITE
Definition trace.h:98