General parameter type for member variables of a pre-specified class. More...
#include <parameter.hpp>
Public Member Functions | |
operator const T & () const | |
const T & | operator() () const |
void | operator() (const T &value) |
void | operator= (const T &value) |
Allow assignment from the underlying type. | |
Parameter () | |
Parameter (const T &value) | |
virtual | ~Parameter () |
Private Attributes | |
T | parameter |
General parameter type for member variables of a pre-specified class.
A Parameter is a templatised construct that formally defines an interface to a simple type embedded in a class.
Usage:
Definition:
class A { public: Parameter<int> counter; };
and usage (like get/set, but much less verbose):
int main() { A a; a.counter(1); // <-- Sets the variable. a.counter = 1; // <-- This is also ok. cout << a.counter(); << endl; // <-- Gets the variable. }
Definition at line 56 of file parameter.hpp.
ecl::Parameter< T >::Parameter | ( | ) | [inline, explicit] |
Definition at line 58 of file parameter.hpp.
ecl::Parameter< T >::Parameter | ( | const T & | value | ) | [inline] |
Configures the parameter with the type's default value. Configures the parameter with a specified value.
value | : the value to instantiate the parameter with. |
Definition at line 63 of file parameter.hpp.
virtual ecl::Parameter< T >::~Parameter | ( | ) | [inline, virtual] |
Definition at line 65 of file parameter.hpp.
ecl::Parameter< T >::operator const T & | ( | ) | const [inline] |
Convenience operator so that it can be treated as a normal variable if you wish (i.e. no () call needed). Note that we do not permit the returned reference to be modified as doing so would mean this class loses control of the variable.
Definition at line 87 of file parameter.hpp.
const T& ecl::Parameter< T >::operator() | ( | ) | const [inline] |
Formal access to the parameter's variable. Note that we do not permit the returned reference to be modified as doing so would mean this class loses control of the variable.
Definition at line 99 of file parameter.hpp.
void ecl::Parameter< T >::operator() | ( | const T & | value | ) | [inline] |
Formal setting operator for the parameter's variable. Note that we dont need the reference here since we're copying into the private variable - you get the same number of constructions either way.
value | : the value to configure the internal variable with. |
Definition at line 107 of file parameter.hpp.
void ecl::Parameter< T >::operator= | ( | const T & | value | ) | [inline] |
Allow assignment from the underlying type.
Note that this does not help with conversions for construction (or in argument passing to functions, because that is construction also).
value | : the value to configure the internal variable with. |
Definition at line 78 of file parameter.hpp.
T ecl::Parameter< T >::parameter [private] |
Definition at line 110 of file parameter.hpp.