Page principale | Hiérarchie des classes | Liste des composants | Liste des fichiers | Composants

NumVar.h

00001 #ifndef __NUMVAR_H_
00002 #define __NUMVAR_H_
00003 
00004 #include "Config.h"
00005 #include "Constant.h"
00006 #include "MuteVar.h"
00007 #include <string>
00008 
00009 class Model; //évite une déclaration cyclique
00010 
00012 
00027 class NumVar
00028 {
00029   protected:
00030     VarId varId; 
00031     Model * modele; 
00032   public:
00034     NumVar():varId(0),modele(0) {}
00035 
00036     NumVar(Model & _modele,
00037            float _lb= 0,
00038            float _ub= Infinity,
00039            MuteVar::VarType _type = MuteVar::FLOAT,
00040            const std::string & _nom = "unknow" );
00041 
00042     NumVar(Model & _modele,
00043            MuteVar::VarType _type = MuteVar::FLOAT,
00044            const std::string & _nom = "unknow" )
00045     {
00046         NumVar(_modele,0,Infinity,MuteVar::FLOAT,_nom);
00047     }
00048 
00049     NumVar(const Model *,VarId);
00050 
00052     NumVar(const NumVar & _n):varId( _n.varId), modele(_n.modele)  {}
00053 
00055     NumVar & operator= (const NumVar & _n)
00056     {
00057       modele = _n.modele;
00058       varId = _n.varId;
00059       return *this;
00060     }
00061 
00062     //Différents Geters et Seters
00066     VarId GetVarId() const { return varId;}
00067 
00071     Model * GetModel() const { return modele;}
00072 
00073     float GetValue() const;
00074 
00075     std::string GetName() const;
00076     void SetName(const std::string &);
00077 
00078     float GetLowerBound() const;
00079     void SetLowerBound(float _value);
00080     
00081     float GetUpperBound() const;
00082     void SetUpperBound(float _value);
00083     
00084     bool IsLowerBoundStrict() const;
00085     void SetLowerBoundStrict( bool _value = true );
00086     
00087     bool IsUpperBoundStrict() const;
00088     void SetUpperBoundStrict( bool _value = true );
00089     
00090     MuteVar::VarType GetType() const;
00091     void SetType( MuteVar::VarType _type);
00092 
00093     //Destructeur
00094     ~NumVar() {}
00095 };
00096 
00097 /*--------------------------------------------------------------------------------------------*/
00104 inline bool operator==( const NumVar & n1, const NumVar & n2)
00105 {
00106   return ( n1.GetVarId()==n2.GetVarId() && n1.GetModel()==n2.GetModel() );
00107 }
00108 
00109 /*--------------------------------------------------------------------------------------------*/
00111 class IntVar:public NumVar
00112 {
00113   public:
00114 
00115 #ifdef COMPILE_FOR_PYTHON
00116     IntVar( Model &_modele,
00117             float lowerBound = 0,
00118             float upperBound = Infinity, // ou MaxInt, il faut voir
00119             const std::string & nom = "unknow" )
00120     :NumVar(_modele,lowerBound,upperBound,MuteVar::INT,nom)
00121     {}  
00122 #else
00123     IntVar( Model &_modele,
00124             int lowerBound = 0,
00125             int upperBound = Infinity, // ou MaxInt, il faut voir
00126             const std::string & nom = "unknow" )
00127     :NumVar( _modele,
00128              (lowerBound > -MaxInt? static_cast<float>(lowerBound) : -Infinity),
00129              (upperBound <  MaxInt? static_cast<float>(upperBound) :  Infinity),
00130              MuteVar::INT,nom)
00131     {}
00132 
00133     IntVar(Model & _modele,
00134            const std::string & _nom = "unknow" )
00135     :NumVar(_modele,0,Infinity,MuteVar::INT,_nom)
00136     {}
00137 
00138 #endif  
00139         
00140 };
00141 
00143 class FloatVar:public NumVar
00144 {
00145   public:
00146     FloatVar( Model &_modele,
00147             float lowerBound = 0,
00148             float upperBound = Infinity,
00149             const std::string & nom = "unknow" )
00150     :NumVar(_modele,lowerBound,upperBound,MuteVar::FLOAT,nom)
00151     {}
00152     
00153     FloatVar(Model & _modele,
00154            const std::string & _nom = "unknow" )
00155     :NumVar(_modele,0,Infinity,MuteVar::FLOAT,_nom)
00156     {}  
00157 };
00158 
00160 class BoolVar:public NumVar
00161 {
00162   public:
00163     BoolVar( Model &_modele,
00164             const std::string & nom = "unknow" )
00165     :NumVar(_modele,0.0f,1.0f,MuteVar::BOOL,nom)
00166     {}
00167 };
00168 
00169 #ifdef COMPILE_FOR_PYTHON
00170         void export_NumVar();
00171 #endif
00172 
00173 #endif

Généré le Mon Jul 18 23:07:41 2005 pour Modelib par doxygen 1.3.6