Version 1 (modified by 11 years ago) ( diff ) | ,
---|
Adding new parameter
Let us suppose that we want to add two new parameters to our component.
First parameter, named "integer-value" of type int
will be obligatory (required).
Second one, named "floating-point-value" of type
double
will be defaulted (we will provide a default value and the user will not be obliged to set it.
- Add member fields to your component which will contain parameter values.
For instance, your class can look like:
class MyComponent { public: // ... private: int mInteger; double mDouble; };
- Invoke
addParameters()
in your component constructor.
This function returns an object that allows you to add parameters.
Then, after ()
, add parameters:
For a required parameter: add a line like ("parameter-name", value<!ParameterType>(&variableToSetWithParameterValue)->required(), "parameter description"
.
For a defaulted parameter: add a line like ("parameter-name", value<!ParameterType>(&variableToSetWithParameterValue)->default_value(kDefaultParameterValue), "parameter description"
.
addParameters() ("integer-value", value<int>(&mInteger)->required(), "integer value for test") ("floating-point-value", value<double>(&mDouble)->default_value(kDefaultMemoryName), "floating-point value for test") ;