Modelib: ConstraintBuilder.h Source File

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

# ConstraintBuilder.h

    00001 #ifndef __CONSTRAINTBUILDER_H
    00002 #define __CONSTRAINTBUILDER_H
    00003
    00004 #include "Expr.h"
    00005 #include <list>
    00006 class ostream;
    00007
    00008
    00010
    00022 class ConstraintBuilder
    00023 {
    00024   public:
    00026     enum Operateur {EGAL=0,DIFFERENT,INFERIEUR,SUPERIEUR,INFSTRICT,SUPSTRICT};
    00027
    00028   protected:
    00029     std::list<Expr> expressions;
    00030     std::list<Operateur> operateurs;
    00031     bool isBound;
    00032
    00033     bool CheckIfIsBound();
    00034     void Add(Operateur,const std::list<Expr> &,const std::list<Operateur> &);
    00035
    00036     friend class Model;
    00037     friend std::ostream & operator<< (std::ostream & flux, const ConstraintBuilder & c);
    00038
    00039   public:
    00041     ConstraintBuilder(): isBound(false) {}
    00042     ConstraintBuilder( const Expr & , ConstraintBuilder::Operateur , const Expr &);
    00044     ConstraintBuilder(const ConstraintBuilder & c) { *this = c; }
    00046     ConstraintBuilder & operator= ( const ConstraintBuilder & _c)
    00047     {
    00048         if( this != &_c )   //permet d'economiser la recopie de liste
    00049         {
    00050           isBound = _c.isBound;
    00051           expressions = _c.expressions;
    00052           operateurs = _c.operateurs;
    00053         }
    00054         return *this;
    00055     }
    00057     inline bool IsBound() const { return isBound;}
    00058
    00059     //operateurs permettant d'enchainer les contraintes
    00060     ConstraintBuilder & operator== ( const ConstraintBuilder & );
    00061     ConstraintBuilder & operator!= ( const ConstraintBuilder & );
    00062     ConstraintBuilder & operator<= ( const ConstraintBuilder & );
    00063     ConstraintBuilder & operator>= ( const ConstraintBuilder & );
    00064     ConstraintBuilder & operator< ( const ConstraintBuilder & );
    00065     ConstraintBuilder & operator> ( const ConstraintBuilder & );
    00066
    00067     //operateur permettant de terminer un enchainement
    00068     ConstraintBuilder & operator== ( const Expr & );
    00069     ConstraintBuilder & operator!= ( const Expr & );
    00070     ConstraintBuilder & operator<= ( const Expr & );
    00071     ConstraintBuilder & operator>= ( const Expr & );
    00072     ConstraintBuilder & operator< ( const Expr & );
    00073     ConstraintBuilder & operator> ( const Expr & );
    00074
    00075     ~ConstraintBuilder() {}
    00076 };
    00077
    00078 //operateurs permettant de créer une expression a partir de deux expressions
    00079 ConstraintBuilder operator== ( const Expr &, const Expr & );
    00080 ConstraintBuilder operator!= ( const Expr &, const Expr & );
    00081 ConstraintBuilder operator<= ( const Expr &, const Expr & );
    00082 ConstraintBuilder operator>= ( const Expr &, const Expr & );
    00083 ConstraintBuilder operator< ( const Expr &, const Expr & );
    00084 ConstraintBuilder operator> ( const Expr &, const Expr & );
    00085
    00086 std::ostream & operator<< (std::ostream & flux,const ConstraintBuilder & c);
    00087
    00088 #endif