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 {
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 {
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 {
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
PropertyDefinition defines a property that will be available within the PropertyUser.
PropertyDefinition< PropertyType > & map(const std::string &valueString, PropertyType value)
Maps a string value onto a value of the specified template type.
Abstract PropertyUser class.
Property< PropertyType > getProperty(const std::string &name)
Property creation and retrieval.
Definition Impl.cpp:41
static void Get(armarx::PropertyUser &pu, T &val, const std::string &name)
static PropertyDefinition< T > & Map(armarx::PropertyDefinition< T > &pd, const boost::bimap< T, std::string > &values)
static PropertyDefinition< T > & Map(armarx::PropertyDefinition< T > &pd, const boost::bimap< std::string, T > &values)
static PropertyDefinition< T > & Map(armarx::PropertyDefinition< T > &pd, const simox::meta::EnumNames< T > &values)
#define ARMARX_TRACE
Definition trace.h:77