|
PropertyDefinition defines a property that will be available within the PropertyUser. More...
#include <ArmarXCore/core/application/properties/PropertyDefinition.h>
Public Types | |
typedef std::function< PropertyType(std::string)> | PropertyFactoryFunction |
using | PropertyTypePtr = std::shared_ptr< PropertyType > |
using | PropertyValuesMap = std::map< std::string, ValueEntry > |
using | ValueEntry = std::pair< std::string, PropertyType > |
![]() | |
enum | PropertyConstness { eConstant, eModifiable } |
Public Member Functions | |
bool | expandEnvironmentVariables () const |
std::string | getDefaultAsString () override |
PropertyType | getDefaultValue () |
std::string | getDescription () const |
PropertyFactoryFunction | getFactory () const |
std::string | getMatchRegex () const |
double | getMax () const |
double | getMin () const |
std::string | getPropertyName () const |
PropertyType | getValue (const std::string &prefix, Ice::PropertiesPtr) |
PropertyValuesMap & | getValueMap () |
bool | isCaseInsensitive () const |
bool | isSet (const std::string &prefix, Ice::PropertiesPtr iceProperties) const |
PropertyDefinition< PropertyType > & | map (const std::map< std::string, PropertyType > &values) |
template<class T > | |
std::enable_if_t< std::is_same_v< T, PropertyType > &&!std::is_same_v< T, std::string >, PropertyDefinition< T > & > | map (const std::map< T, std::string > &values) |
PropertyDefinition< PropertyType > & | map (const std::string &valueString, PropertyType value) |
Maps a string value onto a value of the specified template type. More... | |
template<class T > | |
std::enable_if_t< meta::properties::MapPropertyValuePlugin< T >::value, PropertyDefinition< PropertyType > & > | map (const T &values) |
PropertyDefinition (PropertyType *setterRef, const std::string &propertyName, const std::string &description, PropertyDefinitionBase::PropertyConstness constness=PropertyDefinitionBase::eConstant) | |
Constructs a property definition of a required property. More... | |
PropertyDefinition (PropertyType *setterRef, const std::string &propertyName, PropertyType defaultValue, const std::string &description, PropertyDefinitionBase::PropertyConstness constness=PropertyDefinitionBase::eConstant) | |
Constructs a property definition of an optional property. More... | |
bool | removeQuotes () const |
PropertyDefinition< PropertyType > & | setCaseInsensitive (bool isCaseInsensitive) |
Sets whether the property value matching is case insensitive. More... | |
PropertyDefinition< PropertyType > & | setExpandEnvironmentVariables (bool expand) |
Sets whether for string values environment varbiale expanding should be considered. More... | |
PropertyDefinition< PropertyType > & | setFactory (const PropertyFactoryFunction &func) |
Sets the factory function that creates the specified template type from the actual string value. More... | |
PropertyDefinition< PropertyType > & | setMatchRegex (const std::string &expr) |
Sets the regular expression which the value has to be matched with. More... | |
PropertyDefinition< PropertyType > & | setMax (double max) |
Sets the max allowed numeric value. More... | |
template<class T = PropertyType> | |
PropertyDefinition< PropertyType > & | setMax (std::array< T, 1 > max) |
PropertyDefinition< PropertyType > & | setMin (double min) |
Sets the min allowed numeric value. More... | |
template<class T = PropertyType> | |
PropertyDefinition< PropertyType > & | setMin (std::array< T, 1 > min) |
PropertyDefinition< PropertyType > & | setRemoveQuotes (bool removeQuotes) |
Sets whether for string values leading and trailing quotes should be removed. More... | |
std::string | toString (PropertyDefinitionFormatter &formatter, const std::string &value) override |
virtual void | writeValueToSetter (const std::string &prefix, Ice::PropertiesPtr) override |
![]() | |
bool | isConstant () const |
bool | isRequired () const |
bool | isSet (std::string const &prefix, std::string const &propertyName, Ice::PropertiesPtr const &iceProperties) const |
PropertyDefinitionBase (bool required=true, PropertyConstness constness=eConstant) | |
virtual | ~PropertyDefinitionBase () |
Static Public Member Functions | |
static void | removeQuotes (const std::string &input, std::string &output) |
Checks first and last character of input and in case both are quotes, they are removed and the remaining result is stored in output. More... | |
![]() | |
static std::string | icePropertyGet (Ice::PropertiesPtr const &iceProperties, std::string const &key) |
Protected Attributes | |
bool | caseInsensitive |
Case sensitivity indicator. More... | |
PropertyType | defaultValue |
Fallback/Default property value. More... | |
std::string | description |
Property description. More... | |
bool | expandEnvVars |
Exand environments variables indicator (standard: true) More... | |
PropertyFactoryFunction | factory |
Builder function. More... | |
double | max |
Upper bound of numeric values (used for numeric value retrieval without mapping) More... | |
double | min |
Lower bound of numeric values (used for numeric value retrieval without mapping) More... | |
std::string | propertyName |
Property name. More... | |
PropertyValuesMap | propertyValuesMap |
Main property map. More... | |
std::string | regex |
Regular expression to approve a required value pattern. More... | |
PropertyType * | setterRef |
Reference to a variable to set. More... | |
bool | stringRemoveQuotes |
Remove leading and trailing quotes indicator (standard: true) First and last character of a string property value are checked for quotes. More... | |
![]() | |
PropertyConstness | constness |
bool | required |
If set to true, the property must be explicitely set through configuration parameters. More... | |
PropertyDefinition defines a property that will be available within the PropertyUser.
PropertyDefinition provides the definition and description of a property that may be definined in a config file or passed via command line as an option. Depending which constructor is used a property is either required or optional. In the latter case a default value has to be specified.
The property specific value type (PropertyType) can be arbitrary, yet it is devided into these three groups which are handled internally differently:
All setters are self referential and therefor can be chained to simplify the implementation and increase the readability.
Definition at line 117 of file PropertyDefinition.h.
typedef std::function<PropertyType(std::string)> PropertyFactoryFunction |
Definition at line 123 of file PropertyDefinition.h.
using PropertyTypePtr = std::shared_ptr<PropertyType> |
Definition at line 120 of file PropertyDefinition.h.
using PropertyValuesMap = std::map<std::string, ValueEntry> |
Definition at line 122 of file PropertyDefinition.h.
using ValueEntry = std::pair<std::string, PropertyType> |
Definition at line 121 of file PropertyDefinition.h.
PropertyDefinition | ( | PropertyType * | setterRef, |
const std::string & | propertyName, | ||
const std::string & | description, | ||
PropertyDefinitionBase::PropertyConstness | constness = PropertyDefinitionBase::eConstant |
||
) |
Constructs a property definition of a required property.
setterRef | Setter |
propertyName | Name of the property used in config files |
description | Mandatory property description |
Definition at line 46 of file PropertyDefinition.hpp.
|
inline |
Constructs a property definition of an optional property.
setterRef | Setter |
propertyName | Name of the property used in config files |
defaultValue | Property default value of the type PropertyType |
description | Mandatory property description |
Definition at line 67 of file PropertyDefinition.hpp.
bool expandEnvironmentVariables |
Definition at line 246 of file PropertyDefinition.hpp.
|
overridevirtual |
Implements PropertyDefinitionBase.
Definition at line 356 of file PropertyDefinition.hpp.
PropertyType getDefaultValue |
std::string getDescription |
Definition at line 288 of file PropertyDefinition.hpp.
PropertyDefinition< PropertyType >::PropertyFactoryFunction getFactory |
Definition at line 317 of file PropertyDefinition.hpp.
std::string getMatchRegex |
Definition at line 260 of file PropertyDefinition.hpp.
double getMax |
double getMin |
std::string getPropertyName |
Definition at line 281 of file PropertyDefinition.hpp.
PropertyType getValue | ( | const std::string & | prefix, |
Ice::PropertiesPtr | iceProperties | ||
) |
Definition at line 451 of file PropertyDefinition.hpp.
PropertyDefinition< PropertyType >::PropertyValuesMap & getValueMap |
bool isCaseInsensitive |
Definition at line 239 of file PropertyDefinition.hpp.
bool isSet | ( | const std::string & | prefix, |
Ice::PropertiesPtr | iceProperties | ||
) | const |
|
inline |
|
inline |
|
inline |
Maps a string value onto a value of the specified template type.
Definition at line 93 of file PropertyDefinition.hpp.
|
inline |
Definition at line 176 of file PropertyDefinition.h.
bool removeQuotes |
|
static |
Checks first and last character of input and in case both are quotes, they are removed and the remaining result is stored in output.
Definition at line 779 of file PropertyDefinition.hpp.
PropertyDefinition< PropertyType > & setCaseInsensitive | ( | bool | isCaseInsensitive | ) |
Sets whether the property value matching is case insensitive.
isCaseInsensitive | Case sensitivity state |
Definition at line 144 of file PropertyDefinition.hpp.
PropertyDefinition< PropertyType > & setExpandEnvironmentVariables | ( | bool | expand | ) |
Sets whether for string values environment varbiale expanding should be considered.
expand | Expand entries like '${ENV_VAR}' to the according values of the environment. |
Definition at line 178 of file PropertyDefinition.hpp.
PropertyDefinition< PropertyType > & setFactory | ( | const PropertyFactoryFunction & | func | ) |
Sets the factory function that creates the specified template type from the actual string value.
func | the factory function |
Definition at line 135 of file PropertyDefinition.hpp.
PropertyDefinition< PropertyType > & setMatchRegex | ( | const std::string & | expr | ) |
Sets the regular expression which the value has to be matched with.
expr | Value regular expression |
Definition at line 194 of file PropertyDefinition.hpp.
PropertyDefinition< PropertyType > & setMax | ( | double | max | ) |
Sets the max allowed numeric value.
max | Max. allowed value |
Definition at line 221 of file PropertyDefinition.hpp.
|
inline |
PropertyDefinition< PropertyType > & setMin | ( | double | min | ) |
Sets the min allowed numeric value.
min | Min. allowed value |
Definition at line 203 of file PropertyDefinition.hpp.
|
inline |
PropertyDefinition< PropertyType > & setRemoveQuotes | ( | bool | removeQuotes | ) |
Sets whether for string values leading and trailing quotes should be removed.
removeQuotes | The indicator. |
Definition at line 186 of file PropertyDefinition.hpp.
|
overridevirtual |
Implements PropertyDefinitionBase.
Definition at line 324 of file PropertyDefinition.hpp.
|
overridevirtual |
Implements PropertyDefinitionBase.
Definition at line 460 of file PropertyDefinition.hpp.
|
protected |
Case sensitivity indicator.
Definition at line 326 of file PropertyDefinition.h.
|
protected |
Fallback/Default property value.
Definition at line 306 of file PropertyDefinition.h.
|
protected |
Property description.
Definition at line 301 of file PropertyDefinition.h.
|
protected |
Exand environments variables indicator (standard: true)
Definition at line 331 of file PropertyDefinition.h.
|
protected |
Builder function.
Definition at line 316 of file PropertyDefinition.h.
|
protected |
Upper bound of numeric values (used for numeric value retrieval without mapping)
Definition at line 346 of file PropertyDefinition.h.
|
protected |
Lower bound of numeric values (used for numeric value retrieval without mapping)
Definition at line 352 of file PropertyDefinition.h.
|
protected |
Property name.
Definition at line 296 of file PropertyDefinition.h.
|
protected |
Main property map.
Definition at line 291 of file PropertyDefinition.h.
|
protected |
Regular expression to approve a required value pattern.
Definition at line 321 of file PropertyDefinition.h.
|
protected |
Reference to a variable to set.
Definition at line 311 of file PropertyDefinition.h.
|
protected |
Remove leading and trailing quotes indicator (standard: true) First and last character of a string property value are checked for quotes.
E.g. "test" -> test 'test' -> test
Definition at line 340 of file PropertyDefinition.h.