Property< PropertyType > Class Template Reference

Provides access to Ice properties with extended capabilities. More...

#include <ArmarXCore/core/application/properties/Property.h>

Public Types

typedef PropertyDefinition< PropertyType >::PropertyValuesMap PropertyValuesMap
 Property value map type definition. More...
 

Public Member Functions

PropertyType getValue ()
 Returns the property value set in a config file or passed as a command-line option. More...
 
template<class T = PropertyType>
std::enable_if_t< std::is_same_v< T, std::string >, TgetValueAndReplaceAllVars ()
 
template<class T = PropertyType>
std::enable_if_t< std::is_same_v< T, std::vector< std::string > >, TgetValueAndReplaceAllVars ()
 
bool isConstant () const
 Checks if this property is constant or if it can be changed at runtime. More...
 
bool isRequired () const
 Checks if this property is required. More...
 
bool isSet () const
 Checks whether the property is set. More...
 
 operator PropertyType ()
 Convenience overload of getValue(). More...
 
 Property (PropertyDefinition< PropertyType > definition, std::string prefix, Ice::PropertiesPtr properties)
 Property constructor. More...
 

Detailed Description

template<typename PropertyType>
class armarx::Property< PropertyType >

Provides access to Ice properties with extended capabilities.

The Property template class provides access to Ice config properties and command line options. Its main capability is to map a string value on any type that is required and put constrains on the value as well as on the property itself at the same time. For instance you can specify that a certain property is required for the component to proceed or a property may require a specific value syntax or even numeric bounds which may not be exceeded. These features and few more are supported by the Property combined with the PropertyDefinition.

Outline

template<typename PropertyType> class Property
{
bool iseSet();
bool isRequired();
PropertyType getValue();
}

Definition at line 78 of file Property.h.

Member Typedef Documentation

◆ PropertyValuesMap

Property value map type definition.

Definition at line 85 of file Property.h.

Constructor & Destructor Documentation

◆ Property()

Property ( PropertyDefinition< PropertyType >  definition,
std::string  prefix,
Ice::PropertiesPtr  properties 
)

Property constructor.

Parameters
definitionProperty specific definition
prefixProperty prefix such as domain or component name
propertiesIce properties set which contains all property strings.

Definition at line 193 of file Property.h.

Member Function Documentation

◆ getValue()

PropertyType getValue

Returns the property value set in a config file or passed as a command-line option.

If property is not set, the default value is returned unless the property is required. In the latter case an exception is thrown indicating that the required property is not set.

Returns
Property value of the type PropertyType
Exceptions
armarx::exceptions::local::ValueRangeExceededException
armarx::exceptions::local::InvalidPropertyValueException

Definition at line 207 of file Property.h.

+ Here is the caller graph for this function:

◆ getValueAndReplaceAllVars() [1/2]

std::enable_if_t<std::is_same_v<T, std::string>, T> getValueAndReplaceAllVars ( )
inline

Definition at line 149 of file Property.h.

+ Here is the call graph for this function:

◆ getValueAndReplaceAllVars() [2/2]

std::enable_if_t<std::is_same_v<T, std::vector<std::string> >, T> getValueAndReplaceAllVars ( )
inline

Definition at line 157 of file Property.h.

+ Here is the call graph for this function:

◆ isConstant()

bool isConstant

Checks if this property is constant or if it can be changed at runtime.

Returns
true if property is constant, otherwise false

Definition at line 225 of file Property.h.

◆ isRequired()

bool isRequired

Checks if this property is required.

Returns
true if set required, otherwise false

Definition at line 216 of file Property.h.

◆ isSet()

bool isSet

Checks whether the property is set.

Returns
true if property is set, otheriwse false

Definition at line 234 of file Property.h.

◆ operator PropertyType()

operator PropertyType ( )
inline

Convenience overload of getValue().

Usage:

std::string val = getProperty<std::string>("myProp");

Definition at line 141 of file Property.h.

+ Here is the call graph for this function:

The documentation for this class was generated from the following file:
armarx::Property::getValue
PropertyType getValue()
Returns the property value set in a config file or passed as a command-line option.
Definition: Property.h:207
armarx::Property::Property
Property(PropertyDefinition< PropertyType > definition, std::string prefix, Ice::PropertiesPtr properties)
Property constructor.
Definition: Property.h:193
armarx::Property::isRequired
bool isRequired() const
Checks if this property is required.
Definition: Property.h:216