Public Member Functions | Private Attributes | List of all members
ecl::Parameter< T > Class Template Reference

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. More...
 
 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 60 of file parameter.hpp.

Constructor & Destructor Documentation

◆ Parameter() [1/2]

template<typename T >
ecl::Parameter< T >::Parameter ( )
inlineexplicit

Definition at line 68 of file parameter.hpp.

◆ Parameter() [2/2]

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 73 of file parameter.hpp.

◆ ~Parameter()

template<typename T >
virtual ecl::Parameter< T >::~Parameter ( )
inlinevirtual

Definition at line 75 of file parameter.hpp.

Member Function Documentation

◆ operator const T &()

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 97 of file parameter.hpp.

◆ operator()() [1/2]

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 109 of file parameter.hpp.

◆ operator()() [2/2]

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 117 of file parameter.hpp.

◆ operator=()

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 88 of file parameter.hpp.

Member Data Documentation

◆ parameter

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

Definition at line 120 of file parameter.hpp.


The documentation for this class was generated from the following file:
main
int main(int argc, char **argv)


ecl_utilities
Author(s): Daniel Stonier
autogenerated on Wed Mar 2 2022 00:16:32