PluginCfgStruct.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 
30 
32 {
33  template<class T>
35  : std::bool_constant<meta::has_hana_accessor_v<T>> {};
36 
37  template<class T>
38  static constexpr bool properties_definition_enabled_v =
40 }
41 //GetPropertyPlugin
43 {
44  template<class T>
46  T,
47  std::enable_if_t<meta::cfg::properties_definition_enabled_v<T>>
48  > : std::true_type
49  {
50  static void Get(armarx::PropertyUser& pu, T& val, const std::string& name)
51  {
53  namespace hana = boost::hana;
54  static constexpr auto accessors = hana::accessors<T>();
55  hana::for_each(accessors, [&](auto & e)
56  {
58  using elem_det = decltype(armarx::meta::cfg::to_element_detail(e));
59  pu.getProperty(
60  hana::second(e)(val),
61  elem_det::make_property_name(name)
62  );
63  });
64  }
65  };
66 }
67 //DefinePropertyPlugin
69 {
70  template<class T>
72  T,
73  std::enable_if_t<meta::cfg::properties_definition_enabled_v<T>>
74  > : std::true_type
75  {
76  static void Define(
78  bool required,
79  T& setter,
80  const std::string& name,
81  const std::string& description,
83  {
85  namespace hana = boost::hana;
86  static constexpr auto accessors = hana::accessors<T>();
87  hana::for_each(accessors, [&](auto & e)
88  {
90  using elem_det = decltype(armarx::meta::cfg::to_element_detail(e));
91  if constexpr(elem_det::is_no_prop)
92  {
93  return;
94  }
95  else
96  {
97  using sub_result_t = std::remove_reference_t<decltype(pc.required(hana::second(e)(setter), "", "",
98  constness))>;
99  const auto varname = hana::to<char const*>(hana::first(e));
100 #define call_params \
101  required, \
102  hana::second(e)(setter), \
103  elem_det::make_property_name(name), \
104  description + " (parameter " + varname + ") " + \
105  elem_det::description_as_string(), \
106  constness
107 
108  static constexpr bool min_set = simox::meta::is_not_undefined_t(elem_det::min);
109  static constexpr bool max_set = simox::meta::is_not_undefined_t(elem_det::max);
110  if constexpr(std::is_same_v<sub_result_t, void> || (!min_set && !max_set))
111  {
112  pc.requiredOrOptional(call_params);
113  }
114  else
115  {
116  auto& subpdef = pc.requiredOrOptional(call_params);
117  if constexpr(min_set)
118  {
119  subpdef.setMin(elem_det::min);
120  }
121  if constexpr(max_set)
122  {
123  subpdef.setMax(elem_det::max);
124  }
125  }
126 #undef call_params
127  }
128  });
129  }
130  };
131 }
132 
armarx::PropertyDefinitionBase::PropertyConstness
PropertyConstness
Definition: PropertyDefinitionInterface.h:54
armarx::meta::properties::DefinePropertyPlugin
Definition: PropertyDefinition.h:57
armarx::meta::cfg::properties_definition_enabled
Definition: PluginCfgStruct.h:34
armarx::meta::properties
Definition: PluginCfgStruct.h:42
armarx::meta::properties::DefinePropertyPlugin< T, std::enable_if_t< meta::cfg::properties_definition_enabled_v< T > > >::Define
static void Define(armarx::PropertyDefinitionContainer &pc, bool required, T &setter, const std::string &name, const std::string &description, PropertyDefinitionBase::PropertyConstness constness)
Definition: PluginCfgStruct.h:76
trace.h
ARMARX_TRACE_LITE
#define ARMARX_TRACE_LITE
Definition: trace.h:85
armarx::meta::cfg
Definition: PluginCfgStruct.h:31
ARMARX_TRACE
#define ARMARX_TRACE
Definition: trace.h:69
PropertyUser.h
ConfigIntrospection.h
max
T max(T t1, T t2)
Definition: gdiam.h:48
armarx::PropertyDefinitionContainer
PropertyDefinitionContainer.
Definition: PropertyDefinitionContainer.h:53
armarx::PropertyUser::getProperty
Property< PropertyType > getProperty(const std::string &name)
Property creation and retrieval.
Definition: PropertyUser.h:179
std
Definition: Application.h:66
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 >> &)
pc
Introduction Thank you for taking interest in our work and downloading this software This library implements the algorithm described in the paper R R R Klein Efficient RANSAC for Point Cloud Shape in Computer Graphics Blackwell June If you use this software you should cite the aforementioned paper in any resulting publication Please send comments or bug reports to Ruwen Roland BUT NOT LIMITED THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY OR CONSEQUENTIAL WHETHER IN STRICT OR EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE Example usage This section shows how to use the library to detect the shapes in a point cloud PointCloud pc
Definition: ReadMe.txt:68
T
float T
Definition: UnscentedKalmanFilterTest.cpp:35
min
T min(T t1, T t2)
Definition: gdiam.h:42
armarx::PropertyUser
Abstract PropertyUser class.
Definition: PropertyUser.h:62
armarx::meta::properties::GetPropertyPlugin< T, std::enable_if_t< meta::cfg::properties_definition_enabled_v< T > > >::Get
static void Get(armarx::PropertyUser &pu, T &val, const std::string &name)
Definition: PluginCfgStruct.h:50
armarx::meta::properties::GetPropertyPlugin
Definition: PropertyDefinition.h:54
call_params
#define call_params