All Classes Namespaces Files Functions Variables Typedefs Friends Macros Groups Pages
Public Member Functions | Friends | List of all members
sdf::Param Class Reference

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...
 
ParamClone () 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...
 
Paramoperator= (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...
 

Detailed Description

A parameter class.

Constructor & Destructor Documentation

sdf::Param::Param ( const std::string &  _key,
const std::string &  _typeName,
const std::string &  _default,
bool  _required,
const std::string &  _description = "" 
)

Constructor.

Parameters
[in]_keyKey for the parameter.
[in]_typeNameString name for the value type (double, int,...).
[in]_defaultDefault value.
[in]_requiredTrue if the parameter is required to be set.
[in]_descriptionDescription of the parameter.
virtual sdf::Param::~Param ( )
virtual

Destructor.

Member Function Documentation

Param* sdf::Param::Clone ( ) const

Clone the parameter.

Returns
A new parameter that is the clone of this.
template<typename T >
bool sdf::Param::Get ( T &  _value) const

Get the value of the parameter.

Parameters
[out]_valueThe value of the parameter.
Returns
True if parameter was successfully cast to the value type passed in.

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.

Parameters
[out]_anyValThe boost::any object to set.
Returns
True if successfully set _anyVal, false otherwise.
std::string sdf::Param::GetAsString ( ) const

Get the value as a string.

Returns
String containing the value of the parameter.
template<typename T >
bool sdf::Param::GetDefault ( T &  _value) const

Get the default value of the parameter.

Parameters
[out]_valueThe default value of the parameter.
Returns
True if parameter was successfully cast to the value type passed in.

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.

Returns
String containing the default value of the parameter.
std::string sdf::Param::GetDescription ( ) const

Get the description of the parameter.

Returns
The description of the parameter.
const std::string& sdf::Param::GetKey ( ) const

Get the key value.

Returns
The key.
bool sdf::Param::GetRequired ( ) const

Return whether the parameter is required.

Returns
True if the parameter is required.
bool sdf::Param::GetSet ( ) const

Return true if the parameter has been set.

Returns
True if the parameter has been set.
const std::type_info& sdf::Param::GetType ( ) const

Get the type of the value stored.

Returns
The std::type_info.
Deprecated:
GetType is unstable. Use IsType().
See Also
IsType
const std::string& sdf::Param::GetTypeName ( ) const

Get the type name value.

Returns
The type name.
template<typename Type >
bool sdf::Param::IsType ( ) const

Return true if the param is a particular type.

Returns
True if the type held by this Param matches the Type template parameter.

References sdf::ParamPrivate::value.

Param& sdf::Param::operator= ( const Param _param)

Equal operator.

Set's the value and default value from the provided Param.

Parameters
[in]_paramThe parameter to set values from.
Returns
*This
void sdf::Param::Reset ( )

Reset the parameter to the default value.

template<typename T >
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.

Parameters
[in]_valueThe value to set the parameter to.
Returns
True if the value was successfully set.

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.

Parameters
[in]_descNew description for the parameter.
bool sdf::Param::SetFromString ( const std::string &  _value)

Set the parameter value from a string.

Parameters
[in]_valueNew value for the parameter in string form.

Referenced by Set().

template<typename T >
void sdf::Param::SetUpdateFunc ( _updateFunc)

Set the update function.

The updateFunc will be used to set the parameter's value when Param::Update is called.

Parameters
[in]_updateFuncFunction pointer to an update function.

References sdf::ParamPrivate::updateFunc.

void sdf::Param::Update ( )

Set the parameter's value using the updateFunc.

See Also
Param::SetUpdateFunc

Friends And Related Function Documentation

std::ostream& operator<< ( std::ostream &  _out,
const Param _p 
)
friend

Ostream operator.

Outputs the parameter's value.

Parameters
[in]_outOutput stream.
[in]_pThe parameter to output.
Returns
The output stream.

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