ProxyPropertyDefinition.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 Christian R. G. Dreher <c.dreher@kit.edu>
20 * @date 2020
21 * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
22 * GNU General Public License
23 */
24
25
26#pragma once
27
28
29// STD/STL
30#include <string>
31
32// ArmarXCore
35
36namespace armarx
37{
38
39
40 enum class ProxyType
41 {
44 };
45
47 {
48
49 protected:
51
52 public:
54 {
55 // pass
56 }
57
59 {
60 // pass
61 }
62
63 virtual void write_proxy_to_setter(IceManagerPtr ice_manager,
64 const std::string& proxy_name) = 0;
65
68 {
69 return m_proxy_type;
70 }
71 };
72
73 template <typename PropertyType>
75 {
76
77 private:
78 PropertyType* m_setter_ref;
79
80 public:
81 ProxyPropertyDefinition(PropertyType* setter_ref, ProxyType proxy_type) :
82 ProxyPropertyDefinitionBase{proxy_type}, m_setter_ref{setter_ref}
83 {
84 ARMARX_CHECK(m_setter_ref != nullptr) << "`m_setter_ref` must not be a nullptr";
85 }
86
88 {
89 // pass
90 }
91
92 virtual void
93 write_proxy_to_setter(IceManagerPtr ice_manager, const std::string& proxy_name) override
94 {
95 switch (m_proxy_type)
96 {
98 *m_setter_ref = ice_manager->getProxy<PropertyType>(proxy_name);
99 break;
100 case ProxyType::topic:
101 *m_setter_ref = ice_manager->getTopic<PropertyType>(proxy_name);
102 break;
103 }
104 }
105 };
106
107
108} // namespace armarx
virtual void write_proxy_to_setter(IceManagerPtr ice_manager, const std::string &proxy_name)=0
virtual void write_proxy_to_setter(IceManagerPtr ice_manager, const std::string &proxy_name) override
ProxyPropertyDefinition(PropertyType *setter_ref, ProxyType proxy_type)
#define ARMARX_CHECK(expression)
Shortcut for ARMARX_CHECK_EXPRESSION.
This file offers overloads of toIce() and fromIce() functions for STL container types.
IceUtil::Handle< IceManager > IceManagerPtr
IceManager smart pointer.
Definition ArmarXFwd.h:39