basix_doc 0.1
/Users/mourrain/Devel/mmx/basix/include/basix/evaluator.hpp
Go to the documentation of this file.
00001 
00002 /******************************************************************************
00003 * MODULE     : evaluator.hpp
00004 * DESCRIPTION: Abstract evaluators for symbolic expressions
00005 * COPYRIGHT  : (C) 2006  Joris van der Hoeven
00006 *******************************************************************************
00007 * This software falls under the GNU general public license and comes WITHOUT
00008 * ANY WARRANTY WHATSOEVER. See the file $TEXMACS_PATH/LICENSE for more details.
00009 * If you don't have this file, write to the Free Software Foundation, Inc.,
00010 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
00011 ******************************************************************************/
00012 
00013 #ifndef __EVALUATOR_HPP
00014 #define __EVALUATOR_HPP
00015 #include <basix/exception.hpp>
00016 #include <basix/lisp_syntax.hpp>
00017 
00019 
00020 namespace mmx {
00021 class evaluator_rep;
00022 class evaluator;
00023 
00024 #define PENALTY_NONE             ((nat) 0)
00025 #define PENALTY_AUTOMATIC        ((nat) 1)
00026 #define PENALTY_INCLUSION        ((nat) 2)
00027 #define PENALTY_HOMOMORPHISM     ((nat) 3)
00028 #define PENALTY_VARIANT          ((nat) 4)
00029 #define PENALTY_CAST             ((nat) 5)
00030 #define PENALTY_FALL_BACK        ((nat) 6)
00031 #define PENALTY_PROMOTE_GENERIC  ((nat) 7)
00032 #define PENALTY_INVALID          ((nat) 8)
00033 
00034 class evaluator_rep: public rep_struct {
00035 public:
00036   virtual void* get_internal_data () const;
00037   virtual void set (const generic& var, const generic& val) const;
00038   virtual void reset (const generic& var) const;
00039   virtual void overload (const generic& var, const generic& val,
00040                          nat penalty= PENALTY_INCLUSION) const;
00041   virtual bool contains (const generic& var) const;
00042   virtual generic get (const generic& var) const;
00043   virtual bool get (const generic& var, generic& val) const;
00044 
00045   virtual generic eval (const generic& x) const;
00046   virtual generic construct (const generic& x) const;
00047   virtual generic apply (const generic& fun) const;
00048   virtual generic apply (const generic& fun, const generic& x1) const;
00049   virtual generic apply (const generic& fun,
00050                          const generic& x1, const generic& x2) const;
00051   virtual generic apply (const generic& fun, const vector<generic>& a) const;
00052 
00053 public:
00054   inline evaluator_rep () {}
00055   inline virtual ~evaluator_rep () {}
00056   friend class evaluator;
00057 };
00058 
00059 class evaluator {
00060 INDIRECT_PROTO (evaluator, evaluator_rep)
00061 public:
00062   inline evaluator (): rep (new evaluator_rep ()) {}
00063   friend class evaluator_rep;
00064 };
00065 INDIRECT_IMPL (evaluator, evaluator_rep)
00066 
00067 extern evaluator current_ev;
00068 
00069 void select_evaluator (const evaluator& ev);
00070 void restore_evaluator ();
00071 
00072 } // namespace mmx
00073 #endif // __EVALUATOR_HPP
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines