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
00030
00031
00032 #ifndef __MUTEVAR_H
00033 #define __MUTEVAR_H
00034
00035 namespace Modelib {
00036
00038
00047 class MuteVar
00048 {
00049 bool isBool;
00050 bool isInt;
00051 bool isLBStrict;
00052 bool isUBStrict;
00053 bool isRelaxed;
00054 float value;
00055 float lowerBound;
00056 float upperBound;
00057
00058 public:
00059 typedef enum VarType{FLOAT=0,INT,BOOL};
00060
00062 MuteVar( MuteVar::VarType type = MuteVar::FLOAT,
00063 float _value = 0.0f,
00064 float _lB = 0.0f,
00065 float _uB = 0.0f )
00066 :isBool(type==MuteVar::BOOL),isInt(type==MuteVar::INT),
00067 isLBStrict(false),isUBStrict(false),isRelaxed(false),
00068 value(_value),lowerBound(_lB),upperBound(_uB)
00069 {}
00070
00072 MuteVar(const MuteVar & _mv)
00073 {
00074 *this = _mv;
00075 }
00076
00078 MuteVar & operator= (const MuteVar & _mv)
00079 {
00080 isBool = _mv.isBool;
00081 isInt = _mv.isInt;
00082 isLBStrict = _mv.isLBStrict;
00083 isUBStrict = _mv.isUBStrict;
00084 isRelaxed = _mv.isRelaxed;
00085 value = _mv.value;
00086 lowerBound = _mv.lowerBound;
00087 upperBound = _mv.upperBound;
00088 return *this;
00089 };
00090
00092 MuteVar & operator= (float _value)
00093 {
00094 value = _value;
00095 return *this;
00096 };
00097
00101 float GetValue() const {return value;}
00105 float GetLowerBound() const {return lowerBound;}
00109 float GetUpperBound() const {return upperBound;}
00113 bool IsLowerBoundStrict() const {return isLBStrict;}
00117 bool IsUpperBoundStrict() const {return isUBStrict;}
00118
00122 VarType GetType() const
00123 {
00124 if(isBool) return MuteVar::BOOL;
00125 if(isInt) return MuteVar::INT;
00126 return MuteVar::FLOAT;
00127 }
00128
00132 void SetType( MuteVar::VarType type)
00133 {
00134 isBool = false;
00135 isInt = false;
00136 isBool = (type==MuteVar::BOOL);
00137 isInt = (type==MuteVar::INT);
00138 }
00139
00143 void SetLowerBound( float _value) { lowerBound = _value;}
00147 void SetUpperBound( float _value) { upperBound = _value;}
00151 void SetIsLBStrict( bool _value = true ) { isLBStrict = _value; }
00155 void SetIsUBStrict( bool _value = true ) { isUBStrict = _value; }
00156
00157 bool IsRelaxed() const { return isRelaxed;}
00158 void SetRelaxed( bool _isRelaxed = true ) { isRelaxed = _isRelaxed;}
00159
00160 ~MuteVar()
00161 {
00162 }
00163
00164 };
00165
00166 }
00167
00168 #endif