HyperspaceExplorer 0.7.1
Public Types | Public Member Functions | Private Attributes

A parameter to a Function with a name, an optional description and a default. More...

#include <FunctionParameter.h>

Collaboration diagram for FunctionParameter:
Collaboration graph
[legend]

List of all members.

Public Types

typedef std::shared_ptr
< FunctionParameterValueBase
value_ptr_type
 Pointer to the parameter's value.
typedef std::shared_ptr
< FunctionParameter
parameter_ptr_type
 Pointer to the parameter.

Public Member Functions

 FunctionParameter (const std::string &name, const std::string &description="")
 Construct a FunctionParameter from a name.
double toDouble () const
 Conversion to double.
unsigned toUnsigned () const
 Conversion to unsigned.
int toInt () const
 Conversion to int.
std::string toString () const
 Conversion to std::string.
VecMath::Rotation< 5 > toRotation5 () const
 Conversion to Rotation<5>
VecMath::Rotation< 6 > toRotation6 () const
 Conversion to Rotation<6>
VecMath::Rotation< 7 > toRotation7 () const
 Conversion to Rotation<7>
VecMath::Rotation< 8 > toRotation8 () const
 Conversion to Rotation<8>
VecMath::Rotation< 9 > toRotation9 () const
 Conversion to Rotation<9>
VecMath::Rotation< 10 > toRotation10 () const
 Conversion to Rotation<10>
const std::stringgetName () const
 get the name of the function parameter
void setName (const std::string &name)
 set the name of the function parameter
const std::stringgetDescription () const
 get the long description of the function parameter
void setDescription (const std::string &description)
 set the long description of the function parameter
void setValue (FunctionParameter::value_ptr_type value)
 set the value of the parameter.
void setValue (const std::string &newValue)
 Set a value from a string, as contained in a QLineEdit.
void setDefaultValue (FunctionParameter::value_ptr_type defaultValue)
 set the default value of the parameter.
FunctionParameter::value_ptr_type value () const
FunctionParameter::value_ptr_type defaultValue () const

Private Attributes

std::string _name
 Name of the function parameter.
std::string _description
 Description which is shown in the parameter input dialog.
FunctionParameter::value_ptr_type _value
 Pointer to FunctionParameterValue containing the parameter's value.
FunctionParameter::value_ptr_type _defaultValue
 Default parameter value is no value was given.

Detailed Description

A parameter to a Function with a name, an optional description and a default.

This class stores a FunctionParameterValue for the value of the parameter, and one for its default value. It also stores strings to provide the name of the parameter and one for the optional description.

It provides access to the parameter values through the type cast operators. These are delegated to the cast operators of the value member.

Write access is not so convenient, because it requires an object of type FunctionParameterValue<T>, which must be created with a call to ParameterFac::createParameterWithValue(). Pass that pointer to setValue().

There are also getters and setters for name and description, of course.

This class uses the Pimpl idiom to ensure encapsulation. It may do a bad job at it, this is my first go at a pimpl class. The data members are hidden in a private struct FunctionParameter::Impl.

See also:
FunctionParameterValueBase

Member Function Documentation

FunctionParameter::value_ptr_type FunctionParameter::defaultValue ( ) const
Returns:
Default parameter value is no value was given

References _defaultValue.

Referenced by setDefaultValue().

Here is the caller graph for this function:

void FunctionParameter::setDefaultValue ( FunctionParameter::value_ptr_type  defaultValue)

set the default value of the parameter.

Requires a pointer created by FunctionParameterFactory::createParameterWithDefault().

Todo:
Can't I call createParameterWithDefault() from inside setDefaultValue()?

References _defaultValue, and defaultValue().

Here is the call graph for this function:

void FunctionParameter::setValue ( FunctionParameter::value_ptr_type  value)

set the value of the parameter.

Requires a pointer created by FunctionParameterFactory::createParameterWithValue().

Todo:
Can't I call createParameterWithValue() from inside setValue()?

References _value, and value().

Here is the call graph for this function:

FunctionParameter::value_ptr_type FunctionParameter::value ( ) const
Returns:
Pointer to FunctionParameterValue containing the parameter's value

References _value.

Referenced by UI::Dialogs::ParameterInputFactory::create(), and setValue().

Here is the caller graph for this function:


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Friends

Generated on Mon Apr 9 2012 20:25:18 for HyperspaceExplorer 0.7.1 by doxygen 1.7.4  -  Hosted bySourceForge.net Logo