ControllerDescription.h
Go to the documentation of this file.
1/**
2 * This file is part of ArmarX.
3 *
4 * ArmarX is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation.
7 *
8 * ArmarX is distributed in the hope that it will be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * @author Fabian Reister ( fabian dot reister at kit dot edu )
17 * @date 2022
18 * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
19 * GNU General Public License
20 */
21
22#pragma once
23
24#include <type_traits>
25
26#include <armarx/control/interface/ConfigurableNJointControllerInterface.h>
27
29{
30 namespace detail::proxy
31 {
32 template <typename, typename = std::void_t<>>
33 struct has_proxy_type : std::false_type
34 {
35 };
36
37 // Specialization that checks for the presence of 'Proxy' member.
38 template <typename T>
39 struct has_proxy_type<T, std::void_t<typename T::Proxy>> : std::true_type
40 {
41 };
42
43 // Helper variable template for easier usage.
44 template <typename T>
46
47 // Fallback mechanism using std::conditional_t to safely define ProxyType if it exists
48 template <typename T, bool = has_proxy_type_v<T>>
49 struct ProxyType
50 {
51 using type = typename T::Proxy; // If T has a Proxy type, use it
52 };
53
54 template <typename T>
55 struct ProxyType<T, false>
56 {
57 using type = armarx::control::ConfigurableNJointControllerInterfacePrx; // Fallback type
58 };
59
60 // Helper to easily get the type
61 template <typename T>
63
64 } // namespace detail::proxy
65
67 {
68 // Check for the existence of 'ctrlConfigClassName' member
69 template <typename, typename = std::void_t<>>
70 struct has_ctrl_config_class_name : std::false_type
71 {
72 };
73
74 template <typename T>
75 struct has_ctrl_config_class_name<T, std::void_t<decltype(T::ctrlConfigClassName)>> :
76 std::true_type
77 {
78 };
79
80 template <typename T>
82
83 // Safe ctrlConfigClassName detection with a fallback to 'name'
84 template <typename T, bool = has_ctrl_config_class_name_v<T>>
86 {
87 static constexpr const char* value =
88 T::ctrlConfigClassName; // If T has ctrlConfigClassName, use it
89 };
90
91 template <typename T>
92 struct CtrlConfigClassName<T, false>
93 {
94 static constexpr const char* value = T::name; // Fallback to 'name'
95 };
96
97 template <typename T>
99
100 } // namespace detail::ctrl_class_name
101
102 template <auto T>
104 {
105 // using AronDTO = 'your aron type';
106 // using Proxy = armarx::control::ConfigurableNJointControllerInterfacePrx;
107 };
108
109} // namespace armarx::control::client
typename ProxyType< T >::type ProxyType_t
This file is part of ArmarX.
armarx::control::ConfigurableNJointControllerInterfacePrx type