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.
 

Public Member Functions

PropertyType getValue ()
 Returns the property value set in a config file or passed as a command-line option.
 
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.
 
bool isRequired () const
 Checks if this property is required.
 
bool isSet () const
 Checks whether the property is set.
 
 operator PropertyType ()
 Convenience overload of getValue().
 
 Property (PropertyDefinition< PropertyType > definition, std::string prefix, Ice::PropertiesPtr properties)
 Property constructor.
 

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();
}
PropertyType getValue()
Returns the property value set in a config file or passed as a command-line option.
Definition Property.h:203
Property(PropertyDefinition< PropertyType > definition, std::string prefix, Ice::PropertiesPtr properties)
Property constructor.
Definition Property.h:193
bool isRequired() const
Checks if this property is required.
Definition Property.h:211

Definition at line 78 of file Property.h.

Member Typedef Documentation

◆ PropertyValuesMap

template<typename PropertyType>
typedef PropertyDefinition<PropertyType>::PropertyValuesMap PropertyValuesMap

Property value map type definition.

Definition at line 84 of file Property.h.

Constructor & Destructor Documentation

◆ Property()

template<typename PropertyType>
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()

template<typename PropertyType>
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 203 of file Property.h.

+ Here is the caller graph for this function:

◆ getValueAndReplaceAllVars() [1/2]

template<typename PropertyType>
template<class T = PropertyType>
std::enable_if_t< std::is_same_v< T, std::string >, T > getValueAndReplaceAllVars ( )
inline

Definition at line 148 of file Property.h.

+ Here is the call graph for this function:

◆ getValueAndReplaceAllVars() [2/2]

template<typename PropertyType>
template<class T = PropertyType>
std::enable_if_t< std::is_same_v< T, std::vector< std::string > >, T > getValueAndReplaceAllVars ( )
inline

Definition at line 156 of file Property.h.

+ Here is the call graph for this function:

◆ isConstant()

template<typename PropertyType>
bool isConstant ( ) const

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 219 of file Property.h.

◆ isRequired()

template<typename PropertyType>
bool isRequired ( ) const

Checks if this property is required.

Returns
true if set required, otherwise false

Definition at line 211 of file Property.h.

◆ isSet()

template<typename PropertyType>
bool isSet ( ) const

Checks whether the property is set.

Returns
true if property is set, otheriwse false

Definition at line 227 of file Property.h.

◆ operator PropertyType()

template<typename PropertyType>
operator PropertyType ( )
inline

Convenience overload of getValue().

Usage:

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

Definition at line 140 of file Property.h.

+ Here is the call graph for this function:

The documentation for this class was generated from the following file: