libdap Updated for version 3.20.11
libdap4 is an implementation of OPeNDAP's DAP protocol.
ConstraintEvaluator.h
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
33namespace libdap
34{
35
36class DDS;
37class DataDDS;
38struct Clause;
39class ServerFunctionsList;
40
43{
44private:
45 std::vector<Clause *> expr; // List of CE Clauses
46
47 std::vector<BaseType *> constants;// List of temporary objects
48
49 ServerFunctionsList *d_functions_list; // Known 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 ConstraintEvaluator &operator=(const ConstraintEvaluator &);
57
58 friend class func_name_is;
59
60public:
61 typedef std::vector<Clause *>::const_iterator Clause_citer ;
62 typedef std::vector<Clause *>::iterator Clause_iter ;
63
64 typedef std::vector<BaseType *>::const_iterator Constants_citer ;
65 typedef std::vector<BaseType *>::iterator Constants_iter ;
66
68
69 virtual ~ConstraintEvaluator();
70 bool find_function(const std::string &name, bool_func *f) const;
71 bool find_function(const std::string &name, btp_func *f) const;
72 bool find_function(const std::string &name, proj_func *f) const;
73
74 void append_clause(int op, rvalue *arg1, rvalue_list *arg2);
75 void append_clause(bool_func func, rvalue_list *args);
76 void append_clause(btp_func func, rvalue_list *args);
77
79 bool boolean_expression();
80 bool eval_selection(DDS &dds, const std::string &dataset);
81 BaseType *eval_function(DDS &dds, const std::string &dataset);
82
83 // New for libdap 3.11. These methods provide a way to evaluate multiple
84 // functions in one CE
85 bool function_clauses();
88
89 Clause_iter clause_begin();
90 Clause_iter clause_end();
91 bool clause_value(Clause_iter &i, DDS &dds);
92
93 void parse_constraint(const std::string &constraint, DDS &dds);
94 void append_constant(BaseType *btp);
95
96};
97
98} // namespace libdap
99
100#endif // constraint_evaluator_h
The basic data type for the DODS DAP types.
Definition: BaseType.h:118
Evaluate a constraint expression.
bool boolean_expression()
Does the current constraint expression return a boolean value?
bool eval_selection(DDS &dds, const std::string &dataset)
Evaluate a boolean-valued constraint expression. This is main method for the evaluator and is called ...
bool find_function(const std::string &name, bool_func *f) const
Find a Boolean function with a given name in the function list.
bool clause_value(Clause_iter &i, DDS &dds)
void parse_constraint(const std::string &constraint, DDS &dds)
Parse the constraint expression given the current DDS.
void append_clause(int op, rvalue *arg1, rvalue_list *arg2)
Add a clause to a constraint expression.
BaseType * eval_function(DDS &dds, const std::string &dataset)
Evaluate a function-valued constraint expression.
bool function_clauses()
Does the current constraint expression contain function clauses.
DDS * eval_function_clauses(DDS &dds)
Evaluate a function-valued constraint expression that contains several function calls.
void append_constant(BaseType *btp)
bool functional_expression()
Does the current constraint expression return a BaseType pointer? This method does not evaluate the c...
Holds a DAP2 DDS.
Definition: DataDDS.h:78
top level DAP object to house generic methods
Definition: AlarmHandler.h:36