Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #ifndef constraint_evaluator_h
00026 #define constraint_evaluator_h
00027
00028 #include <list>
00029
00030 #ifndef _clause_h
00031 #include "Clause.h"
00032 #endif
00033
00034 namespace libdap
00035 {
00036
00038 class ConstraintEvaluator
00039 {
00040 private:
00041
00042
00043 struct function
00044 {
00045 string name;
00046 bool_func b_func;
00047 btp_func bt_func;
00048 proj_func p_func;
00049
00050 function(const string &n, const bool_func f)
00051 : name(n), b_func(f), bt_func(0), p_func(0)
00052 {}
00053 function(const string &n, const btp_func f)
00054 : name(n), bt_func(f), p_func(0)
00055 {}
00056 function(const string &n, const proj_func f)
00057 : name(n), bt_func(0), p_func(f)
00058 {}
00059 function(): name(""), bt_func(0), p_func(0)
00060 {}
00061 };
00062
00063 vector<Clause *> expr;
00064
00065 vector<BaseType *> constants;
00066
00067 list<function> functions;
00068
00069
00070
00071
00072 ConstraintEvaluator(const ConstraintEvaluator &)
00073 {}
00074 ConstraintEvaluator &operator=(const ConstraintEvaluator &)
00075 {
00076 throw InternalErr(__FILE__, __LINE__, "Unimplemented method");
00077 }
00078
00079 friend class func_name_is;
00080
00081 public:
00082 typedef std::vector<Clause *>::const_iterator Clause_citer ;
00083 typedef std::vector<Clause *>::iterator Clause_iter ;
00084
00085 typedef std::vector<BaseType *>::const_iterator Constants_citer ;
00086 typedef std::vector<BaseType *>::iterator Constants_iter ;
00087
00088 typedef std::list<function>::const_iterator Functions_citer ;
00089 typedef std::list<function>::iterator Functions_iter ;
00090
00091 ConstraintEvaluator();
00092 virtual ~ConstraintEvaluator();
00093
00094 void add_function(const string &name, bool_func f);
00095 void add_function(const string &name, btp_func f);
00096 void add_function(const string &name, proj_func f);
00097
00098 bool find_function(const string &name, bool_func *f) const;
00099 bool find_function(const string &name, btp_func *f) const;
00100 bool find_function(const string &name, proj_func *f) const;
00101
00102 void append_clause(int op, rvalue *arg1, rvalue_list *arg2);
00103 void append_clause(bool_func func, rvalue_list *args);
00104 void append_clause(btp_func func, rvalue_list *args);
00105
00106 bool functional_expression();
00107 bool boolean_expression();
00108 bool eval_selection(DDS &dds, const string &dataset);
00109 BaseType *eval_function(DDS &dds, const string &dataset);
00110
00111
00112 Clause_iter clause_begin();
00113 Clause_iter clause_end();
00114 bool clause_value(Clause_iter &i, DDS &dds);
00115
00116 void parse_constraint(const string &constraint, DDS &dds);
00117 void append_constant(BaseType *btp);
00118
00119 };
00120
00121 }
00122
00123 #endif // constraint_evaluator_h