PropertyDefinitionInterface.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 2012
21  * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
22  * GNU General Public License
23  */
24 
25 
26 #pragma once
27 
28 #include <Ice/Handle.h>
29 
32 
33 namespace Ice
34 {
35 
36  class Properties;
38 
39 } // namespace Ice
40 
41 namespace armarx
42 {
43  /**
44  * @ingroup properties
45  *
46  * @class PropertyDefinitionBase
47  * @brief Common interface of any property definition
48  *
49  * This abstract class is part of the internal implementation
50  */
52  {
53  public:
55  {
58  };
59 
62  {
63  }
64 
66  {
67  }
68 
69  /**
70  * Converts the property definition into a string using a specified
71  * formatter.
72  *
73  * @param formatter Custom definition formatter
74  */
75  virtual std::string toString(PropertyDefinitionFormatter& formatter,
76  const std::string& value) = 0;
77 
78  bool
79  isRequired() const
80  {
81  return required;
82  }
83 
84  bool
85  isConstant() const
86  {
87  return constness == eConstant;
88  }
89 
90  virtual std::string getDefaultAsString() = 0;
91 
92  virtual void writeValueToSetter(const std::string& prefix, Ice::PropertiesPtr) = 0;
93 
94  static std::string icePropertyGet(Ice::PropertiesPtr const& iceProperties,
95  std::string const& key);
96 
97  bool isSet(std::string const& prefix,
98  std::string const& propertyName,
99  Ice::PropertiesPtr const& iceProperties) const;
100 
101  protected:
102  /**
103  * If set to true, the property must be explicitely set through configuration parameters.
104  */
105  bool required;
106 
108 
109  private:
111 
112  /**
113  * Sets the typeid name of the property value type
114  *
115  * @param typeIdName Value type name
116  */
117  void
118  setTypeIdName(std::string typeIdName)
119  {
120  this->typeIdName = typeIdName;
121  }
122 
123  /**
124  * Returns the value type name
125  */
126  std::string
127  getTypeIdName() const
128  {
129  return typeIdName;
130  }
131 
132  /**
133  * Value type name
134  */
135  std::string typeIdName;
136  };
137 
138 } // namespace armarx
armarx::PropertyDefinitionBase::toString
virtual std::string toString(PropertyDefinitionFormatter &formatter, const std::string &value)=0
Converts the property definition into a string using a specified formatter.
armarx::PropertyDefinitionBase
Common interface of any property definition.
Definition: PropertyDefinitionInterface.h:51
armarx::PropertyDefinitionBase::isRequired
bool isRequired() const
Definition: PropertyDefinitionInterface.h:79
armarx::PropertyDefinitionBase::PropertyConstness
PropertyConstness
Definition: PropertyDefinitionInterface.h:54
armarx::PropertyDefinitionBase::~PropertyDefinitionBase
virtual ~PropertyDefinitionBase()
Definition: PropertyDefinitionInterface.h:65
PropertyDefinitionFormatter.h
IceInternal::Handle<::Ice::Properties >
cxxopts::value
std::shared_ptr< Value > value()
Definition: cxxopts.hpp:855
armarx::PropertyDefinitionBase::icePropertyGet
static std::string icePropertyGet(Ice::PropertiesPtr const &iceProperties, std::string const &key)
Definition: PropertyDefinition.cpp:289
armarx::PropertyDefinitionBase::isSet
bool isSet(std::string const &prefix, std::string const &propertyName, Ice::PropertiesPtr const &iceProperties) const
Definition: PropertyDefinition.cpp:296
armarx::PropertyDefinitionBase::getDefaultAsString
virtual std::string getDefaultAsString()=0
armarx::PropertyDefinitionBase::required
bool required
If set to true, the property must be explicitely set through configuration parameters.
Definition: PropertyDefinitionInterface.h:105
IceManager.h
armarx::PropertyDefinitionBase::PropertyDefinitionBase
PropertyDefinitionBase(bool required=true, PropertyConstness constness=eConstant)
Definition: PropertyDefinitionInterface.h:60
armarx::PropertyDefinitionContainer
PropertyDefinitionContainer.
Definition: PropertyDefinitionContainer.h:53
Ice
Definition: DBTypes.cpp:63
armarx::PropertyDefinitionBase::isConstant
bool isConstant() const
Definition: PropertyDefinitionInterface.h:85
armarx::PropertyDefinitionBase::constness
PropertyConstness constness
Definition: PropertyDefinitionInterface.h:107
armarx::PropertyDefinitionBase::writeValueToSetter
virtual void writeValueToSetter(const std::string &prefix, Ice::PropertiesPtr)=0
Ice::PropertiesPtr
::IceInternal::Handle<::Ice::Properties > PropertiesPtr
Definition: PropertyDefinition.h:48
armarx::PropertyDefinitionFormatter
PropertyDefinitionFormatter is the base class for all formatters of PropertyDefinitions.
Definition: PropertyDefinitionFormatter.h:38
armarx::PropertyDefinitionBase::eModifiable
@ eModifiable
Definition: PropertyDefinitionInterface.h:57
armarx
This file offers overloads of toIce() and fromIce() functions for STL container types.
Definition: ArmarXTimeserver.cpp:27
armarx::PropertyDefinitionBase::eConstant
@ eConstant
Definition: PropertyDefinitionInterface.h:56