libdap
Updated for version 3.17.0
|
00001 // -*- mode: c++; c-basic-offset:4 -*- 00002 00003 // This file is part of libdap, A C++ implementation of the OPeNDAP Data 00004 // Access Protocol. 00005 00006 // Copyright (c) 2006 OPeNDAP, Inc. 00007 // Author: James Gallagher <jgallagher@opendap.org> 00008 // 00009 // This library is free software; you can redistribute it and/or 00010 // modify it under the terms of the GNU Lesser General Public 00011 // License as published by the Free Software Foundation; either 00012 // version 2.1 of the License, or (at your option) any later version. 00013 // 00014 // This library is distributed in the hope that it will be useful, 00015 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00016 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00017 // Lesser General Public License for more details. 00018 // 00019 // You should have received a copy of the GNU Lesser General Public 00020 // License along with this library; if not, write to the Free Software 00021 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 00022 // 00023 // You can contact OPeNDAP, Inc. at PO Box 112, Saunderstown, RI. 02874-0112. 00024 00025 #ifndef constraint_evaluator_h 00026 #define constraint_evaluator_h 00027 00028 #include <vector> 00029 00030 #include "expr.h" 00031 #include "RValue.h" 00032 00033 namespace libdap 00034 { 00035 00036 class DDS; 00037 class DataDDS; 00038 struct Clause; 00039 class ServerFunctionsList; 00040 00042 class ConstraintEvaluator 00043 { 00044 private: 00045 std::vector<Clause *> expr; // List of CE Clauses 00046 00047 std::vector<BaseType *> constants;// List of temporary objects 00048 00049 ServerFunctionsList *d_functions_list; // Known external functions from 00050 // modules 00051 00052 // The default versions of these methods will break this class. Because 00053 // Clause does not support deep copies, that class will need to be modified 00054 // before these can be properly implemented. jhrg 4/3/06 00055 ConstraintEvaluator(const ConstraintEvaluator &); 00056 ConstraintEvaluator &operator=(const ConstraintEvaluator &); 00057 00058 friend class func_name_is; 00059 00060 public: 00061 typedef std::vector<Clause *>::const_iterator Clause_citer ; 00062 typedef std::vector<Clause *>::iterator Clause_iter ; 00063 00064 typedef std::vector<BaseType *>::const_iterator Constants_citer ; 00065 typedef std::vector<BaseType *>::iterator Constants_iter ; 00066 00067 ConstraintEvaluator(); 00068 00069 virtual ~ConstraintEvaluator(); 00070 bool find_function(const std::string &name, bool_func *f) const; 00071 bool find_function(const std::string &name, btp_func *f) const; 00072 bool find_function(const std::string &name, proj_func *f) const; 00073 00074 void append_clause(int op, rvalue *arg1, rvalue_list *arg2); 00075 void append_clause(bool_func func, rvalue_list *args); 00076 void append_clause(btp_func func, rvalue_list *args); 00077 00078 bool functional_expression(); 00079 bool boolean_expression(); 00080 bool eval_selection(DDS &dds, const std::string &dataset); 00081 BaseType *eval_function(DDS &dds, const std::string &dataset); 00082 00083 // New for libdap 3.11. These methods provide a way to evaluate multiple 00084 // functions in one CE 00085 bool function_clauses(); 00086 DDS *eval_function_clauses(DDS &dds); 00087 DataDDS *eval_function_clauses(DataDDS &dds); 00088 00089 Clause_iter clause_begin(); 00090 Clause_iter clause_end(); 00091 bool clause_value(Clause_iter &i, DDS &dds); 00092 00093 void parse_constraint(const std::string &constraint, DDS &dds); 00094 void append_constant(BaseType *btp); 00095 00096 }; 00097 00098 } // namespace libdap 00099 00100 #endif // constraint_evaluator_h