libdap Updated for version 3.21.1
libdap4 is an implementation of OPeNDAP's DAP protocol.
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 "RValue.h"
31#include "expr.h"
32
33namespace libdap {
34
35class DDS;
36class DataDDS;
37struct Clause;
39
41class ConstraintEvaluator {
42private:
43 std::vector<Clause *> expr; // List of CE Clauses
44
45 std::vector<BaseType *> constants; // List of temporary objects
46
47 ServerFunctionsList *d_functions_list; // Known external functions from
48 // modules
49
50 // The default versions of these methods will break this class. Because
51 // Clause does not support deep copies, that class will need to be modified
52 // before these can be properly implemented. jhrg 4/3/06
53 ConstraintEvaluator(const ConstraintEvaluator &);
54 ConstraintEvaluator &operator=(const ConstraintEvaluator &);
55
56 friend class func_name_is;
57
58public:
59 typedef std::vector<Clause *>::const_iterator Clause_citer;
60 typedef std::vector<Clause *>::iterator Clause_iter;
61
62 typedef std::vector<BaseType *>::const_iterator Constants_citer;
63 typedef std::vector<BaseType *>::iterator Constants_iter;
64
66
67 virtual ~ConstraintEvaluator();
68 bool find_function(const std::string &name, bool_func *f) const;
69 bool find_function(const std::string &name, btp_func *f) const;
70 bool find_function(const std::string &name, proj_func *f) const;
71
72 void append_clause(int op, rvalue *arg1, rvalue_list *arg2);
73 void append_clause(bool_func func, rvalue_list *args);
74 void append_clause(btp_func func, rvalue_list *args);
75
77 bool boolean_expression();
78 bool eval_selection(DDS &dds, const std::string &dataset);
79 BaseType *eval_function(DDS &dds, const std::string &dataset);
80
81 // New for libdap 3.11. These methods provide a way to evaluate multiple
82 // functions in one CE
83 bool function_clauses();
86
89 bool clause_value(Clause_iter &i, DDS &dds);
90
91 void parse_constraint(const std::string &constraint, DDS &dds);
92 void append_constant(BaseType *btp);
93};
94
95} // namespace libdap
96
97#endif // constraint_evaluator_h
The basic data type for the DODS DAP types.
Definition BaseType.h:118
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.
std::vector< BaseType * >::const_iterator Constants_citer
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.
std::vector< BaseType * >::iterator Constants_iter
std::vector< Clause * >::const_iterator Clause_citer
bool functional_expression()
Does the current constraint expression return a BaseType pointer? This method does not evaluate the c...
std::vector< Clause * >::iterator Clause_iter
Holds a DAP2 DDS.
Definition DataDDS.h:76
top level DAP object to house generic methods
Definition AISConnect.cc:30
std::vector< rvalue * > rvalue_list
Definition RValue.h:69
Holds a fragment of a constraint expression.
Definition Clause.h:88