Changes between Initial Version and Version 1 of TutorialAddingNewParameter


Ignore:
Timestamp:
Nov 20, 2013, 11:53:44 AM (11 years ago)
Author:
Marek Kurdej
Comment:

created

Legend:

Unmodified
Added
Removed
Modified
  • TutorialAddingNewParameter

    v1 v1  
     1= Adding new parameter =
     2
     3Let us suppose that we want to add two new parameters to our component.
     4First parameter, named "integer-value" of type ```int``` will be obligatory (required).
     5Second 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.
     6
     71. Add member fields to your component which will contain parameter values.
     8
     9For instance, your class can look like:
     10
     11{{{
     12class MyComponent
     13{
     14public:
     15    // ...
     16
     17private:
     18    int mInteger;
     19    double mDouble;
     20};
     21}}}
     22
     232. Invoke ```addParameters()``` in your component constructor.
     24This function returns an object that allows you to add parameters.
     25Then, '''after ```()```''', add parameters:
     26
     27For a ''required'' parameter: add a line like ```("parameter-name", value<!ParameterType>(&variableToSetWithParameterValue)->required(), "parameter description"```.
     28
     29For a ''defaulted'' parameter: add a line like ```("parameter-name", value<!ParameterType>(&variableToSetWithParameterValue)->default_value(kDefaultParameterValue), "parameter description"```.
     30
     31{{{
     32addParameters()
     33("integer-value", value<int>(&mInteger)->required(), "integer value for test")
     34("floating-point-value", value<double>(&mDouble)->default_value(kDefaultMemoryName), "floating-point value for test")
     35;
     36}}}