A parameter class. More...
#include <sdf/sdf.hh>
Public Member Functions | |
Param (const Param &_param) | |
Copy constructor Note that the updateFunc member does not get copied. | |
Param (const std::string &_key, const std::string &_typeName, const std::string &_default, bool _required, const std::string &_description="") | |
Constructor. | |
Param (const std::string &_key, const std::string &_typeName, const std::string &_default, bool _required, const std::string &_minValue, const std::string &_maxValue, const std::string &_description="") | |
Constructor with min and max values. | |
Param (const std::string &_key, const std::string &_typeName, const std::string &_default, bool _required, const std::string &_minValue, const std::string &_maxValue, sdf::Errors &_errors, const std::string &_description="") | |
Constructor with min and max values. | |
Param (const std::string &_key, const std::string &_typeName, const std::string &_default, bool _required, sdf::Errors &_errors, const std::string &_description="") | |
Constructor. | |
Param (Param &&_param) noexcept=default | |
Move constructor. | |
virtual | ~Param () |
Destructor. | |
ParamPtr | Clone () const |
Clone the parameter. | |
template<typename T > | |
bool | Get (T &_value) const |
Get the value of the parameter. | |
template<typename T > | |
bool | Get (T &_value, sdf::Errors &_errors) const |
Get the value of the parameter. | |
bool | GetAny (std::any &_anyVal) const |
Get the value of the parameter as a std::any. | |
bool | GetAny (std::any &_anyVal, sdf::Errors &_errors) const |
Get the value of the parameter as a std::any. | |
std::string | GetAsString (const PrintConfig &_config=PrintConfig()) const |
Get the value as a string. | |
std::string | GetAsString (sdf::Errors &_errors, const PrintConfig &_config=PrintConfig()) const |
Get the value as a string. | |
template<typename T > | |
bool | GetDefault (T &_value) const |
Get the default value of the parameter. | |
template<typename T > | |
bool | GetDefault (T &_value, sdf::Errors &_errors) const |
Get the default value of the parameter. | |
std::string | GetDefaultAsString (const PrintConfig &_config=PrintConfig()) const |
Get the default value as a string. | |
std::string | GetDefaultAsString (sdf::Errors &_errors, const PrintConfig &_config=PrintConfig()) const |
Get the default value as a string. | |
std::string | GetDescription () const |
Get the description of the parameter. | |
const std::string & | GetKey () const |
Get the key value. | |
std::optional< std::string > | GetMaxValueAsString (const PrintConfig &_config=PrintConfig()) const |
Get the maximum allowed value as a string. | |
std::optional< std::string > | GetMaxValueAsString (sdf::Errors &_errors, const PrintConfig &_config=PrintConfig()) const |
Get the maximum allowed value as a string. | |
std::optional< std::string > | GetMinValueAsString (const PrintConfig &_config=PrintConfig()) const |
Get the minimum allowed value as a string. | |
std::optional< std::string > | GetMinValueAsString (sdf::Errors &_errors, const PrintConfig &_config=PrintConfig()) const |
Get the minimum allowed value as a string. | |
ElementPtr | GetParentElement () const |
Get the parent Element of this Param. | |
bool | GetRequired () const |
Return whether the parameter is required. | |
bool | GetSet () const |
Return true if the parameter has been set. | |
const std::string & | GetTypeName () const |
Get the type name value. | |
bool | IgnoresParentElementAttribute () const |
Return true if the parameter ignores the parent element's attributes, or if the parameter has no parent element. | |
template<typename Type > | |
bool | IsType () const |
Return true if the param is a particular type. | |
Param & | operator= (const Param &_param) |
Copy assignment operator Note that the updateFunc member will not get copied. | |
Param & | operator= (Param &&_param) noexcept=default |
Move assignment operator. | |
bool | Reparse () |
Reparse the parameter value. | |
bool | Reparse (sdf::Errors &_errors) |
Reparse the parameter value. | |
void | Reset () |
Reset the parameter to the default value. | |
template<typename T > | |
bool | Set (const T &_value) |
Set the parameter's value. | |
template<typename T > | |
bool | Set (const T &_value, sdf::Errors &_errors) |
Set the parameter's value. | |
void | SetDescription (const std::string &_desc) |
Set the description of the parameter. | |
bool | SetFromString (const std::string &_value) |
Set the parameter value from a string. | |
bool | SetFromString (const std::string &_value, bool _ignoreParentAttributes) |
Set the parameter value from a string. | |
bool | SetFromString (const std::string &_value, bool _ignoreParentAttributes, sdf::Errors &_errors) |
Set the parameter value from a string. | |
bool | SetFromString (const std::string &_value, sdf::Errors &_errors) |
Set the parameter value from a string. | |
bool | SetParentElement (ElementPtr _parentElement) |
Set the parent Element of this Param. | |
bool | SetParentElement (ElementPtr _parentElement, sdf::Errors &_errors) |
Set the parent Element of this Param. | |
template<typename T > | |
void | SetUpdateFunc (T _updateFunc) |
Set the update function. | |
void | Update () |
Set the parameter's value using the updateFunc. | |
void | Update (sdf::Errors &_errors) |
Set the parameter's value using the updateFunc. | |
bool | ValidateValue () const |
Validate the value against minimum and maximum allowed values. | |
bool | ValidateValue (sdf::Errors &_errors) const |
Validate the value against minimum and maximum allowed values. | |
A parameter class.
sdf::SDF_VERSION_NAMESPACE::Param::Param | ( | const std::string & | _key, |
const std::string & | _typeName, | ||
const std::string & | _default, | ||
bool | _required, | ||
const std::string & | _description = "" |
||
) |
Constructor.
[in] | _key | Key for the parameter. |
[in] | _typeName | String name for the value type (double, int,...). |
[in] | _default | Default value. |
[in] | _required | True if the parameter is required to be set. |
[in] | _description | Description of the parameter. |
sdf::AssertionInternalError | if an invalid type is given. |
sdf::SDF_VERSION_NAMESPACE::Param::Param | ( | const std::string & | _key, |
const std::string & | _typeName, | ||
const std::string & | _default, | ||
bool | _required, | ||
sdf::Errors & | _errors, | ||
const std::string & | _description = "" |
||
) |
Constructor.
[in] | _key | Key for the parameter. |
[in] | _typeName | String name for the value type (double, int,...). |
[in] | _default | Default value. |
[in] | _required | True if the parameter is required to be set. |
[out] | _errors | Vector of errors. |
[in] | _description | Description of the parameter. |
sdf::SDF_VERSION_NAMESPACE::Param::Param | ( | const std::string & | _key, |
const std::string & | _typeName, | ||
const std::string & | _default, | ||
bool | _required, | ||
const std::string & | _minValue, | ||
const std::string & | _maxValue, | ||
const std::string & | _description = "" |
||
) |
Constructor with min and max values.
[in] | _key | Key for the parameter. |
[in] | _typeName | String name for the value type (double, int,...). |
[in] | _default | Default value. |
[in] | _required | True if the parameter is required to be set. |
[in] | _minValue | Minimum allowed value for the parameter. |
[in] | _maxValue | Maximum allowed value for the parameter. |
[in] | _description | Description of the parameter. |
sdf::AssertionInternalError | if an invalid type is given. |
sdf::SDF_VERSION_NAMESPACE::Param::Param | ( | const std::string & | _key, |
const std::string & | _typeName, | ||
const std::string & | _default, | ||
bool | _required, | ||
const std::string & | _minValue, | ||
const std::string & | _maxValue, | ||
sdf::Errors & | _errors, | ||
const std::string & | _description = "" |
||
) |
Constructor with min and max values.
[in] | _key | Key for the parameter. |
[in] | _typeName | String name for the value type (double, int,...). |
[in] | _default | Default value. |
[in] | _required | True if the parameter is required to be set. |
[in] | _minValue | Minimum allowed value for the parameter. |
[in] | _maxValue | Maximum allowed value for the parameter. |
[out] | _errors | Vector of errors. |
[in] | _description | Description of the parameter. |
sdf::SDF_VERSION_NAMESPACE::Param::Param | ( | const Param & | _param | ) |
Copy constructor Note that the updateFunc member does not get copied.
[in] | _param | Param to copy |
|
defaultnoexcept |
Move constructor.
[in] | _param | Param to move from |
|
virtual |
Destructor.
ParamPtr sdf::SDF_VERSION_NAMESPACE::Param::Clone | ( | ) | const |
Clone the parameter.
bool sdf::SDF_VERSION_NAMESPACE::Param::Get | ( | T & | _value | ) | const |
Get the value of the parameter.
[out] | _value | The value of the parameter. |
References sdferr.
bool sdf::SDF_VERSION_NAMESPACE::Param::Get | ( | T & | _value, |
sdf::Errors & | _errors | ||
) | const |
Get the value of the parameter.
[out] | _value | The value of the parameter. |
[out] | _errors | Vector of errors. |
References GetAsString(), and sdf::SDF_VERSION_NAMESPACE::UNKNOWN_PARAMETER_TYPE.
bool sdf::SDF_VERSION_NAMESPACE::Param::GetAny | ( | std::any & | _anyVal | ) | const |
Get the value of the parameter as a std::any.
[out] | _anyVal | The std::any object to set. |
bool sdf::SDF_VERSION_NAMESPACE::Param::GetAny | ( | std::any & | _anyVal, |
sdf::Errors & | _errors | ||
) | const |
Get the value of the parameter as a std::any.
[out] | _anyVal | The std::any object to set. |
[out] | _errors | Vector of errors. |
std::string sdf::SDF_VERSION_NAMESPACE::Param::GetAsString | ( | const PrintConfig & | _config = PrintConfig() | ) | const |
Get the value as a string.
[in] | _config | Configuration for conversion to string. |
Referenced by Get().
std::string sdf::SDF_VERSION_NAMESPACE::Param::GetAsString | ( | sdf::Errors & | _errors, |
const PrintConfig & | _config = PrintConfig() |
||
) | const |
Get the value as a string.
[out] | _errors | Vector of errors. |
[in] | _config | Configuration for conversion to string. |
bool sdf::SDF_VERSION_NAMESPACE::Param::GetDefault | ( | T & | _value | ) | const |
Get the default value of the parameter.
[out] | _value | The default value of the parameter. |
References sdferr.
bool sdf::SDF_VERSION_NAMESPACE::Param::GetDefault | ( | T & | _value, |
sdf::Errors & | _errors | ||
) | const |
Get the default value of the parameter.
[out] | _value | The default value of the parameter. |
[out] | _errors | Vector of errors. |
References sdf::SDF_VERSION_NAMESPACE::PARAMETER_ERROR.
std::string sdf::SDF_VERSION_NAMESPACE::Param::GetDefaultAsString | ( | const PrintConfig & | _config = PrintConfig() | ) | const |
Get the default value as a string.
[in] | _config | Configuration for conversion to string. |
std::string sdf::SDF_VERSION_NAMESPACE::Param::GetDefaultAsString | ( | sdf::Errors & | _errors, |
const PrintConfig & | _config = PrintConfig() |
||
) | const |
Get the default value as a string.
[out] | _errors | Vector of errors. |
[in] | _config | Configuration for conversion to string. |
std::string sdf::SDF_VERSION_NAMESPACE::Param::GetDescription | ( | ) | const |
Get the description of the parameter.
const std::string & sdf::SDF_VERSION_NAMESPACE::Param::GetKey | ( | ) | const |
Get the key value.
std::optional< std::string > sdf::SDF_VERSION_NAMESPACE::Param::GetMaxValueAsString | ( | const PrintConfig & | _config = PrintConfig() | ) | const |
Get the maximum allowed value as a string.
[in] | _config | Configuration for conversion to string. |
std::optional< std::string > sdf::SDF_VERSION_NAMESPACE::Param::GetMaxValueAsString | ( | sdf::Errors & | _errors, |
const PrintConfig & | _config = PrintConfig() |
||
) | const |
Get the maximum allowed value as a string.
[in] | _config | Configuration for conversion to string. |
[out] | _errors | Vector of errors. |
std::optional< std::string > sdf::SDF_VERSION_NAMESPACE::Param::GetMinValueAsString | ( | const PrintConfig & | _config = PrintConfig() | ) | const |
Get the minimum allowed value as a string.
[in] | _config | Configuration for conversion to string. |
std::optional< std::string > sdf::SDF_VERSION_NAMESPACE::Param::GetMinValueAsString | ( | sdf::Errors & | _errors, |
const PrintConfig & | _config = PrintConfig() |
||
) | const |
Get the minimum allowed value as a string.
[out] | _errors | Vector of errors. |
[in] | _config | Configuration for conversion to string. |
ElementPtr sdf::SDF_VERSION_NAMESPACE::Param::GetParentElement | ( | ) | const |
bool sdf::SDF_VERSION_NAMESPACE::Param::GetRequired | ( | ) | const |
Return whether the parameter is required.
bool sdf::SDF_VERSION_NAMESPACE::Param::GetSet | ( | ) | const |
Return true if the parameter has been set.
const std::string & sdf::SDF_VERSION_NAMESPACE::Param::GetTypeName | ( | ) | const |
Get the type name value.
bool sdf::SDF_VERSION_NAMESPACE::Param::IgnoresParentElementAttribute | ( | ) | const |
Return true if the parameter ignores the parent element's attributes, or if the parameter has no parent element.
bool sdf::SDF_VERSION_NAMESPACE::Param::IsType | ( | ) | const |
Return true if the param is a particular type.
Copy assignment operator Note that the updateFunc member will not get copied.
[in] | _param | The parameter to set values from. |
bool sdf::SDF_VERSION_NAMESPACE::Param::Reparse | ( | ) |
Reparse the parameter value.
This should be called after the parent element's attributes have been modified, in the event that the value was set using SetFromString or posesses a default value, and that the final parsed value is dependent on the attributes of the parent element. For example, the rotation component of a pose element can be parsed as degrees or radians, depending on the attribute @degrees of the parent element. If however the value was explicitly set using the Set<T> function, reparsing would not change the value.
bool sdf::SDF_VERSION_NAMESPACE::Param::Reparse | ( | sdf::Errors & | _errors | ) |
Reparse the parameter value.
This should be called after the parent element's attributes have been modified, in the event that the value was set using SetFromString or posesses a default value, and that the final parsed value is dependent on the attributes of the parent element. For example, the rotation component of a pose element can be parsed as degrees or radians, depending on the attribute @degrees of the parent element. If however the value was explicitly set using the Set<T> function, reparsing would not change the value.
[out] | _errors | Vector of errors. |
void sdf::SDF_VERSION_NAMESPACE::Param::Reset | ( | ) |
Reset the parameter to the default value.
bool sdf::SDF_VERSION_NAMESPACE::Param::Set | ( | const T & | _value | ) |
Set the parameter's value.
The passed in value value must have an input and output stream operator.
[in] | _value | The value to set the parameter to. |
References sdferr.
bool sdf::SDF_VERSION_NAMESPACE::Param::Set | ( | const T & | _value, |
sdf::Errors & | _errors | ||
) |
Set the parameter's value.
The passed in value value must have an input and output stream operator.
[in] | _value | The value to set the parameter to. |
[out] | _errors | Vector of errors. |
References sdf::SDF_VERSION_NAMESPACE::PARAMETER_ERROR, and SetFromString().
void sdf::SDF_VERSION_NAMESPACE::Param::SetDescription | ( | const std::string & | _desc | ) |
Set the description of the parameter.
[in] | _desc | New description for the parameter. |
bool sdf::SDF_VERSION_NAMESPACE::Param::SetFromString | ( | const std::string & | _value | ) |
Set the parameter value from a string.
[in] | _value | New value for the parameter in string form. |
bool sdf::SDF_VERSION_NAMESPACE::Param::SetFromString | ( | const std::string & | _value, |
bool | _ignoreParentAttributes | ||
) |
Set the parameter value from a string.
[in] | _value | New value for the parameter in string form. |
[in] | _ignoreParentAttributes | Whether to ignore parent element attributes when parsing value from string as well as subsequent reparses. |
Referenced by Set().
bool sdf::SDF_VERSION_NAMESPACE::Param::SetFromString | ( | const std::string & | _value, |
bool | _ignoreParentAttributes, | ||
sdf::Errors & | _errors | ||
) |
Set the parameter value from a string.
[in] | _value | New value for the parameter in string form. |
[in] | _ignoreParentAttributes | Whether to ignore parent element |
[out] | _errors | Vector of errors. attributes when parsing value from string as well as subsequent reparses. |
bool sdf::SDF_VERSION_NAMESPACE::Param::SetFromString | ( | const std::string & | _value, |
sdf::Errors & | _errors | ||
) |
Set the parameter value from a string.
[in] | _value | New value for the parameter in string form. |
[out] | _errors | Vector of errors. |
bool sdf::SDF_VERSION_NAMESPACE::Param::SetParentElement | ( | ElementPtr | _parentElement | ) |
bool sdf::SDF_VERSION_NAMESPACE::Param::SetParentElement | ( | ElementPtr | _parentElement, |
sdf::Errors & | _errors | ||
) |
void sdf::SDF_VERSION_NAMESPACE::Param::SetUpdateFunc | ( | T | _updateFunc | ) |
Set the update function.
The updateFunc will be used to set the parameter's value when Param::Update is called.
[in] | _updateFunc | Function pointer to an update function. |
void sdf::SDF_VERSION_NAMESPACE::Param::Update | ( | ) |
Set the parameter's value using the updateFunc.
void sdf::SDF_VERSION_NAMESPACE::Param::Update | ( | sdf::Errors & | _errors | ) |
Set the parameter's value using the updateFunc.
[out] | _errors | Vector of errors. |
bool sdf::SDF_VERSION_NAMESPACE::Param::ValidateValue | ( | ) | const |
Validate the value against minimum and maximum allowed values.
bool sdf::SDF_VERSION_NAMESPACE::Param::ValidateValue | ( | sdf::Errors & | _errors | ) | const |
Validate the value against minimum and maximum allowed values.
[out] | _errors | Vector of errors. |