00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029 #ifndef PHI_H
00030 #define PHI_H
00031
00032 class Phi;
00033 class MsgStream;
00034
00035 MsgStream& operator << ( MsgStream&, const Phi& ) ;
00036 MsgStream& operator << ( MsgStream&, const Phi* const) ;
00037
00042 class Phi {
00043
00044 private:
00045
00046 double m_val ;
00047
00048 void reduce() {
00049 while( m_val > s_upperLimit ) { m_val -= s_range ; }
00050 while( m_val <= s_lowerLimit ) { m_val += s_range ; }
00051 }
00052 static const double s_upperLimit;
00053 static const double s_lowerLimit;
00054 static const double s_range;
00055
00056
00057
00058 public:
00059
00060
00061 Phi() { this->m_val = 0. ; }
00062 Phi( const double init ) { this->m_val = init ; this->reduce() ; }
00063 Phi( Phi& src ) { this->m_val = src.m_val ; }
00064
00065
00066
00067 Phi& operator= ( const Phi& rhs ) {
00068 this->m_val = rhs.m_val;
00069 return *this;
00070 }
00071
00072 Phi& operator+= ( Phi& rhs ) {
00073 this->m_val += rhs.m_val ;
00074 reduce() ;
00075 return *this;
00076 }
00077
00078 Phi& operator-= ( Phi& in ) {
00079 this->m_val -= in.m_val;
00080 reduce() ;
00081 return *this;
00082 }
00083
00084 Phi operator+ ( Phi& in ) const {
00085 Phi result( this->m_val + in.m_val ) ;
00086 return result ;
00087 }
00088
00089 Phi operator- ( Phi& in ) const {
00090 Phi result(this->m_val - in.m_val ) ;
00091 return result ;
00092 }
00093
00094
00095 bool operator< ( Phi& in ) const { return this->m_val < in.m_val ; }
00096 bool operator> ( Phi& in ) const { return this->m_val > in.m_val ; }
00097
00098
00099 operator double() const { return this->m_val ; }
00100
00101 double lowerLimit() const {return s_lowerLimit;}
00102 double upperLimit() const {return s_upperLimit;}
00103 double range () const {return s_range;}
00104 double val() const {return m_val;}
00105 };
00106 #endif
00107