Jpp  19.1.0-rc.1
the software that should make you happy
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
 
typedef JClass< T >::value_type value_type
 

Public Member Functions

 JParameter ()
 Default constructor. More...
 
 JParameter (argument_type value)
 Constructor. More...
 
JParameter< T > & operator= (const value_type &value)
 Assignment operator. More...
 
const value_type getValue () const
 Get value of parameter. More...
 
void setValue (const value_type &value)
 Set value. More...
 
 operator const value_type () const
 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

__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

◆ argument_type

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

Definition at line 39 of file JParameter.hh.

◆ value_type

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

Definition at line 40 of file JParameter.hh.

Constructor & Destructor Documentation

◆ JParameter() [1/2]

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

Default constructor.

Definition at line 46 of file JParameter.hh.

46  :
47  __value(),
48  is_defined(false)
49  {}

◆ JParameter() [2/2]

template<class T >
JLANG::JParameter< T >::JParameter ( argument_type  value)
inlineexplicit

Constructor.

Parameters
valuevalue

Definition at line 57 of file JParameter.hh.

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

Member Function Documentation

◆ operator=()

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

Assignment operator.

Parameters
valuevalue
Returns
this parameter

Definition at line 69 of file JParameter.hh.

70  {
71  setValue(value);
72 
73  return *this;
74  }
void setValue(const value_type &value)
Set value.
Definition: JParameter.hh:93

◆ getValue()

template<class T >
const value_type JLANG::JParameter< T >::getValue ( ) const
inline

Get value of parameter.

Returns
value

Definition at line 82 of file JParameter.hh.

83  {
84  return __value;
85  }

◆ setValue()

template<class T >
void JLANG::JParameter< T >::setValue ( const value_type value)
inline

Set value.

Parameters
valuevalue

Definition at line 93 of file JParameter.hh.

94  {
95  __value = value;
96  is_defined = true;
97  }

◆ operator const value_type()

template<class T >
JLANG::JParameter< T >::operator const value_type ( ) const
inline

Type conversion operator.

Returns
value

Definition at line 105 of file JParameter.hh.

106  {
107  return getValue();
108  }
const value_type getValue() const
Get value of parameter.
Definition: JParameter.hh:82

◆ isDefined()

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

117  {
118  return is_defined;
119  }

◆ less()

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

132  {
133  return this->isDefined() && parameter.isDefined() && this->getValue() < parameter.getValue();
134  }
const bool isDefined() const
Get status of parameter.
Definition: JParameter.hh:116

Friends And Related Function Documentation

◆ operator>>

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

145  {
146  in >> parameter.__value;
147 
148  parameter.is_defined = (bool) in;
149 
150  return in;
151  }

◆ operator<<

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

162  {
163  if (parameter.is_defined) {
164  out << parameter.__value;
165  }
166 
167  return out;
168  }

Member Data Documentation

◆ __value

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

Definition at line 172 of file JParameter.hh.

◆ is_defined

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

Definition at line 173 of file JParameter.hh.


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