libdap++  Updated for version 3.13.1
ConstraintEvaluator.h
Go to the documentation of this file.
1 // -*- mode: c++; c-basic-offset:4 -*-
2 
3 // This file is part of libdap, A C++ implementation of the OPeNDAP Data
4 // Access Protocol.
5 
6 // Copyright (c) 2006 OPeNDAP, Inc.
7 // Author: James Gallagher <jgallagher@opendap.org>
8 //
9 // This library is free software; you can redistribute it and/or
10 // modify it under the terms of the GNU Lesser General Public
11 // License as published by the Free Software Foundation; either
12 // version 2.1 of the License, or (at your option) any later version.
13 //
14 // This library is distributed in the hope that it will be useful,
15 // but WITHOUT ANY WARRANTY; without even the implied warranty of
16 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 // Lesser General Public License for more details.
18 //
19 // You should have received a copy of the GNU Lesser General Public
20 // License along with this library; if not, write to the Free Software
21 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
22 //
23 // You can contact OPeNDAP, Inc. at PO Box 112, Saunderstown, RI. 02874-0112.
24 
25 #ifndef constraint_evaluator_h
26 #define constraint_evaluator_h
27 
28 #include <vector>
29 
30 #include "expr.h"
31 #include "RValue.h"
32 
33 namespace libdap
34 {
35 
36 class DDS;
37 class DataDDS;
38 struct Clause;
39 class ServerFunctionsList;
40 
43 {
44 private:
45  vector<Clause *> expr; // List of CE Clauses
46 
47  vector<BaseType *> constants;// List of temporary objects
48 
49  ServerFunctionsList *d_functions_list; // Know external functions from
50  // modules
51 
52  // The default versions of these methods will break this class. Because
53  // Clause does not support deep copies, that class will need to be modified
54  // before these can be properly implemented. jhrg 4/3/06
56  {}
57  ConstraintEvaluator &operator=(const ConstraintEvaluator &)
58  {
59  throw InternalErr(__FILE__, __LINE__, "Unimplemented method");
60  }
61 
62  friend class func_name_is;
63 
64 public:
65  typedef std::vector<Clause *>::const_iterator Clause_citer ;
66  typedef std::vector<Clause *>::iterator Clause_iter ;
67 
68  typedef std::vector<BaseType *>::const_iterator Constants_citer ;
69  typedef std::vector<BaseType *>::iterator Constants_iter ;
70 
72 
73  virtual ~ConstraintEvaluator();
74  bool find_function(const string &name, bool_func *f) const;
75  bool find_function(const string &name, btp_func *f) const;
76  bool find_function(const string &name, proj_func *f) const;
77 
78  void append_clause(int op, rvalue *arg1, rvalue_list *arg2);
79  void append_clause(bool_func func, rvalue_list *args);
80  void append_clause(btp_func func, rvalue_list *args);
81 
82  bool functional_expression();
83  bool boolean_expression();
84  bool eval_selection(DDS &dds, const string &dataset);
85  BaseType *eval_function(DDS &dds, const string &dataset);
86 
87  // New for libdap 3.11. These methods provide a way to evaluate multiple
88  // functions in one CE
89  bool function_clauses();
92 
95  bool clause_value(Clause_iter &i, DDS &dds);
96 
97  void parse_constraint(const string &constraint, DDS &dds);
98  void append_constant(BaseType *btp);
99 
100 };
101 
102 } // namespace libdap
103 
104 #endif // constraint_evaluator_h
std::vector< rvalue * > rvalue_list
Definition: RValue.h:67
bool boolean_expression()
Does the current constraint expression return a boolean value?
BaseType * eval_function(DDS &dds, const string &dataset)
Evaluate a function-valued constraint expression.
void parse_constraint(const string &constraint, DDS &dds)
Parse the constraint expression given the current DDS.
A class for software fault reporting.
Definition: InternalErr.h:64
std::vector< BaseType * >::const_iterator Constants_citer
bool eval_selection(DDS &dds, const string &dataset)
Evaluate a boolean-valued constraint expression. This is main method for the evaluator ans is called ...
DDS * eval_function_clauses(DDS &dds)
Evaluate a function-valued constraint expression that contains several function calls.
std::vector< BaseType * >::iterator Constants_iter
Evaluate a constraint expression.
bool functional_expression()
Does the current constraint expression return a BaseType pointer? This method does not evaluate the c...
std::vector< Clause * >::const_iterator Clause_citer
The basic data type for the DODS DAP types.
Definition: BaseType.h:199
void append_constant(BaseType *btp)
bool clause_value(Clause_iter &i, DDS &dds)
bool function_clauses()
Does the current constraint expression contain function clauses.
std::vector< Clause * >::iterator Clause_iter
Holds a DAP2 DDS.
Definition: DataDDS.h:77
void append_clause(int op, rvalue *arg1, rvalue_list *arg2)
Add a clause to a constraint expression.
bool find_function(const string &name, bool_func *f) const
Find a Boolean function with a given name in the function list.