HyperspaceExplorer 0.7.1
|
A parameter to a Function with a name, an optional description and a default. More...
#include <FunctionParameter.h>
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::string & | getName () const |
get the name of the function parameter | |
void | setName (const std::string &name) |
set the name of the function parameter | |
const std::string & | getDescription () 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. |
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.
FunctionParameter::value_ptr_type FunctionParameter::defaultValue | ( | ) | const |
References _defaultValue.
Referenced by setDefaultValue().
void FunctionParameter::setDefaultValue | ( | FunctionParameter::value_ptr_type | defaultValue | ) |
set the default value of the parameter.
Requires a pointer created by FunctionParameterFactory::createParameterWithDefault().
References _defaultValue, and defaultValue().
void FunctionParameter::setValue | ( | FunctionParameter::value_ptr_type | value | ) |
set the value of the parameter.
Requires a pointer created by FunctionParameterFactory::createParameterWithValue().
References _value, and value().
FunctionParameter::value_ptr_type FunctionParameter::value | ( | ) | const |
References _value.
Referenced by UI::Dialogs::ParameterInputFactory::create(), and setValue().