Public Member Functions | Private Attributes
ecl::Parameter< T > Class Template Reference

General parameter type for member variables of a pre-specified class. More...

#include <parameter.hpp>

List of all members.

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

parameter

Detailed Description

template<typename T>
class ecl::Parameter< T >

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.
 }
See also:
src/test/core/parameters.cpp, Parameters

Definition at line 56 of file parameter.hpp.


Constructor & Destructor Documentation

template<typename T >
ecl::Parameter< T >::Parameter ( ) [inline, explicit]

Definition at line 58 of file parameter.hpp.

template<typename T >
ecl::Parameter< T >::Parameter ( const T &  value) [inline]

Configures the parameter with the type's default value. Configures the parameter with a specified value.

Parameters:
value: the value to instantiate the parameter with.

Definition at line 63 of file parameter.hpp.

template<typename T >
virtual ecl::Parameter< T >::~Parameter ( ) [inline, virtual]

Definition at line 65 of file parameter.hpp.


Member Function Documentation

template<typename T >
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.

Returns:
T& : a const reference to the parameter's variable.

Definition at line 87 of file parameter.hpp.

template<typename T >
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.

Returns:
T& : a reference to the parameter's variable.

Definition at line 99 of file parameter.hpp.

template<typename T >
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.

Parameters:
value: the value to configure the internal variable with.

Definition at line 107 of file parameter.hpp.

template<typename T >
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).

Parameters:
value: the value to configure the internal variable with.

Definition at line 78 of file parameter.hpp.


Member Data Documentation

template<typename T >
T ecl::Parameter< T >::parameter [private]

Definition at line 110 of file parameter.hpp.


The documentation for this class was generated from the following file:


ecl_utilities
Author(s): Daniel Stonier (d.stonier@gmail.com)
autogenerated on Thu Jan 2 2014 11:12:21