libdap++  Updated for version 3.12.0
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 <list>
29 
30 #ifndef _dds_h
31 #include "DDS.h"
32 #endif
33 
34 #ifndef _datadds_h
35 #include "DataDDS.h"
36 #endif
37 
38 #ifndef _clause_h
39 #include "Clause.h"
40 #endif
41 
42 namespace libdap
43 {
44 
45 class ServerFunctionsList;
46 
49 {
50 private:
51 #if 0
52  // This struct is used to hold all the known `user defined' functions
53  // (including those that are `built-in').
54  struct function
55  {
56  string name;
57  bool_func b_func;
58  btp_func bt_func;
59  proj_func p_func;
60 
61  function(const string &n, const bool_func f)
62  : name(n), b_func(f), bt_func(0), p_func(0)
63  {}
64  function(const string &n, const btp_func f)
65  : name(n), bt_func(f), p_func(0)
66  {}
67  function(const string &n, const proj_func f)
68  : name(n), bt_func(0), p_func(f)
69  {}
70  function(): name(""), bt_func(0), p_func(0)
71  {}
72  };
73 #endif
74  vector<Clause *> expr; // List of CE Clauses
75 
76  vector<BaseType *> constants;// List of temporary objects
77 #if 0
78  list<function> functions; // Known external functions
79 #endif
80  ServerFunctionsList *d_functions_list; // Know external functions from
81  // modules
82 
83  // The default versions of these methods will break this class. Because
84  // Clause does not support deep copies, that class will need to be modified
85  // before these can be properly implemented. jhrg 4/3/06
87  {}
88  ConstraintEvaluator &operator=(const ConstraintEvaluator &)
89  {
90  throw InternalErr(__FILE__, __LINE__, "Unimplemented method");
91  }
92 
93  friend class func_name_is;
94 
95 public:
96  typedef std::vector<Clause *>::const_iterator Clause_citer ;
97  typedef std::vector<Clause *>::iterator Clause_iter ;
98 
99  typedef std::vector<BaseType *>::const_iterator Constants_citer ;
100  typedef std::vector<BaseType *>::iterator Constants_iter ;
101 #if 0
102  typedef std::list<function>::const_iterator Functions_citer ;
103  typedef std::list<function>::iterator Functions_iter ;
104 #endif
105 
107 
108  virtual ~ConstraintEvaluator();
109 #if 0
110  void add_function(const string &name, bool_func f);
111  void add_function(const string &name, btp_func f);
112  void add_function(const string &name, proj_func f);
113 #endif
114  bool find_function(const string &name, bool_func *f) const;
115  bool find_function(const string &name, btp_func *f) const;
116  bool find_function(const string &name, proj_func *f) const;
117 
118  void append_clause(int op, rvalue *arg1, rvalue_list *arg2);
119  void append_clause(bool_func func, rvalue_list *args);
120  void append_clause(btp_func func, rvalue_list *args);
121 
122  bool functional_expression();
123  bool boolean_expression();
124  bool eval_selection(DDS &dds, const string &dataset);
125  BaseType *eval_function(DDS &dds, const string &dataset);
126 
127  // New for libdap 3.11. These methods provide a way to evaluate multiple
128  // functions in one CE
129  bool function_clauses();
132 
135  bool clause_value(Clause_iter &i, DDS &dds);
136 
137  void parse_constraint(const string &constraint, DDS &dds);
138  void append_constant(BaseType *btp);
139 
140 };
141 
142 } // namespace libdap
143 
144 #endif // constraint_evaluator_h