Page principale | Liste des namespaces | Hiérarchie des classes | Liste alphabétique | Liste des classes | Liste des fichiers | Membres de namespace | Membres de classe | Membres de fichier

MuteVar.h

Aller à la documentation de ce fichier.
00001 /*
00002     Copyright (c) 2005, Quentin Lequy and Romain Gaucher
00003     All rights reserved.
00004 
00005     Redistribution and use in source and binary forms, with or 
00006     without modification, are permitted provided that the following 
00007     conditions are met:
00008 
00009         * Redistributions of source code must retain the above copyright 
00010           notice, this list of conditions and the following disclaimer.
00011 
00012         * Redistributions in binary form must reproduce the above copyright 
00013           notice, this list of conditions and the following disclaimer in the 
00014           documentation and/or other materials provided with the distribution.
00015 
00016         * Neither the name of Quentin Lequy or Romain Gaucher nor the names 
00017           of its contributors may be used to endorse or promote products 
00018           derived from this software without specific prior written permission.
00019 
00020     THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 
00021     AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
00022     IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
00023     ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 
00024     LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 
00025     DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 
00026     SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 
00027     AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 
00028     (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 
00029     SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
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

Généré le Sun Oct 2 19:13:11 2005 pour Modelib par  doxygen 1.4.4