PluginEnumNames.h
Go to the documentation of this file.
1 /*
2  * This file is part of ArmarX.
3  *
4  * Copyright (C) 2011-2016, High Performance Humanoid Technologies (H2T), Karlsruhe Institute of Technology (KIT), all rights reserved.
5  *
6  * ArmarX is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License version 2 as
8  * published by the Free Software Foundation.
9  *
10  * ArmarX is distributed in the hope that it will be useful, but
11  * WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program. If not, see <http://www.gnu.org/licenses/>.
17  *
18  * @package ArmarXCore::core
19  * @author Jan Issac (jan dot issac at gmx dot de)
20  * @date 2011
21  * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
22  * GNU General Public License
23  */
24 
25 #pragma once
26 
27 #include <boost/lexical_cast.hpp>
28 #include <SimoxUtility/meta/enum/adapt_enum.h>
29 
32 
33 //bimap
35 {
36  template <class T>
37  struct MapPropertyValuePlugin<boost::bimap<std::string, T>, void> : std::true_type
38  {
39  static PropertyDefinition<T>&
40  Map(armarx::PropertyDefinition<T>& pd, const boost::bimap<std::string, T>& values)
41  {
42  for (const auto& [name, value] : values)
43  {
44  pd.map(name, value);
45  }
46  return pd;
47  }
48  };
49 
50  template <class T>
51  struct MapPropertyValuePlugin<boost::bimap<T, std::string>,
52  std::enable_if_t<!std::is_same_v<T, std::string>>> :
53  std::true_type
54  {
55  static PropertyDefinition<T>&
56  Map(armarx::PropertyDefinition<T>& pd, const boost::bimap<T, std::string>& values)
57  {
58  for (const auto& [value, name] : values)
59  {
60  pd.map(name, value);
61  }
62  return pd;
63  }
64  };
65 } // namespace armarx::meta::properties
66 
67 //EnumNames
69 {
70  template <class T>
71  struct MapPropertyValuePlugin<simox::meta::EnumNames<T>, void> : std::true_type
72  {
73  static PropertyDefinition<T>&
74  Map(armarx::PropertyDefinition<T>& pd, const simox::meta::EnumNames<T>& values)
75  {
76  return pd.map(values.map());
77  }
78  };
79 } // namespace armarx::meta::properties
80 
81 //GetPropertyPlugin
83 {
84  template <class T>
85  struct GetPropertyPlugin<T, simox::meta::enable_if_enum_adapted_t<T>> : std::true_type
86  {
87  static void
88  Get(armarx::PropertyUser& pu, T& val, const std::string& name)
89  {
90  std::cout << "callget\n";
92  val = boost::lexical_cast<T>(pu.getProperty<std::string>(name));
93  }
94  };
95 } // namespace armarx::meta::properties
96 
97 //DefinePropertyPlugin
99 {
100  template <class T>
101  struct PDInitHookPlugin<T, simox::meta::enable_if_enum_adapted_t<T>> : std::true_type
102  {
103  static void
105  {
106  pd.map(simox::meta::enum_names<T>);
107  }
108  };
109 } // namespace armarx::meta::properties
armarx::meta::properties::MapPropertyValuePlugin
Definition: PropertyDefinition.h:64
armarx::meta::properties
Definition: PluginCfgStruct.h:43
trace.h
ProsthesisInterface.values
values
Definition: ProsthesisInterface.py:190
boost
Definition: ApplicationOptions.h:37
armarx::meta::properties::MapPropertyValuePlugin< boost::bimap< T, std::string >, std::enable_if_t<!std::is_same_v< T, std::string > > >::Map
static PropertyDefinition< T > & Map(armarx::PropertyDefinition< T > &pd, const boost::bimap< T, std::string > &values)
Definition: PluginEnumNames.h:56
armarx::meta::properties::PDInitHookPlugin
Definition: PropertyDefinition.h:74
ARMARX_TRACE
#define ARMARX_TRACE
Definition: trace.h:77
cxxopts::value
std::shared_ptr< Value > value()
Definition: cxxopts.hpp:855
PropertyUser.h
armarx::meta::properties::PDInitHookPlugin< T, simox::meta::enable_if_enum_adapted_t< T > >::Init
static void Init(PropertyDefinition< T > &pd)
Definition: PluginEnumNames.h:104
armarx::meta::properties::MapPropertyValuePlugin< boost::bimap< std::string, T >, void >::Map
static PropertyDefinition< T > & Map(armarx::PropertyDefinition< T > &pd, const boost::bimap< std::string, T > &values)
Definition: PluginEnumNames.h:40
armarx::meta::properties::MapPropertyValuePlugin< simox::meta::EnumNames< T >, void >::Map
static PropertyDefinition< T > & Map(armarx::PropertyDefinition< T > &pd, const simox::meta::EnumNames< T > &values)
Definition: PluginEnumNames.h:74
armarx::PropertyUser::getProperty
Property< PropertyType > getProperty(const std::string &name)
Property creation and retrieval.
Definition: PropertyUser.h:180
T
float T
Definition: UnscentedKalmanFilterTest.cpp:38
armarx::PropertyUser
Abstract PropertyUser class.
Definition: PropertyUser.h:63
armarx::PropertyDefinition
PropertyDefinition defines a property that will be available within the PropertyUser.
Definition: PropertyDefinition.h:117
simox
Definition: Impl.cpp:40
armarx::meta::properties::GetPropertyPlugin< T, simox::meta::enable_if_enum_adapted_t< T > >::Get
static void Get(armarx::PropertyUser &pu, T &val, const std::string &name)
Definition: PluginEnumNames.h:88
armarx::meta::properties::GetPropertyPlugin
Definition: PropertyDefinition.h:54
armarx::PropertyDefinition::map
PropertyDefinition< PropertyType > & map(const std::string &valueString, PropertyType value)
Maps a string value onto a value of the specified template type.
Definition: PropertyDefinition.hpp:93