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 
30 
31 #include <Ice/Handle.h>
32 
33 namespace Ice
34 {
35 
36  class Properties;
38 
39 }
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 
63  {}
64 
66 
67  /**
68  * Converts the property definition into a string using a specified
69  * formatter.
70  *
71  * @param formatter Custom definition formatter
72  */
73  virtual std::string toString(PropertyDefinitionFormatter& formatter, const std::string& value) = 0;
74 
75  bool isRequired() const
76  {
77  return required;
78  }
79 
80 
81  bool isConstant() const
82  {
83  return constness == eConstant;
84  }
85 
86  virtual std::string getDefaultAsString() = 0;
87 
88  virtual
89  void
91  const std::string& prefix,
92  Ice::PropertiesPtr) = 0;
93 
94  static std::string icePropertyGet(Ice::PropertiesPtr const& iceProperties, std::string const& key);
95 
96  bool isSet(std::string const& prefix, std::string const& propertyName, Ice::PropertiesPtr const& iceProperties) const;
97 
98  protected:
99  /**
100  * If set to true, the property must be explicitely set through configuration parameters.
101  */
102  bool required;
103 
105 
106  private:
108 
109  /**
110  * Sets the typeid name of the property value type
111  *
112  * @param typeIdName Value type name
113  */
114  void setTypeIdName(std::string typeIdName)
115  {
116  this->typeIdName = typeIdName;
117  }
118 
119  /**
120  * Returns the value type name
121  */
122  std::string getTypeIdName() const
123  {
124  return typeIdName;
125  }
126 
127  /**
128  * Value type name
129  */
130  std::string typeIdName;
131  };
132 
133 }
134 
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:75
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:926
armarx::PropertyDefinitionBase::icePropertyGet
static std::string icePropertyGet(Ice::PropertiesPtr const &iceProperties, std::string const &key)
Definition: PropertyDefinition.cpp:267
armarx::PropertyDefinitionBase::isSet
bool isSet(std::string const &prefix, std::string const &propertyName, Ice::PropertiesPtr const &iceProperties) const
Definition: PropertyDefinition.cpp:272
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:102
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:64
armarx::PropertyDefinitionBase::isConstant
bool isConstant() const
Definition: PropertyDefinitionInterface.h:81
armarx::PropertyDefinitionBase::constness
PropertyConstness constness
Definition: PropertyDefinitionInterface.h:104
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:28
armarx::PropertyDefinitionBase::eConstant
@ eConstant
Definition: PropertyDefinitionInterface.h:56