A parameter class. More...
#include <sdf/sdf.hh>
Public Member Functions | |
| Param (const std::string &_key, const std::string &_typeName, const std::string &_default, bool _required, const std::string &_description="") | |
| Constructor. More... | |
| 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. More... | |
| Param (const Param &_param) | |
| Copy constructor Note that the updateFunc member does not get copied. More... | |
| Param (Param &&_param) noexcept=default | |
| Move constructor. More... | |
| virtual | ~Param () |
| Destructor. More... | |
| ParamPtr | Clone () const |
| Clone the parameter. More... | |
| template<typename T > | |
| bool | Get (T &_value) const |
| Get the value of the parameter. More... | |
| bool | GetAny (std::any &_anyVal) const |
| Get the value of the parameter as a std::any. More... | |
| std::string | GetAsString () const |
| Get the value as a string. More... | |
| template<typename T > | |
| bool | GetDefault (T &_value) const |
| Get the default value of the parameter. More... | |
| std::string | GetDefaultAsString () const |
| Get the default value as a string. More... | |
| std::string | GetDescription () const |
| Get the description of the parameter. More... | |
| const std::string & | GetKey () const |
| Get the key value. More... | |
| std::optional< std::string > | GetMaxValueAsString () const |
| Get the maximum allowed value as a string. More... | |
| std::optional< std::string > | GetMinValueAsString () const |
| Get the minimum allowed value as a string. More... | |
| bool | GetRequired () const |
| Return whether the parameter is required. More... | |
| bool | GetSet () const |
| Return true if the parameter has been set. More... | |
| const std::string & | GetTypeName () const |
| Get the type name value. More... | |
| template<typename Type > | |
| bool | IsType () const |
| Return true if the param is a particular type. More... | |
| Param & | operator= (const Param &_param) |
| Copy assignment operator Note that the updateFunc member will not get copied. More... | |
| Param & | operator= (Param &&_param) noexcept=default |
| Move assignment operator. More... | |
| void | Reset () |
| Reset the parameter to the default value. More... | |
| template<typename T > | |
| bool | Set (const T &_value) |
| Set the parameter's value. More... | |
| void | SetDescription (const std::string &_desc) |
| Set the description of the parameter. More... | |
| bool | SetFromString (const std::string &_value) |
| Set the parameter value from a string. More... | |
| template<typename T > | |
| void | SetUpdateFunc (T _updateFunc) |
| Set the update function. More... | |
| void | Update () |
| Set the parameter's value using the updateFunc. More... | |
| bool | ValidateValue () const |
| Validate the value against minimum and maximum allowed values. More... | |
Friends | |
| std::ostream & | operator<< (std::ostream &_out, const Param &_p) |
| Ostream operator. More... | |
A parameter class.
| sdf::v11::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::v11::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::v11::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::v11::Param::Clone | ( | ) | const |
Clone the parameter.
| bool sdf::v11::Param::Get | ( | T & | _value | ) | const |
Get the value of the parameter.
| [out] | _value | The value of the parameter. |
References sdferr.
| bool sdf::v11::Param::GetAny | ( | std::any & | _anyVal | ) | const |
Get the value of the parameter as a std::any.
| [out] | _anyVal | The std::any object to set. |
| std::string sdf::v11::Param::GetAsString | ( | ) | const |
Get the value as a string.
| bool sdf::v11::Param::GetDefault | ( | T & | _value | ) | const |
Get the default value of the parameter.
| [out] | _value | The default value of the parameter. |
References sdferr.
| std::string sdf::v11::Param::GetDefaultAsString | ( | ) | const |
Get the default value as a string.
| std::string sdf::v11::Param::GetDescription | ( | ) | const |
Get the description of the parameter.
| const std::string& sdf::v11::Param::GetKey | ( | ) | const |
Get the key value.
| std::optional<std::string> sdf::v11::Param::GetMaxValueAsString | ( | ) | const |
Get the maximum allowed value as a string.
| std::optional<std::string> sdf::v11::Param::GetMinValueAsString | ( | ) | const |
Get the minimum allowed value as a string.
| bool sdf::v11::Param::GetRequired | ( | ) | const |
Return whether the parameter is required.
| bool sdf::v11::Param::GetSet | ( | ) | const |
Return true if the parameter has been set.
| const std::string& sdf::v11::Param::GetTypeName | ( | ) | const |
Get the type name value.
| bool sdf::v11::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. |
| void sdf::v11::Param::Reset | ( | ) |
Reset the parameter to the default value.
| bool sdf::v11::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.
| void sdf::v11::Param::SetDescription | ( | const std::string & | _desc | ) |
Set the description of the parameter.
| [in] | _desc | New description for the parameter. |
| bool sdf::v11::Param::SetFromString | ( | const std::string & | _value | ) |
Set the parameter value from a string.
| [in] | _value | New value for the parameter in string form. |
| void sdf::v11::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::v11::Param::Update | ( | ) |
Set the parameter's value using the updateFunc.
| bool sdf::v11::Param::ValidateValue | ( | ) | const |
Validate the value against minimum and maximum allowed values.
|
friend |
Ostream operator.
Outputs the parameter's value.
| [in] | _out | Output stream. |
| [in] | _p | The parameter to output. |