Modelib: Expr.h Source File

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

# Expr.h

    00001 #ifndef __EXPR_H_
    00002 #define __EXPR_H_
    00003
    00004 #include <list>
    00005 #include <iostream>
    00006
    00007
    00008 class Num;
    00009 class NumArray;
    00010 class NumVar;
    00011 class NumVarArray;
    00012 class LagrangianParam;
    00013
    00014 #include "ExprNode.h"
    00016
    00028 class Expr
    00029 {
    00030   std::list<ExprNode> nodeList;
    00031   protected:
    00036     Expr & operator+=(const ExprNode & _node)
    00037     {
    00038       nodeList.push_back(_node);
    00039       isSimplified = false;
    00040       return *this;
    00041     }
    00042
    00043     void Simplify(bool AvecLagrangianParam = false,bool SansConstantes = false);
    00044
    00045     bool isSimplified;
    00046     bool isParametric;
    00047     bool sansConstantes;
    00048
    00049     friend class Model;
    00050   public:
    00051     Expr() {}
    00052     Expr( const NumVar & numVar);
    00053     Expr( float );
    00054     Expr( double );
    00055     Expr( int );
    00056     Expr( unsigned );
    00057     Expr( const Num & num);
    00058     Expr( const Num & num, const NumVar & numVar);
    00059     Expr( const Num & num, const NumVar & numVar, const LagrangianParam & mult);
    00061     Expr( const Expr & _expr) { *this = _expr; }
    00062
    00064     Expr & operator= ( const Expr & _expr)
    00065     {
    00066         if( this != &_expr )
    00067         {
    00068             nodeList = _expr.nodeList;
    00069             isSimplified =  _expr.isSimplified;
    00070             isParametric = _expr.isParametric;
    00071             sansConstantes = _expr.sansConstantes;
    00072         }
    00073         return *this;
    00074     }
    00075
    00076     Expr & operator+=( const Expr & );
    00077     Expr & operator-=( const Expr & );
    00078
    00079     Expr & operator*=(const Num &);
    00080
    00081     Expr & ASS( const Num & num, const NumVar & numVar );
    00082     Expr & ASS( const Num & num, const NumVar & numVar, const LagrangianParam & mult );
    00083
    00087     unsigned Size() { return nodeList.size(); }
    00088     bool IsNum();
    00089     bool IsVar();
    00090     float GetConstant(bool avecLagrangianParam = true) const;
    00091     float Evalue(bool avecLagrangianParam = true) const;
    00092
    00093     friend std::ostream & operator<< ( std::ostream & flux, const Expr & expr);
    00094     friend std::ostream& operator<<(std::ostream& o,const Model& m);
    00095
    00096     ~Expr() {}
    00097 };
    00098
    00099 //Operateurs de constructions d'expressions
    00100 Expr operator*( const Num & , const NumVar &);
    00101 Expr operator*( const NumVar & , const Num &);
    00102 Expr operator*( const NumVarArray & , const NumArray &);
    00103 Expr operator*( const NumArray & , const NumVarArray &);
    00104 Expr operator*( const Expr &, const Num & );
    00105 Expr operator*( const Num & , const Expr &);
    00106 Expr operator+( const Expr &, const Expr &);
    00107 Expr operator-( const Expr &, const Expr &);
    00108
    00109
    00110 std::ostream & operator<< (std::ostream & flux,const Expr & expr);
    00111
    00112 Expr Sum(const NumVarArray & );
    00113
    00114 #endif