00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #ifndef __TOSVAL_INCLUDED
00019 #define __TOSVAL_INCLUDED
00020
00021 #include <iostream>
00022
00023 #include "common/global.h"
00024
00025 class TDataPackageList;
00026 using namespace std;
00027
00028
00029
00030
00031 inline int4 sign(const int4 i) {
00032 return (i > 0)? 1 : ((i == 0)? 0 : -1);
00033 }
00034
00035 inline int4 iabs(const int4 i) {
00036 return (i > 0)? i : ((i == 0)? 0 : -i);
00037 }
00038
00039 inline int4 min(const int4 a, const int4 b) {
00040 return (a < b)? a : b;
00041 }
00042
00043 inline int4 max(const int4 a, const int4 b) {
00044 return (a > b)? a : b;
00045 }
00046
00047
00048
00049
00050
00051
00052
00103 class TOSVal
00104 {
00105 public:
00106 TOSVal();
00107 TOSVal(const int4 iVal);
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117 static const int4 iInfinity;
00118 static const int4 iMaximum;
00119
00120
00121 int4 Value() const;
00122 bool Infinite() const;
00123 bool Maximum() const;
00124 bool Zero() const;
00125 bool Positive() const;
00126 bool Negative() const;
00127 TOSVal& operator=(const int4 iVal);
00128
00129
00130 const TOSVal operator-(void) const;
00131 const TOSVal operator+(const TOSVal& v2) const;
00132 const TOSVal operator-(const TOSVal& v2) const;
00133 TOSVal& operator+=(const TOSVal& v2);
00134 TOSVal& operator-=(const TOSVal& v2);
00135
00136
00137 TOSVal Scale(const int4 iNum, const int4 iDenom) const;
00138
00139
00140 bool operator==(const TOSVal v2) const;
00141 bool operator>=(const TOSVal v2) const;
00142 bool operator<=(const TOSVal v2) const;
00143 bool operator>(const TOSVal v2) const;
00144 bool operator<(const TOSVal v2) const;
00145
00146 bool operator==( int4 v2 ) const;
00147 bool operator!=( int4 v2 ) const;
00148
00149
00150 friend ostream& operator<<(ostream& os, const TOSVal& v);
00151
00152
00160 bool load( TDataPackageList* in, const string& sIdentifier, bool bUnique=true );
00168 bool save( TDataPackageList* out, const string& sIdentifier, bool bUnique=true ) const;
00169
00170 private:
00171 int4 iValue;
00172 };
00173
00174
00175
00176
00177
00178 #endif // TOSVal