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 >, T > getValueAndReplaceAllVars ()
 
template<class T = PropertyType>
std::enable_if_t< std::is_same_v< T, std::vector< std::string > >, T > getValueAndReplaceAllVars ()
 
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

Member Typedef Documentation

◆ PropertyValuesMap

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

Property value map type definition.

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.

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

◆ getValueAndReplaceAllVars() [1/2]

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

◆ 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

◆ 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

◆ isRequired()

template<typename PropertyType>
bool isRequired ( ) const

Checks if this property is required.

Returns
true if set required, otherwise false

◆ isSet()

template<typename PropertyType>
bool isSet ( ) const

Checks whether the property is set.

Returns
true if property is set, otheriwse false

◆ operator PropertyType()

template<typename PropertyType>
operator PropertyType ( )
inline

Convenience overload of getValue().

Usage:

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

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