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
34 #include <ArmarXCore/util/check.h>
35 
36 
37 namespace armarx
38 {
39 
40 
41  enum class ProxyType
42  {
43  component,
44  topic
45  };
46 
47 
49  {
50 
51  protected:
52 
54 
55  public:
56 
58  m_proxy_type{proxy_type}
59  {
60  // pass
61  }
62 
63  virtual
65  {
66  // pass
67  }
68 
69  virtual
70  void
72  IceManagerPtr ice_manager,
73  const std::string& proxy_name) = 0;
74 
75  ProxyType
77  {
78  return m_proxy_type;
79  }
80 
81  };
82 
83 
84  template <typename PropertyType>
86  {
87 
88  private:
89 
90  PropertyType* m_setter_ref;
91 
92  public:
93 
94  ProxyPropertyDefinition(PropertyType* setter_ref, ProxyType proxy_type) :
95  ProxyPropertyDefinitionBase{proxy_type},
96  m_setter_ref{setter_ref}
97  {
98  ARMARX_CHECK(m_setter_ref != nullptr) << "`m_setter_ref` must not be a nullptr";
99  }
100 
101  virtual
103  {
104  // pass
105  }
106 
107  virtual
108  void
110  IceManagerPtr ice_manager,
111  const std::string& proxy_name) override
112  {
113  switch (m_proxy_type)
114  {
116  *m_setter_ref = ice_manager->getProxy<PropertyType>(proxy_name);
117  break;
118  case ProxyType::topic:
119  *m_setter_ref = ice_manager->getTopic<PropertyType>(proxy_name);
120  break;
121  }
122  }
123 
124  };
125 
126 
127 }
check.h
armarx::ProxyPropertyDefinitionBase::m_proxy_type
const ProxyType m_proxy_type
Definition: ProxyPropertyDefinition.h:53
armarx::ProxyType::component
@ component
armarx::ProxyPropertyDefinition::ProxyPropertyDefinition
ProxyPropertyDefinition(PropertyType *setter_ref, ProxyType proxy_type)
Definition: ProxyPropertyDefinition.h:94
armarx::ProxyPropertyDefinition::~ProxyPropertyDefinition
virtual ~ProxyPropertyDefinition()
Definition: ProxyPropertyDefinition.h:102
armarx::ProxyPropertyDefinitionBase::~ProxyPropertyDefinitionBase
virtual ~ProxyPropertyDefinitionBase()
Definition: ProxyPropertyDefinition.h:64
armarx::ProxyPropertyDefinition
Definition: ProxyPropertyDefinition.h:85
ARMARX_CHECK
#define ARMARX_CHECK(expression)
Shortcut for ARMARX_CHECK_EXPRESSION.
Definition: ExpressionException.h:82
armarx::ProxyPropertyDefinitionBase::write_proxy_to_setter
virtual void write_proxy_to_setter(IceManagerPtr ice_manager, const std::string &proxy_name)=0
armarx::ProxyPropertyDefinition::write_proxy_to_setter
virtual void write_proxy_to_setter(IceManagerPtr ice_manager, const std::string &proxy_name) override
Definition: ProxyPropertyDefinition.h:109
armarx::ProxyType::topic
@ topic
IceManager.h
armarx::ProxyType
ProxyType
Definition: ProxyPropertyDefinition.h:41
armarx::ProxyPropertyDefinitionBase
Definition: ProxyPropertyDefinition.h:48
IceUtil::Handle< IceManager >
armarx::ProxyPropertyDefinitionBase::ProxyPropertyDefinitionBase
ProxyPropertyDefinitionBase(ProxyType proxy_type)
Definition: ProxyPropertyDefinition.h:57
armarx::ProxyPropertyDefinitionBase::getProxyType
ProxyType getProxyType()
Definition: ProxyPropertyDefinition.h:76
armarx
This file offers overloads of toIce() and fromIce() functions for STL container types.
Definition: ArmarXTimeserver.cpp:28