libdap  Updated for version 3.20.6
libdap4 is an implementation of OPeNDAP's DAP protocol.
D4FunctionEvaluator.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) 2014 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 D4_FUNCTION_DRIVER_H_
26 #define D4_FUNCTION_DRIVER_H_
27 
28 #include <string>
29 #include <vector>
30 #include <stack>
31 
32 namespace libdap {
33 
34 class location;
35 
36 class BaseType;
37 class Array;
38 class ServerFunctionsList;
39 
40 class DMR;
41 class D4Dimension;
42 class D4RValue;
43 class D4RValueList;
44 
49 {
50  bool d_trace_scanning;
51  bool d_trace_parsing;
52  std::string d_expr;
53 
54  DMR *d_dmr;
55  ServerFunctionsList *d_sf_list;
56 
57  D4RValueList *d_result;
58 
59  std::stack<BaseType*> d_basetype_stack;
60 
61  unsigned long long d_arg_length_hint;
62 
63  // d_expr should be set by parse! Its value is used by the parser right before
64  // the actual parsing operation starts. jhrg 11/26/13
65  std::string *expression()
66  {
67  return &d_expr;
68  }
69 
70  void push_basetype(BaseType *btp)
71  {
72  d_basetype_stack.push(btp);
73  }
74  BaseType *top_basetype() const
75  {
76  return d_basetype_stack.empty() ? 0 : d_basetype_stack.top();
77  }
78  void pop_basetype()
79  {
80  d_basetype_stack.pop();
81  }
82 
83  D4RValue *build_rvalue(const std::string &id);
84 
85  friend class D4FunctionParser;
86 
87 public:
89  d_trace_scanning(false), d_trace_parsing(false), d_expr(""), d_dmr(0), d_sf_list(0), d_result(0), d_arg_length_hint(
90  0)
91  {
92  }
94  d_trace_scanning(false), d_trace_parsing(false), d_expr(""), d_dmr(dmr), d_sf_list(sf_list), d_result(0), d_arg_length_hint(
95  0)
96  {
97  }
98 
99  virtual ~D4FunctionEvaluator()
100  {
101  }
102 
103  bool parse(const std::string &expr);
104 
105  bool trace_scanning() const
106  {
107  return d_trace_scanning;
108  }
109  void set_trace_scanning(bool ts)
110  {
111  d_trace_scanning = ts;
112  }
113 
114  bool trace_parsing() const
115  {
116  return d_trace_parsing;
117  }
118  void set_trace_parsing(bool tp)
119  {
120  d_trace_parsing = tp;
121  }
122 
128  {
129  return d_result;
130  }
131  void set_result(D4RValueList *rv_list)
132  {
133  d_result = rv_list;
134  }
135 
136  void eval(DMR *dmr);
137 
138  unsigned long long get_arg_length_hint() const
139  {
140  return d_arg_length_hint;
141  }
142  void set_arg_length_hint(unsigned long long alh)
143  {
144  d_arg_length_hint = alh;
145  }
146 
147  DMR *dmr() const
148  {
149  return d_dmr;
150  }
151  void set_dmr(DMR *dmr)
152  {
153  d_dmr = dmr;
154  }
155 
156  ServerFunctionsList *sf_list() const
157  {
158  return d_sf_list;
159  }
160  void set_sf_list(ServerFunctionsList *sf_list)
161  {
162  d_sf_list = sf_list;
163  }
164 
165  template<typename t> std::vector<t> *init_arg_list(t val);
166 
167  void error(const libdap::location &l, const std::string &m);
168 };
169 
170 } /* namespace libdap */
171 #endif /* D4_FUNCTION_DRIVER_H_ */
top level DAP object to house generic methods
Definition: AISConnect.cc:30
D4RValueList * result() const
bool parse(const std::string &expr)
The basic data type for the DODS DAP types.
Definition: BaseType.h:117