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 namespace armarx
37 {
38 
39 
40  enum class ProxyType
41  {
42  component,
43  topic
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 
66  ProxyType
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
check.h
armarx::ProxyPropertyDefinitionBase::m_proxy_type
const ProxyType m_proxy_type
Definition: ProxyPropertyDefinition.h:50
armarx::ProxyType::component
@ component
armarx::ProxyPropertyDefinition::ProxyPropertyDefinition
ProxyPropertyDefinition(PropertyType *setter_ref, ProxyType proxy_type)
Definition: ProxyPropertyDefinition.h:81
armarx::ProxyPropertyDefinition::~ProxyPropertyDefinition
virtual ~ProxyPropertyDefinition()
Definition: ProxyPropertyDefinition.h:87
armarx::ProxyPropertyDefinitionBase::~ProxyPropertyDefinitionBase
virtual ~ProxyPropertyDefinitionBase()
Definition: ProxyPropertyDefinition.h:58
armarx::ProxyPropertyDefinition
Definition: ProxyPropertyDefinition.h:74
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:93
armarx::ProxyType::topic
@ topic
IceManager.h
armarx::ProxyType
ProxyType
Definition: ProxyPropertyDefinition.h:40
armarx::ProxyPropertyDefinitionBase
Definition: ProxyPropertyDefinition.h:46
IceUtil::Handle< IceManager >
armarx::ProxyPropertyDefinitionBase::ProxyPropertyDefinitionBase
ProxyPropertyDefinitionBase(ProxyType proxy_type)
Definition: ProxyPropertyDefinition.h:53
armarx::ProxyPropertyDefinitionBase::getProxyType
ProxyType getProxyType()
Definition: ProxyPropertyDefinition.h:67
armarx
This file offers overloads of toIce() and fromIce() functions for STL container types.
Definition: ArmarXTimeserver.cpp:27