libdap++  Updated for version 3.12.0
Grid.h
Go to the documentation of this file.
1 
2 // -*- mode: c++; c-basic-offset:4 -*-
3 
4 // This file is part of libdap, A C++ implementation of the OPeNDAP Data
5 // Access Protocol.
6 
7 // Copyright (c) 2002,2003 OPeNDAP, Inc.
8 // Author: James Gallagher <jgallagher@opendap.org>
9 //
10 // This library is free software; you can redistribute it and/or
11 // modify it under the terms of the GNU Lesser General Public
12 // License as published by the Free Software Foundation; either
13 // version 2.1 of the License, or (at your option) any later version.
14 //
15 // This library is distributed in the hope that it will be useful,
16 // but WITHOUT ANY WARRANTY; without even the implied warranty of
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 // Lesser General Public License for more details.
19 //
20 // You should have received a copy of the GNU Lesser General Public
21 // License along with this library; if not, write to the Free Software
22 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
23 //
24 // You can contact OPeNDAP, Inc. at PO Box 112, Saunderstown, RI. 02874-0112.
25 
26 // (c) COPYRIGHT URI/MIT 1994-1999
27 // Please read the full copyright statement in the file COPYRIGHT_URI.
28 //
29 // Authors:
30 // jhrg,jimg James Gallagher <jgallagher@gso.uri.edu>
31 
32 // Interface to the Grid ctor class. Grids contain a single array (the `main'
33 // array) of dimension N and N single dimension arrays (map arrays). For any
34 // dimension n of the main array, the size of the nth map array must match
35 // the size of the main array's nth dimension. Grids are used to map
36 // non-integer scales to multidimensional point data.
37 //
38 // jhrg 9/15/94
39 
40 #ifndef _grid_h
41 #define _grid_h 1
42 
43 #include <vector>
44 
45 //#include "Pix.h"
46 
47 #ifndef _basetype_h
48 #include "BaseType.h"
49 #endif
50 
51 #ifndef _array_h
52 #include "Array.h"
53 #endif
54 
55 #ifndef _constructor_h
56 #include "Constructor.h"
57 #endif
58 
59 #ifndef constraint_evaluator_h
60 #include "ConstraintEvaluator.h"
61 #endif
62 
63 namespace libdap
64 {
65 
121 class Grid: public Constructor
122 {
123 private:
124  BaseType *d_array_var;
125  std::vector<BaseType *> d_map_vars;
126 
127 protected: // subclasses need access [mjohnson 11 nov 2009]
128  void m_duplicate(const Grid &s);
129 
130 public:
131 
132  Grid(const string &n);
133  Grid(const string &n, const string &d);
134  Grid(const Grid &rhs);
135  virtual ~Grid();
136 
137  typedef std::vector<BaseType *>::const_iterator Map_citer ;
138  typedef std::vector<BaseType *>::iterator Map_iter ;
139  typedef std::vector<BaseType *>::reverse_iterator Map_riter ;
140 
141 
142  Grid &operator=(const Grid &rhs);
143  virtual BaseType *ptr_duplicate();
144 
145  virtual bool is_dap2_only_type();
146 
147  virtual int element_count(bool leaves = false);
148 
149  virtual void set_send_p(bool state);
150  virtual void set_read_p(bool state);
151  virtual void set_in_selection(bool state);
152 
153  virtual BaseType *var(const string &n, bool exact = true, btp_stack *s = 0);
154  virtual BaseType *var(const string &n, btp_stack &s);
155 
156  virtual void add_var(BaseType *bt, Part part);
157  virtual void add_var_nocopy(BaseType *bt, Part part);
158 
159  virtual void set_array(Array* p_new_arr);
160  virtual Array* add_map(Array* p_new_map, bool add_copy);
161  virtual Array* prepend_map(Array* p_new_map, bool add_copy);
162 
163  BaseType *array_var();
164  Array *get_array();
165 
166  virtual unsigned int width(bool constrained = false);
167 #if 0
168  virtual unsigned int width(bool constrained);
169 #endif
170  virtual int components(bool constrained = false);
171 
172  virtual bool projection_yields_grid();
173 
174  virtual void clear_constraint();
175 
176  virtual void intern_data(ConstraintEvaluator &eval, DDS &dds);
177  virtual bool serialize(ConstraintEvaluator &eval, DDS &dds, Marshaller &m, bool ce_eval = true);
178  virtual bool deserialize(UnMarshaller &um, DDS *dds, bool reuse = false);
179 #if 0
180  virtual unsigned int val2buf(void *buf, bool reuse = false);
181  virtual unsigned int buf2val(void **val);
182 #endif
183 
184  virtual void print_decl(ostream &out, string space = " ",
185  bool print_semi = true,
186  bool constraint_info = false,
187  bool constrained = false);
188 
189  virtual void print_xml(ostream &out, string space = " ",
190  bool constrained = false);
191  virtual void print_xml_writer(XMLWriter &xml, bool constrained = false);
192 
193  virtual void print_val(ostream &out, string space = "",
194  bool print_decl_p = true);
195 
196  virtual void print_decl(FILE *out, string space = " ",
197  bool print_semi = true,
198  bool constraint_info = false,
199  bool constrained = false);
200  virtual void print_xml(FILE *out, string space = " ",
201  bool constrained = false);
202  virtual void print_val(FILE *out, string space = "",
203  bool print_decl_p = true);
204 
205  virtual void transfer_attributes(AttrTable *at_container);
206 
207  virtual bool check_semantics(string &msg, bool all = false);
208 
209  Map_iter map_begin() ;
210  Map_iter map_end() ;
212  Map_riter map_rend() ;
213  Map_iter get_map_iter(int i);
214 
215  virtual void dump(ostream &strm) const ;
216 };
217 
218 } // namespace libdap
219 
220 #endif // _grid_h
221