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... | |
virtual | ~Param () |
Destructor. More... | |
Param * | Clone () const |
Clone the parameter. More... | |
template<typename T > | |
bool | Get (T &_value) const |
Get the value of the parameter. More... | |
bool | GetAny (boost::any &_anyVal) const |
Get the value of the parameter as a boost::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... | |
bool | GetRequired () const |
Return whether the parameter is required. More... | |
bool | GetSet () const |
Return true if the parameter has been set. More... | |
const std::type_info & | GetType () const SDF_DEPRECATED(4.0) |
Get the type of the value stored. 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) |
Equal 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... | |
Friends | |
std::ostream & | operator<< (std::ostream &_out, const Param &_p) |
Ostream operator. More... | |
A parameter class.
sdf::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. |
|
virtual |
Destructor.
Param* sdf::Param::Clone | ( | ) | const |
Clone the parameter.
bool sdf::Param::Get | ( | T & | _value | ) | const |
Get the value of the parameter.
[out] | _value | The value of the parameter. |
References sdf::ParamPrivate::key, sdferr, sdf::ParamPrivate::typeName, and sdf::ParamPrivate::value.
Referenced by sdf::Element::Get().
bool sdf::Param::GetAny | ( | boost::any & | _anyVal | ) | const |
Get the value of the parameter as a boost::any.
[out] | _anyVal | The boost::any object to set. |
std::string sdf::Param::GetAsString | ( | ) | const |
Get the value as a string.
bool sdf::Param::GetDefault | ( | T & | _value | ) | const |
Get the default value of the parameter.
[out] | _value | The default value of the parameter. |
References sdf::ParamPrivate::defaultValue, sdf::ParamPrivate::key, sdferr, and sdf::ParamPrivate::typeName.
std::string sdf::Param::GetDefaultAsString | ( | ) | const |
Get the default value as a string.
std::string sdf::Param::GetDescription | ( | ) | const |
Get the description of the parameter.
const std::string& sdf::Param::GetKey | ( | ) | const |
Get the key value.
bool sdf::Param::GetRequired | ( | ) | const |
Return whether the parameter is required.
bool sdf::Param::GetSet | ( | ) | const |
Return true if the parameter has been set.
const std::type_info& sdf::Param::GetType | ( | ) | const |
Get the type of the value stored.
const std::string& sdf::Param::GetTypeName | ( | ) | const |
Get the type name value.
bool sdf::Param::IsType | ( | ) | const |
Return true if the param is a particular type.
References sdf::ParamPrivate::value.
Equal operator.
Set's the value and default value from the provided Param.
[in] | _param | The parameter to set values from. |
void sdf::Param::Reset | ( | ) |
Reset the parameter to the default value.
bool sdf::Param::Set | ( | const T & | _value | ) |
Set the parameter's value.
The passed in value must conform to the boost::lexical_cast spec. This means the value must have an input and output stream operator.
[in] | _value | The value to set the parameter to. |
References sdf::ParamPrivate::key, sdferr, and SetFromString().
Referenced by sdf::Element::Set().
void sdf::Param::SetDescription | ( | const std::string & | _desc | ) |
Set the description of the parameter.
[in] | _desc | New description for the parameter. |
bool sdf::Param::SetFromString | ( | const std::string & | _value | ) |
Set the parameter value from a string.
[in] | _value | New value for the parameter in string form. |
Referenced by Set().
void sdf::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. |
References sdf::ParamPrivate::updateFunc.
void sdf::Param::Update | ( | ) |
Set the parameter's value using the updateFunc.
|
friend |
Ostream operator.
Outputs the parameter's value.
[in] | _out | Output stream. |
[in] | _p | The parameter to output. |