ucond.hpp

00001 /* ==================================================== ======== ======= *
00002  *
00003  *  ucond.hpp
00004  *  Ubit Project
00005  *  Part of the Ubit Toolkit: A Brick Construction Game Model for Creating GUIs
00006  *  (C) 1999-2005 Eric Lecolinet / ENST Paris / http://www.enst.fr/~elc/ubit
00007  *
00008  * ***********************************************************************
00009  * COPYRIGHT NOTICE : 
00010  * THIS PROGRAM IS DISTRIBUTED WITHOUT ANY WARRANTY AND WITHOUT EVEN THE 
00011  * IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. 
00012  * YOU CAN REDISTRIBUTE IT AND/OR MODIFY IT UNDER THE TERMS OF THE GNU 
00013  * GENERAL PUBLIC LICENSE AS PUBLISHED BY THE FREE SOFTWARE FOUNDATION; 
00014  * EITHER VERSION 2 OF THE LICENSE, OR (AT YOUR OPTION) ANY LATER VERSION.
00015  * SEE FILES 'COPYRIGHT' AND 'COPYING' FOR MORE DETAILS.
00016  * ***********************************************************************
00017  * ==================================================== [(c)Elc] ======= *
00018  * ==================================================== ======== ======= */
00019 
00020 #ifndef _ucond_hpp_
00021 #define _ucond_hpp_
00022 #include <ubit/umode.hpp>
00023 #include <ubit/ucall.hpp>
00024 //pragma ident  "@(#)ucond.hpp  ubit:05.05.00"
00025 namespace ubit {
00026   
00027 /* ==================================================== ===== ======= */
00036 class UCond {
00037 public:
00038   virtual ~UCond() {}
00039   
00040   virtual bool operator==(const UCond& c) const {return this == &c;}
00041   virtual bool operator!=(const UCond& c) const {return this != &c;}
00042   virtual const UCond* matches(const UCond& c) const {return this == &c? this: 0;}
00043   virtual bool verifies(const UContext&, const UControl*) const = 0;
00044 
00045   template <class A, class R> 
00046   Truc_F1<A,R> operator/(R(*f)(A)) {return Truc_F1<A,R>(*this,f);}
00047   
00048   template <class A, class R, class E> 
00049   Truc_F1E<A,R,E> operator/(R(*f)(E&,A)) {return Truc_F1E<A,R,E>(*this,f);}
00050   
00051   template <class A1, class A2, class R> 
00052   Truc_F2<A1,A2,R> operator/(R(*f)(A1,A2)) {return Truc_F2<A1,A2,R>(*this,f);}
00053     
00054   template <class A1, class A2, class R, class E> 
00055   Truc_F2E<A1,A2,R,E> operator/(R(*f)(E&,A1,A2)) {return Truc_F2E<A1,A2,R,E>(*this,f);}
00056 
00057   // - - - impl - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
00058   
00059   virtual UOn* onCast() {return null;}
00060   virtual const UOn* onCast() const {return null;}
00061   virtual void setParentModes(UControl* parent) const {};
00062 };
00063 
00064 /* ==================================================== ===== ======= */
00065 
00066 class UMultiCond : public UCond {
00067 public:
00068   virtual void add(const UCond&);
00069   virtual void remove(const UCond&);
00070 
00071   virtual const UCond* matches(const UCond& c) const;
00072   virtual bool verifies(const UContext&, const UControl*) const;
00073   virtual void setParentModes(UControl* parent) const;
00074 
00075 private:
00076   typedef std::list<const UCond*> CondList;
00077   CondList condlist;
00078 };
00079 
00080 /* ==================================================== ===== ======= */
00094 class UInscale : public UCond {
00095 public:
00096   UInscale();
00097   UInscale(float smin, float smax);
00098   friend UInscale& uinscale(float smin, float smax) {return *new UInscale(smin,smax);}
00099     
00100   void  setMin(float smin);
00101   void  setMax(float smax);
00102   float getMin() const {return smin;}
00103   float getMax() const {return smax;}
00104   
00105   virtual bool verifies(const UContext&, const UControl*) const;
00106 private:
00107   float smin, smax;
00108 };
00109 
00110 /* ==================================================== ===== ======= */
00132 class UFlag : public UCond {
00133 public:
00134   static const UFlag none;
00135   virtual bool verifies(const UContext&, const UControl*) const;
00136 };
00137 
00138 /* ==================================================== ======== ======= */
00142  class UNotFlag : public UCond {
00143 public:
00144    const UFlag& cond;
00145    UNotFlag(const UFlag& c) : cond(c) {}
00146    virtual bool verifies(const UContext&, const UControl*) const;
00147  };
00148  
00151 inline UNotFlag& operator!(const UFlag& c) {return *new UNotFlag(c);}
00152 
00153 }
00154 #endif
00155 /* ==================================================== [TheEnd] ======= */
00156 /* ==================================================== [(c)Elc] ======= */
00157 

Generated on Mon Jan 29 00:20:37 2007 for Ubit by  doxygen 1.4.7