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 _dds_h
00031 #include "DDS.h"
00032 #endif
00033
00034 #ifndef _datadds_h
00035 #include "DataDDS.h"
00036 #endif
00037
00038 #ifndef _clause_h
00039 #include "Clause.h"
00040 #endif
00041
00042 namespace libdap
00043 {
00044
00046 class ConstraintEvaluator
00047 {
00048 private:
00049
00050
00051 struct function
00052 {
00053 string name;
00054 bool_func b_func;
00055 btp_func bt_func;
00056 proj_func p_func;
00057
00058 function(const string &n, const bool_func f)
00059 : name(n), b_func(f), bt_func(0), p_func(0)
00060 {}
00061 function(const string &n, const btp_func f)
00062 : name(n), bt_func(f), p_func(0)
00063 {}
00064 function(const string &n, const proj_func f)
00065 : name(n), bt_func(0), p_func(f)
00066 {}
00067 function(): name(""), bt_func(0), p_func(0)
00068 {}
00069 };
00070
00071 vector<Clause *> expr;
00072
00073 vector<BaseType *> constants;
00074
00075 list<function> functions;
00076
00077
00078
00079
00080 ConstraintEvaluator(const ConstraintEvaluator &)
00081 {}
00082 ConstraintEvaluator &operator=(const ConstraintEvaluator &)
00083 {
00084 throw InternalErr(__FILE__, __LINE__, "Unimplemented method");
00085 }
00086
00087 friend class func_name_is;
00088
00089 public:
00090 typedef std::vector<Clause *>::const_iterator Clause_citer ;
00091 typedef std::vector<Clause *>::iterator Clause_iter ;
00092
00093 typedef std::vector<BaseType *>::const_iterator Constants_citer ;
00094 typedef std::vector<BaseType *>::iterator Constants_iter ;
00095
00096 typedef std::list<function>::const_iterator Functions_citer ;
00097 typedef std::list<function>::iterator Functions_iter ;
00098
00099 ConstraintEvaluator();
00100 virtual ~ConstraintEvaluator();
00101
00102 void add_function(const string &name, bool_func f);
00103 void add_function(const string &name, btp_func f);
00104 void add_function(const string &name, proj_func f);
00105
00106 bool find_function(const string &name, bool_func *f) const;
00107 bool find_function(const string &name, btp_func *f) const;
00108 bool find_function(const string &name, proj_func *f) const;
00109
00110 void append_clause(int op, rvalue *arg1, rvalue_list *arg2);
00111 void append_clause(bool_func func, rvalue_list *args);
00112 void append_clause(btp_func func, rvalue_list *args);
00113
00114 bool functional_expression();
00115 bool boolean_expression();
00116 bool eval_selection(DDS &dds, const string &dataset);
00117 BaseType *eval_function(DDS &dds, const string &dataset);
00118
00119
00120
00121 bool function_clauses();
00122 DDS *eval_function_clauses(DDS &dds);
00123 DataDDS *eval_function_clauses(DataDDS &dds);
00124
00125 Clause_iter clause_begin();
00126 Clause_iter clause_end();
00127 bool clause_value(Clause_iter &i, DDS &dds);
00128
00129 void parse_constraint(const string &constraint, DDS &dds);
00130 void append_constant(BaseType *btp);
00131
00132 };
00133
00134 }
00135
00136 #endif // constraint_evaluator_h