Jpp  15.0.0-rc.2
the software that should make you happy
 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 TgetValue () const
 Get value of parameter. More...
 
TgetValue ()
 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

T __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 an additional 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 comparison between parameter objects is based on the philosophy "undefined = any value".
Hence, if any of the two parameter values is undefined, they are considered equal.
The comparison between a parameter object with a template value is based on the internal value of the parameter object via implicit type conversion, regardless of its state.

Definition at line 33 of file JParameter.hh.

Member Typedef Documentation

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

Definition at line 38 of file JParameter.hh.

Constructor & Destructor Documentation

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

Default constructor.

Definition at line 43 of file JParameter.hh.

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

Constructor.

Parameters
valuevalue

Definition at line 54 of file JParameter.hh.

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

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 66 of file JParameter.hh.

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

Get value of parameter.

Returns
value

Definition at line 79 of file JParameter.hh.

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

Get value of parameter.

Returns
value

Definition at line 90 of file JParameter.hh.

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

Set value.

Parameters
valuevalue

Definition at line 101 of file JParameter.hh.

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

Type conversion operator.

Returns
value

Definition at line 113 of file JParameter.hh.

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

Type conversion operator.

Returns
value

Definition at line 124 of file JParameter.hh.

125  {
126  return getValue();
127  }
const T & getValue() const
Get value of parameter.
Definition: JParameter.hh:79
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 135 of file JParameter.hh.

136  {
137  return is_defined;
138  }
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 150 of file JParameter.hh.

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

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 163 of file JParameter.hh.

164  {
165  in >> parameter.__value;
166 
167  parameter.is_defined = (bool) in;
168 
169  return in;
170  }
then fatal Wrong number of arguments fi set_variable DETECTOR $argv[1] set_variable INPUT_FILE $argv[2] eval JPrintDetector a $DETECTOR O IDENTIFIER eval JPrintDetector a $DETECTOR O SUMMARY source JAcoustics sh $DETECTOR_ID CHECK_EXIT_CODE typeset A TRIPODS get_tripods $WORKDIR tripod txt TRIPODS for EMITTER in
Definition: JCanberra.sh:41
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 180 of file JParameter.hh.

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

Member Data Documentation

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

Definition at line 187 of file JParameter.hh.

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

Definition at line 188 of file JParameter.hh.


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