Jpp
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Types | Public Member Functions | Protected Attributes | Friends | List of all members
JLANG::JParameter< T > Class Template Reference

Parameter class. More...

#include <JParameter.hh>

Inheritance diagram for JLANG::JParameter< T >:
JLANG::JComparable< JParameter< T > >

Public Types

typedef JClass< T >::argument_type argument_type
 

Public Member Functions

 JParameter ()
 Default constructor. More...
 
 JParameter (argument_type value)
 Constructor. More...
 
JParameter< T > & operator= (argument_type value)
 Assignment operator. More...
 
const T & getValue () const
 Get value of parameter. More...
 
T & getValue ()
 Get value of parameter. More...
 
void setValue (argument_type value)
 Set value. More...
 
 operator const T & () const
 Type conversion operator. More...
 
 operator T & ()
 Type conversion operator. More...
 
const bool isDefined () const
 Get status of parameter. More...
 
bool less (const JParameter &parameter) const
 Less than method. More...
 

Protected Attributes

__value
 
bool is_defined
 

Friends

std::istream & operator>> (std::istream &in, JParameter< T > &parameter)
 Stream input. More...
 
std::ostream & operator<< (std::ostream &out, const JParameter< T > &parameter)
 Stream output. More...
 

Detailed Description

template<class T>
class JLANG::JParameter< T >

Parameter class.

This class is a simple wrapper around the template parameter with a status value. The status value indicates whether the parameter has been defined or not. A parameter is defined when a value has been assigned or correctly read. Note that the comparisons between parameter objects are based on the philosphy "undefined = any value". Hence, if any of the two parameter values is undefined, they are considered equal. The comparison between a paramater object with a template value is based on the internal value of the parameter object, regardless of its state.

Definition at line 32 of file JParameter.hh.

Member Typedef Documentation

template<class T>
typedef JClass<T>::argument_type JLANG::JParameter< T >::argument_type

Definition at line 37 of file JParameter.hh.

Constructor & Destructor Documentation

template<class T>
JLANG::JParameter< T >::JParameter ( )
inline

Default constructor.

Definition at line 42 of file JParameter.hh.

42  :
43  __value(),
44  is_defined(false)
45  {}
template<class T>
JLANG::JParameter< T >::JParameter ( argument_type  value)
inlineexplicit

Constructor.

Parameters
valuevalue

Definition at line 53 of file JParameter.hh.

53  :
54  __value(value),
55  is_defined(true)
56  {}

Member Function Documentation

template<class T>
JParameter<T>& JLANG::JParameter< T >::operator= ( argument_type  value)
inline

Assignment operator.

Parameters
valuevalue
Returns
this parameter

Definition at line 65 of file JParameter.hh.

66  {
67  setValue(value);
68 
69  return *this;
70  }
void setValue(argument_type value)
Set value.
Definition: JParameter.hh:100
template<class T>
const T& JLANG::JParameter< T >::getValue ( ) const
inline

Get value of parameter.

Returns
value

Definition at line 78 of file JParameter.hh.

79  {
80  return __value;
81  }
template<class T>
T& JLANG::JParameter< T >::getValue ( )
inline

Get value of parameter.

Returns
value

Definition at line 89 of file JParameter.hh.

90  {
91  return __value;
92  }
template<class T>
void JLANG::JParameter< T >::setValue ( argument_type  value)
inline

Set value.

Parameters
valuevalue

Definition at line 100 of file JParameter.hh.

101  {
102  __value = value;
103  is_defined = true;
104  }
template<class T>
JLANG::JParameter< T >::operator const T & ( ) const
inline

Type conversion operator.

Returns
value

Definition at line 112 of file JParameter.hh.

113  {
114  return getValue();
115  }
const T & getValue() const
Get value of parameter.
Definition: JParameter.hh:78
template<class T>
JLANG::JParameter< T >::operator T & ( )
inline

Type conversion operator.

Returns
value

Definition at line 123 of file JParameter.hh.

124  {
125  return getValue();
126  }
const T & getValue() const
Get value of parameter.
Definition: JParameter.hh:78
template<class T>
const bool JLANG::JParameter< T >::isDefined ( ) const
inline

Get status of parameter.

Returns
true if value has been defined (by read or assignment); else false

Definition at line 134 of file JParameter.hh.

135  {
136  return is_defined;
137  }
template<class T>
bool JLANG::JParameter< T >::less ( const JParameter< T > &  parameter) const
inline

Less than method.

This method evaluates to true if both parameter values are defined and this value is less than the value of the given parameter object.

Parameters
parameterparameter
Returns
true if both defined and first value less than second value; else false

Definition at line 149 of file JParameter.hh.

150  {
151  return this->isDefined() && parameter.isDefined() && this->getValue() < parameter.getValue();
152  }
const bool isDefined() const
Get status of parameter.
Definition: JParameter.hh:134
const T & getValue() const
Get value of parameter.
Definition: JParameter.hh:78

Friends And Related Function Documentation

template<class T>
std::istream& operator>> ( std::istream &  in,
JParameter< T > &  parameter 
)
friend

Stream input.

Parameters
ininput stream
parameterparameter
Returns
input stream

Definition at line 162 of file JParameter.hh.

163  {
164  in >> parameter.__value;
165 
166  parameter.is_defined = (bool) in;
167 
168  return in;
169  }
template<class T>
std::ostream& operator<< ( std::ostream &  out,
const JParameter< T > &  parameter 
)
friend

Stream output.

Parameters
outoutput stream
parameterparameter
Returns
output stream

Definition at line 179 of file JParameter.hh.

180  {
181  return out << parameter.__value;
182  }

Member Data Documentation

template<class T>
T JLANG::JParameter< T >::__value
protected

Definition at line 186 of file JParameter.hh.

template<class T>
bool JLANG::JParameter< T >::is_defined
protected

Definition at line 187 of file JParameter.hh.


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