libdap++  Updated for version 3.11.7
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 
Map_riter map_rend()
Definition: Grid.cc:697
abstract base class used to unmarshall/deserialize dap data objects
Definition: UnMarshaller.h:54
virtual Array * prepend_map(Array *p_new_map, bool add_copy)
Definition: Grid.cc:635
virtual void add_var_nocopy(BaseType *bt, Part part)
Definition: Grid.cc:489
Part
Names the parts of multi-section constructor data types.
Definition: BaseType.h:102
virtual bool serialize(ConstraintEvaluator &eval, DDS &dds, Marshaller &m, bool ce_eval=true)
Move data to the net.
Definition: Grid.cc:269
virtual void dump(ostream &strm) const
dumps information about this object
Definition: Grid.cc:1326
Contains the attributes for a dataset.
Definition: AttrTable.h:150
virtual unsigned int width()
Returns the size of the class instance data.
Definition: Grid.cc:204
Grid & operator=(const Grid &rhs)
Definition: Grid.cc:127
virtual void print_xml(ostream &out, string space=" ", bool constrained=false)
Definition: Grid.cc:1053
virtual void set_in_selection(bool state)
Definition: Grid.cc:192
Map_iter map_end()
Definition: Grid.cc:682
virtual void set_send_p(bool state)
Definition: Grid.cc:168
virtual unsigned int val2buf(void *buf, bool reuse=false)
Returns the size of the Grid type.
Definition: Grid.cc:346
stack< BaseType * > btp_stack
Definition: BaseType.h:218
std::vector< BaseType * >::const_iterator Map_citer
Definition: Grid.h:139
virtual int components(bool constrained=false)
Returns the number of components in the Grid object.
Definition: Grid.cc:727
Map_riter map_rbegin()
Returns an iterator referencing the first Map vector.
Definition: Grid.cc:689
virtual void set_array(Array *p_new_arr)
Definition: Grid.cc:559
virtual int element_count(bool leaves=false)
Count the members of constructor types.
Definition: Grid.cc:149
virtual bool projection_yields_grid()
Definition: Grid.cc:801
Map_iter map_begin()
Returns an iterator referencing the first Map vector.
Definition: Grid.cc:674
virtual BaseType * ptr_duplicate()
Definition: Grid.cc:121
Map_iter get_map_iter(int i)
Definition: Grid.cc:706
virtual void intern_data(ConstraintEvaluator &eval, DDS &dds)
Definition: Grid.cc:249
virtual void add_var(BaseType *bt, Part part)
Definition: Grid.cc:405
virtual void transfer_attributes(AttrTable *at_container)
Definition: Grid.cc:747
virtual void clear_constraint()
Definition: Grid.cc:845
virtual ~Grid()
Definition: Grid.cc:110
virtual void set_read_p(bool state)
Sets the value of the read_p property.
Definition: Grid.cc:180
Holds the Grid data type.
Definition: Grid.h:123
virtual void print_val(ostream &out, string space="", bool print_decl_p=true)
Prints the value of the variable.
Definition: Grid.cc:1193
virtual Array * add_map(Array *p_new_map, bool add_copy)
Definition: Grid.cc:603
Array * get_array()
Returns the Grid Array. This method returns the array using an Array*, so no cast is required...
Definition: Grid.cc:663
std::vector< BaseType * >::iterator Map_iter
Definition: Grid.h:140
std::vector< BaseType * >::reverse_iterator Map_riter
Definition: Grid.h:141
virtual void print_decl(ostream &out, string space=" ", bool print_semi=true, bool constraint_info=false, bool constrained=false)
Print an ASCII representation of the variable structure.
Definition: Grid.cc:911
Evaluate a constraint expression.
virtual bool deserialize(UnMarshaller &um, DDS *dds, bool reuse=false)
Receive data from the net.
Definition: Grid.cc:327
virtual BaseType * var(const string &n, bool exact=true, btp_stack *s=0)
Definition: Grid.cc:371
The basic data type for the DODS DAP types.
Definition: BaseType.h:194
abstract base class used to marshal/serialize dap data objects
Definition: Marshaller.h:53
virtual unsigned int buf2val(void **val)
Definition: Grid.cc:355
virtual bool check_semantics(string &msg, bool all=false)
Return true if this Grid is well formed.
Definition: Grid.cc:1229
void _duplicate(const Grid &s)
Definition: Grid.cc:57
BaseType * array_var()
Returns the Grid Array.
Definition: Grid.cc:654
A multidimensional array of identical data types.
Definition: Array.h:105
virtual void print_xml_writer(XMLWriter &xml, bool constrained=false)
Definition: Grid.cc:1115
Grid(const string &n)
The Grid constructor.
Definition: Grid.cc:86