Jpp  18.3.1
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 > > JOSCPROB::JOscParameter< JGrid< double > > JOSCPROB::JOscParameter< T > JOSCPROB::JComplexPhase< JGrid< double > > JOSCPROB::JMassSquaredDifference< JGrid< double > > JOSCPROB::JMixingAngle< JGrid< double > > JOSCPROB::JComplexPhase< T > JOSCPROB::JMassSquaredDifference< T > JOSCPROB::JMixingAngle< 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< T > &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 34 of file JParameter.hh.

Member Typedef Documentation

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

Definition at line 39 of file JParameter.hh.

Constructor & Destructor Documentation

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

Default constructor.

Definition at line 45 of file JParameter.hh.

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

Constructor.

Parameters
valuevalue

Definition at line 56 of file JParameter.hh.

56  :
57  __value(value),
58  is_defined(true)
59  {}

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

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

Get value of parameter.

Returns
value

Definition at line 81 of file JParameter.hh.

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

Get value of parameter.

Returns
value

Definition at line 92 of file JParameter.hh.

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

Set value.

Parameters
valuevalue

Definition at line 103 of file JParameter.hh.

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

Type conversion operator.

Returns
value

Definition at line 115 of file JParameter.hh.

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

Type conversion operator.

Returns
value

Definition at line 126 of file JParameter.hh.

127  {
128  return getValue();
129  }
const T & getValue() const
Get value of parameter.
Definition: JParameter.hh:81
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 137 of file JParameter.hh.

138  {
139  return is_defined;
140  }
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 152 of file JParameter.hh.

153  {
154  return this->isDefined() && parameter.isDefined() && this->getValue() < parameter.getValue();
155  }
const bool isDefined() const
Get status of parameter.
Definition: JParameter.hh:137
const T & getValue() const
Get value of parameter.
Definition: JParameter.hh:81

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

166  {
167  in >> parameter.__value;
168 
169  parameter.is_defined = (bool) in;
170 
171  return in;
172  }
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 JAcoustics sh $DETECTOR_ID source JAcousticsToolkit sh CHECK_EXIT_CODE typeset A EMITTERS get_tripods $WORKDIR tripod txt EMITTERS get_transmitters $WORKDIR transmitter txt EMITTERS for EMITTER in
Definition: JCanberra.sh:48
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 182 of file JParameter.hh.

183  {
184  if (parameter.is_defined) {
185  out << parameter.__value;
186  }
187 
188  return out;
189  }

Member Data Documentation

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

Definition at line 193 of file JParameter.hh.

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

Definition at line 194 of file JParameter.hh.


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