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 <SimoxUtility/meta/enum/adapt_enum.h>
30 //bimap
32 {
33  template<class T>
34  struct MapPropertyValuePlugin<boost::bimap<std::string, T>, void> : std::true_type
35  {
36  static PropertyDefinition<T>&
37  Map(armarx::PropertyDefinition<T>& pd, const boost::bimap<std::string, T>& values)
38  {
39  for (const auto& [name, value] : values)
40  {
41  pd.map(name, value);
42  }
43  return pd;
44  }
45  };
46 
47  template<class T>
49  boost::bimap<T, std::string>,
50  std::enable_if_t < !std::is_same_v<T, std::string >>
51  > : std::true_type
52  {
53  static PropertyDefinition<T>&
54  Map(armarx::PropertyDefinition<T>& pd, const boost::bimap<T, std::string>& values)
55  {
56  for (const auto& [value, name] : values)
57  {
58  pd.map(name, value);
59  }
60  return pd;
61  }
62  };
63 }
64 //EnumNames
66 {
67  template<class T>
68  struct MapPropertyValuePlugin <simox::meta::EnumNames<T>, void> : std::true_type
69  {
70  static PropertyDefinition<T>&
71  Map(armarx::PropertyDefinition<T>& pd, const simox::meta::EnumNames<T>& values)
72  {
73  return pd.map(values.map());
74  }
75  };
76 }
77 //GetPropertyPlugin
79 {
80  template<class T>
81  struct GetPropertyPlugin<T, simox::meta::enable_if_enum_adapted_t<T>> : std::true_type
82  {
83  static void Get(armarx::PropertyUser& pu, T& val, const std::string& name)
84  {
85  std::cout << "callget\n";
87  val = boost::lexical_cast<T>(pu.getProperty<std::string>(name));
88  }
89  };
90 }
91 //DefinePropertyPlugin
93 {
94  template<class T>
95  struct PDInitHookPlugin<T, simox::meta::enable_if_enum_adapted_t<T>> : std::true_type
96  {
97  static void Init(PropertyDefinition<T>& pd)
98  {
99  pd.map(simox::meta::enum_names<T>);
100  }
101  };
102 }
armarx::meta::properties::MapPropertyValuePlugin
Definition: PropertyDefinition.h:60
armarx::meta::properties
Definition: PluginCfgStruct.h:42
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:54
trace.h
ProsthesisInterface.values
values
Definition: ProsthesisInterface.py:190
boost
Definition: ApplicationOptions.h:37
armarx::meta::properties::PDInitHookPlugin
Definition: PropertyDefinition.h:66
ARMARX_TRACE
#define ARMARX_TRACE
Definition: trace.h:69
cxxopts::value
std::shared_ptr< Value > value()
Definition: cxxopts.hpp:926
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:97
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:37
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:71
armarx::PropertyUser::getProperty
Property< PropertyType > getProperty(const std::string &name)
Property creation and retrieval.
Definition: PropertyUser.h:179
T
float T
Definition: UnscentedKalmanFilterTest.cpp:35
armarx::PropertyUser
Abstract PropertyUser class.
Definition: PropertyUser.h:62
armarx::PropertyDefinition
PropertyDefinition defines a property that will be available within the PropertyUser.
Definition: PropertyDefinition.h:107
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:83
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:95