00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016 #include "torc/generic/om/DumpRestoreConfig.hpp"
00017
00018 #ifndef HAVE_CONFIG_H
00019 #include "torc/generic/config.h"
00020 #endif
00021
00022 #ifdef GENOM_SERIALIZATION
00023 #include <boost/archive/binary_iarchive.hpp>
00024 #include <boost/archive/binary_oarchive.hpp>
00025 #include <boost/serialization/variant.hpp>
00026 #endif //GENOM_SERIALIZATION
00027 #include <cmath>
00028
00029 #include "torc/generic/om/Value.hpp"
00030
00031 namespace torc {
00032
00033 namespace generic {
00034
00035 Value::MiNoMax::MiNoMax()
00036 :mMin(),
00037 mMinUndefined(true),
00038 mNominal(),
00039 mMax(),
00040 mMaxUndefined(true) {
00041 }
00042
00043 Value::MiNoMax::MiNoMax(Value::Number inMin,
00044 Value::Number inNominal, Value::Number inMax)
00045 :mMin(inMin),
00046 mMinUndefined(false),
00047 mNominal(inNominal),
00048 mMax(inMax),
00049 mMaxUndefined(false) {
00050 }
00051
00052 Value::MiNoMax::~MiNoMax() throw() {
00053 }
00054
00055 Value::MiNoMax::MiNoMax(const Value::MiNoMax & inSource) throw()
00056 : mMin( inSource.mMin ),
00057 mMinUndefined( inSource.mMinUndefined ),
00058 mNominal( inSource.mNominal ),
00059 mMax( inSource.mMax ),
00060 mMaxUndefined( inSource.mMaxUndefined ) {
00061 }
00062
00063 Value::MiNoMax & Value::MiNoMax::operator=(
00064 const Value::MiNoMax & inSource) throw() {
00065 if( this != &inSource )
00066 {
00067 mMin = inSource.mMin;
00068 mMinUndefined = inSource.mMinUndefined;
00069 mNominal = inSource.mNominal;
00070 mMax = inSource.mMax;
00071 mMaxUndefined = inSource.mMaxUndefined;
00072 }
00073 return *this;
00074 }
00075
00076 bool
00077 Value::MiNoMax::operator <(
00078 const Value::MiNoMax & inRhs) const throw() {
00079 return mNominal.eval() < inRhs.mNominal.eval();
00080 }
00081
00082 bool
00083 Value::MiNoMax::operator ==(
00084 const Value::MiNoMax & inRhs) const throw() {
00085 return mNominal.eval() == inRhs.mNominal.eval();
00086 }
00087
00088 bool
00089 Value::MiNoMax::operator >(
00090 const Value::MiNoMax & inRhs) const throw() {
00091 return mNominal.eval() > inRhs.mNominal.eval();
00092 }
00093
00094 bool
00095 Value::MiNoMax::operator >=(
00096 const Value::MiNoMax & inRhs) const throw() {
00097 return mNominal.eval() >= inRhs.mNominal.eval();
00098 }
00099
00100 bool
00101 Value::MiNoMax::operator <=(
00102 const Value::MiNoMax & inRhs) const throw() {
00103 return mNominal.eval() <= inRhs.mNominal.eval();
00104 }
00105
00106 bool
00107 Value::MiNoMax::operator !=(
00108 const Value::MiNoMax & inRhs) const throw() {
00109 return !operator ==( inRhs );
00110 }
00111
00112 void
00113 Value::MiNoMax::setMax(const Value::Number & inSource) throw() {
00114 mMax = inSource;
00115 mMaxUndefined = false;
00116 }
00117
00118 void
00119 Value::MiNoMax::setMin(const Value::Number & inSource) throw() {
00120 mMin = inSource;
00121 mMinUndefined = false;
00122 }
00123
00124 void
00125 Value::MiNoMax::setNominal(const Value::Number & inSource) throw() {
00126 mNominal = inSource;
00127 }
00128
00129 Value::Number::Number()
00130 :mMantissa(0),
00131 mExponent(0) {
00132 }
00133
00134 Value::Number::Number(int32_t inMantissa, int32_t inExponent)
00135 :mMantissa(inMantissa),
00136 mExponent(inExponent) {
00137 }
00138
00139 Value::Number::~Number() throw() {
00140 }
00141
00142 Value::Number::Number(const Value::Number & inSource) throw()
00143 :mMantissa( inSource.mMantissa ),
00144 mExponent( inSource.mExponent ) {
00145 }
00146
00147 Value::Number &
00148 Value::Number::operator=(
00149 const Value::Number & inSource) throw() {
00150 if( this != &inSource )
00151 {
00152 mMantissa = inSource.mMantissa;
00153 mExponent = inSource.mExponent;
00154 }
00155 return *this;
00156 }
00157
00158 bool
00159 Value::Number::operator <(
00160 const Value::Number & inRhs) const throw() {
00161 return eval() < inRhs.eval();
00162 }
00163
00164 bool
00165 Value::Number::operator ==(
00166 const Value::Number & inRhs) const throw() {
00167 return eval() == inRhs.eval();
00168 }
00169
00170 bool
00171 Value::Number::operator >(
00172 const Value::Number & inRhs) const throw() {
00173 return eval() > inRhs.eval();
00174 }
00175
00176 bool
00177 Value::Number::operator >=(
00178 const Value::Number & inRhs) const throw() {
00179 return eval() >= inRhs.eval();
00180 }
00181
00182 bool
00183 Value::Number::operator <=(
00184 const Value::Number & inRhs) const throw() {
00185 return eval() <= inRhs.eval();
00186 }
00187
00188 bool
00189 Value::Number::operator !=(
00190 const Value::Number & inRhs) const throw() {
00191 return !operator ==(inRhs);
00192 }
00193
00194 void
00195 Value::Number::setMantissa( const int32_t & inSource) throw() {
00196 mMantissa = inSource;
00197 }
00198
00199 void
00200 Value::Number::setExponent(const int32_t & inSource) throw() {
00201 mExponent = inSource;
00202 }
00203
00204 double
00205 Value::Number::eval() const throw() {
00206 return static_cast<double>(mMantissa)
00207 * exp( static_cast<double>(mExponent) );
00208 }
00209
00210 Value::Point::Point()
00211 :mX(0),
00212 mY(0) {
00213 }
00214
00215 Value::Point::Point(int32_t inX, int32_t inY)
00216 :mX(inX),
00217 mY(inY) {
00218 }
00219
00220 Value::Point::~Point() throw() {
00221 }
00222
00223 Value::Point::Point(const Value::Point & inSource )
00224 :mX( inSource.mX ),
00225 mY( inSource.mY ) {
00226 }
00227
00228 Value::Point &
00229 Value::Point::operator=(const Value::Point & inSource) throw() {
00230 if( this != &inSource )
00231 {
00232 mX = inSource.mX;
00233 mY = inSource.mY;
00234 }
00235 return *this;
00236 }
00237
00238 bool
00239 Value::Point::operator <(
00240 const Value::Point & inRhs) const throw() {
00241 return mX < inRhs.mY
00242 || (mX == inRhs.mX && mY < inRhs.mY );
00243 }
00244
00245 bool
00246 Value::Point::operator ==(
00247 const Value::Point & inRhs) const throw() {
00248 return mX == inRhs.mY && mY == inRhs.mY;
00249 }
00250
00251 bool
00252 Value::Point::operator >(
00253 const Value::Point & inRhs) const throw() {
00254 return mX > inRhs.mY
00255 || (mX == inRhs.mX && mY > inRhs.mY );
00256 }
00257
00258 bool
00259 Value::Point::operator >=(
00260 const Value::Point & inRhs) const throw() {
00261 return mX >= inRhs.mY && mY >= inRhs.mY;
00262 }
00263
00264 bool
00265 Value::Point::operator <=(
00266 const Value::Point & inRhs) const throw() {
00267 return mX <= inRhs.mY && mY <= inRhs.mY;
00268 }
00269
00270 bool
00271 Value::Point::operator !=(
00272 const Value::Point & inRhs) const throw() {
00273 return !operator ==(inRhs);
00274 }
00275
00276 void
00277 Value::Point::setX(const int32_t & inSource) throw() {
00278 mX = inSource;
00279 }
00280
00281 void
00282 Value::Point::setY(const int32_t & inSource) throw() {
00283 mX = inSource;
00284 }
00285
00286 Value::Value()
00287 :mType( eValueTypeUndefined ),
00288 mValue(),
00289 mIsSet( false ) {
00290 }
00291
00292 Value::Value(Value::Type type)
00293 :mType( type ),
00294 mValue(),
00295 mIsSet( false ) {
00296 }
00297
00298 Value::~Value() throw() {
00299 }
00300
00301 Value::Value(const Value & inSource)
00302 :mType( inSource.mType ),
00303 mValue( inSource.mValue ),
00304 mIsSet( inSource.mIsSet ) {
00305 }
00306
00307 Value &
00308 Value::operator=(const Value & inSource) throw() {
00309 if( this != &inSource )
00310 {
00311 mType = inSource.mType;
00312 mValue = inSource.mValue;
00313 mIsSet = inSource.mIsSet;
00314 }
00315 return *this;
00316 }
00317
00318
00319
00320
00321
00322
00323 void
00324 Value::setType(const Value::Type & inSource) throw() {
00325 mType = inSource;
00326 }
00327
00328
00329
00330
00331
00332
00333 void
00334 Value::setIsSet(const bool & inSource) throw() {
00335 mIsSet = inSource;
00336 }
00337
00338 #ifdef GENOM_SERIALIZATION
00339 template<class Archive> void
00340 Value::serialize( Archive &ar, unsigned int ) {
00341 ar & mType;
00342 ar & mValue;
00343 ar & mIsSet;
00344 }
00345
00346
00347 template void
00348 Value::serialize<boost::archive::binary_iarchive>(
00349 boost::archive::binary_iarchive & ar, const unsigned int);
00350
00351 template void
00352 Value::serialize<boost::archive::binary_oarchive>(
00353 boost::archive::binary_oarchive & ar, const unsigned int);
00354
00355 #endif //GENOM_SERIALIZATION
00356
00357 }
00358
00359 }