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