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
33namespace Ice
34{
35
36 class Properties;
37 using PropertiesPtr = ::IceInternal::Handle<::Ice::Properties>;
38
39} // namespace Ice
40
41namespace 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:
59
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 */
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
bool isSet(std::string const &prefix, std::string const &propertyName, Ice::PropertiesPtr const &iceProperties) const
virtual void writeValueToSetter(const std::string &prefix, Ice::PropertiesPtr)=0
static std::string icePropertyGet(Ice::PropertiesPtr const &iceProperties, std::string const &key)
virtual std::string getDefaultAsString()=0
virtual std::string toString(PropertyDefinitionFormatter &formatter, const std::string &value)=0
Converts the property definition into a string using a specified formatter.
bool required
If set to true, the property must be explicitely set through configuration parameters.
PropertyDefinitionBase(bool required=true, PropertyConstness constness=eConstant)
PropertyDefinitionFormatter is the base class for all formatters of PropertyDefinitions.
::IceInternal::Handle<::Ice::Properties > PropertiesPtr
This file offers overloads of toIce() and fromIce() functions for STL container types.