charon-core  0.3.1
Parameter< T > Class Template Reference

Implementation of the AbstractParameter interface for one single parameter. More...

#include <charon-core/Parameter.h>

Inheritance diagram for Parameter< T >:

Public Member Functions

 Parameter (T defaultValue=T())
 Create parameter. More...
 
virtual std::string getDefaultString ()
 Get default value. More...
 
virtual std::string guessType () const
 Try to guess type. More...
 
virtual void intoStream (std::ostream &os) const
 Inserts the value of the Parameter at the end of a stream. More...
 
virtual void load (const ParameterFile &pf)
 Load from ParameterFile. More...
 
virtual operator T () const
 Cast operator to get internal value.
 
virtual const T & operator() () const
 Call operator. More...
 
virtual T & operator() ()
 Call operator. More...
 
virtual T & operator= (const T &B)
 Assignment operator for internal value. More...
 
virtual Parameter< T > & operator= (const Parameter< T > &B)
 Assign new current and default value. More...
 
virtual void save (ParameterFile &pf) const
 Save to ParameterFile. More...
 
void setDefault (const T &value)
 Set default value. More...
 
- Public Member Functions inherited from AbstractParameter
std::string getName () const
 Get parameter name.
 
ParameteredObjectgetParent ()
 get parent object
 
const ParameteredObjectgetParent () const
 get parent object (const version)
 
void init (ParameteredObject *parent, const std::string &name)
 Initialize new parameter. More...
 

Private Attributes

_defaultValue
 default value
 
_value
 current value
 

Additional Inherited Members

- Protected Member Functions inherited from AbstractParameter
std::string _followLink (const ParameterFile &pf, const std::string paramName) const
 Follow reference to targeted parameter. More...
 
- Protected Attributes inherited from AbstractParameter
std::string _name
 Parameter name.
 
ParameteredObject_parent
 Parent ParameteredObject.
 

Detailed Description

template<typename T>
class Parameter< T >

Definition at line 153 of file Parameter.h.

Constructor & Destructor Documentation

template<typename T>
Parameter< T >::Parameter ( defaultValue = T())

_defaultValue and _value are set to the given defaultValue.

Parameters
defaultValueNew default and current value.

Definition at line 45 of file Parameter.hxx.

Member Function Documentation

template<typename T >
std::string Parameter< T >::getDefaultString ( )
virtual

This string representation will be saved in the metadata parameter file.

Returns
default value string

Implements AbstractParameter.

Definition at line 118 of file Parameter.hxx.

template<typename T >
std::string Parameter< T >::guessType ( ) const
virtual
Returns
string representation of T

Implements AbstractParameter.

Definition at line 78 of file Parameter.hxx.

References TypeDetector::type().

template<typename T >
void Parameter< T >::intoStream ( std::ostream &  os) const
virtual
See Also
AbstractParameter::intoStream()
Parameters
osStream ot insert the value in

Implements AbstractParameter.

Definition at line 125 of file Parameter.hxx.

template<typename T >
void Parameter< T >::load ( const ParameterFile pf)
virtual

This restores the value from the paremeter named "name"."_name" in the given parameter file.

Parameters
pfParameterFile to load from.

Implements AbstractParameter.

Definition at line 109 of file Parameter.hxx.

References ParameterFile::get(), and ParameterFile::isSet().

template<typename T >
const T & Parameter< T >::operator() ( ) const
virtual
Returns
data content (const reference, no copy)

Implements AbstractROData< T >.

Definition at line 83 of file Parameter.hxx.

template<typename T >
T & Parameter< T >::operator() ( )
virtual

Non const version

Returns
data content (no copy)

Implements AbstractData< T >.

Definition at line 88 of file Parameter.hxx.

template<typename T>
T & Parameter< T >::operator= ( const T &  B)
virtual

This modifies only the current value.

Parameters
BValue to assign.
Returns
updated object

Implements AbstractData< T >.

Definition at line 55 of file Parameter.hxx.

template<typename T>
Parameter< T > & Parameter< T >::operator= ( const Parameter< T > &  B)
virtual

by copying an existing parameter (which has not to be assigned to some object)

Parameters
BCopy source
Returns
updated object

Definition at line 66 of file Parameter.hxx.

References Parameter< T >::_defaultValue, and Parameter< T >::_value.

template<typename T >
void Parameter< T >::save ( ParameterFile pf) const
virtual

This stores the value to the paremeter name parent_name._name in the given parameter file. If the parameter has not been changed (i.e. has the same value as its default value), the parameter string will not be written to the parameter file.

Parameters
pfParameterFile to write to.

Implements AbstractParameter.

Definition at line 93 of file Parameter.hxx.

References ParameterFile::erase(), ParameterFile::get(), ParameterFile::isSet(), and ParameterFile::set().

template<typename T>
void Parameter< T >::setDefault ( const T &  value)
Parameters
valueNew default value

Definition at line 61 of file Parameter.hxx.


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