HerkuleXLib
1.1
Arduino library to drive HerkuleX DRS-0101 and DRS-0201
|
Class to manage optional parameters. More...
#include <HkxCommunication.h>
Public Member Functions | |
HkxMaybe () | |
Default constructor. More... | |
HkxMaybe (hkxMaybeHasNoValue noValue) | |
Empty constructor. More... | |
HkxMaybe (T value) | |
Copy value constructor. More... | |
HkxMaybe (T *addressValue) | |
Pointer value constructor. More... | |
~HkxMaybe () | |
Default destructor. More... | |
bool | isEmpty () const |
Check if empty. More... | |
T & | getValue () const |
Get the value. More... | |
void | setValue (T value) |
Set the value. More... | |
Private Attributes | |
const bool | _empty |
T *const | _value |
Class to manage optional parameters.
This class manages the optional parameters of the functions in order to avoid null pointer approach.
Default constructor.
The default constructor of HkxMaybe creates an empty parameter.
|
inline |
Empty constructor.
The empty constructor of HkxMaybe using HKX_NO_VALUE
in order to simplify the writing of the code.
A function
can be called with an empty parameter.
This constructor allow the simpler implementation thanks to the implicit conversion.
[in] | noValue | : this parameter can only have the value HKX_NO_VALUE . |
Copy value constructor.
This constructor is used for input optional parameters of function. Its value is copied and then cannot be returned when using implicit conversion.
[in] | value | : value of any type. |
Pointer value constructor.
This constructor is used for output optional parameters of function. Its value is pointed and then can be returned when using implicit conversion.
[in] | addressValue | : address of the value (any type). |
Default destructor.
The destructor delete the pointed value.
|
inline |
Get the value.
Get the value of the parameter if it has one.
nothing
if the parameter is empty. a
copy of the value if the parameter has one.
|
inline |
Check if empty.
Check if the parameter is empty or if it contains a value.
true
if the parameter is empty. false
if the parameter contains a value.
|
inline |
Set the value.
Set the value of the parameter if it is not empty. This member shall be use only when it was created with the pointer value constructor (for output optionnal parameter).
[in] | value | : value to copy to the pointed value if the parameter is not empty. |
|
private |
If empty => parameter to considered
|
private |
Value of the parameter (if not empty)