libdap++  Updated for version 3.8.2
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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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 #define FILE_METHODS 1
64 
65 namespace libdap
66 {
67 
123 class Grid: public Constructor
124 {
125 private:
126  BaseType *_array_var;
127  std::vector<BaseType *> _map_vars;
128 
129 protected: // subclasses need access [mjohnson 11 nov 2009]
130  void _duplicate(const Grid &s);
131 
132 public:
133 
134  Grid(const string &n);
135  Grid(const string &n, const string &d);
136  Grid(const Grid &rhs);
137  virtual ~Grid();
138 
139  typedef std::vector<BaseType *>::const_iterator Map_citer ;
140  typedef std::vector<BaseType *>::iterator Map_iter ;
141  typedef std::vector<BaseType *>::reverse_iterator Map_riter ;
142 
143 
144  Grid &operator=(const Grid &rhs);
145  virtual BaseType *ptr_duplicate();
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,
154  btp_stack *s = 0);
155 
156  virtual BaseType *var(const string &n, btp_stack &s);
157 
158  virtual void add_var(BaseType *bt, Part part);
159  virtual void add_var_nocopy(BaseType *bt, Part part);
160 
161  virtual void set_array(Array* p_new_arr);
162  virtual Array* add_map(Array* p_new_map, bool add_copy);
163  virtual Array* prepend_map(Array* p_new_map, bool add_copy);
164 
165  BaseType *array_var();
166  Array *get_array();
167 
168 
169  virtual unsigned int width();
170  virtual unsigned int width(bool constrained);
171 
172  virtual int components(bool constrained = false);
173 
174  virtual bool projection_yields_grid();
175 
176  virtual void clear_constraint();
177 
178  virtual void intern_data(ConstraintEvaluator &eval, DDS &dds);
179  virtual bool serialize(ConstraintEvaluator &eval, DDS &dds,
180  Marshaller &m, bool ce_eval = true);
181  virtual bool deserialize(UnMarshaller &um, DDS *dds, bool reuse = false);
182 
183  virtual unsigned int val2buf(void *buf, bool reuse = false);
184 
185  virtual unsigned int buf2val(void **val);
186 
187  virtual void print_decl(ostream &out, string space = " ",
188  bool print_semi = true,
189  bool constraint_info = false,
190  bool constrained = false);
191 
192  virtual void print_xml(ostream &out, string space = " ",
193  bool constrained = false);
194  virtual void print_xml_writer(XMLWriter &xml, bool constrained = false);
195 
196  virtual void print_val(ostream &out, string space = "",
197  bool print_decl_p = true);
198 
199 #if FILE_METHODS
200  virtual void print_decl(FILE *out, string space = " ",
201  bool print_semi = true,
202  bool constraint_info = false,
203  bool constrained = false);
204  virtual void print_xml(FILE *out, string space = " ",
205  bool constrained = false);
206  virtual void print_val(FILE *out, string space = "",
207  bool print_decl_p = true);
208 #endif
209 
210  virtual void transfer_attributes(AttrTable *at_container);
211 
212  virtual bool check_semantics(string &msg, bool all = false);
213 
214  Map_iter map_begin() ;
215  Map_iter map_end() ;
217  Map_riter map_rend() ;
218  Map_iter get_map_iter(int i);
219 
220  virtual void dump(ostream &strm) const ;
221 };
222 
223 } // namespace libdap
224 
225 #endif // _grid_h
226