libdap  Updated for version 3.20.6
libdap4 is an implementation of OPeNDAP's DAP protocol.
Grid.h
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 #ifndef _basetype_h
46 #include "BaseType.h"
47 #endif
48 
49 #ifndef _array_h
50 #include "Array.h"
51 #endif
52 
53 #ifndef _constructor_h
54 #include "Constructor.h"
55 #endif
56 
57 #ifndef constraint_evaluator_h
58 #include "ConstraintEvaluator.h"
59 #endif
60 
61 namespace libdap
62 {
63 
64 class D4Grup;
65 class XMLWriter;
66 
122 class Grid: public Constructor
123 {
124 private:
125  //BaseType *d_array_var; // weak pointer to the
126  bool d_is_array_set;
127 
128 protected: // subclasses need access [mjohnson 11 nov 2009]
129  void m_duplicate(const Grid &s);
130 
131 public:
132 
133  Grid(const string &n);
134  Grid(const string &n, const string &d);
135  Grid(const Grid &rhs);
136  virtual ~Grid();
137 
138  typedef std::vector<BaseType *>::const_iterator Map_citer ;
139  typedef std::vector<BaseType *>::iterator Map_iter ;
140  typedef std::vector<BaseType *>::reverse_iterator Map_riter ;
141 
142 
143  Grid &operator=(const Grid &rhs);
144  virtual BaseType *ptr_duplicate();
145 
146  virtual void transform_to_dap4(D4Group *root, Constructor *container);
147 
148  virtual bool is_dap2_only_type();
149 
150  virtual void add_var(BaseType *bt, Part part);
151  virtual void add_var_nocopy(BaseType *bt, Part part);
152 
153  virtual void set_array(Array* p_new_arr);
154  virtual Array* add_map(Array* p_new_map, bool add_copy);
155  virtual Array* prepend_map(Array* p_new_map, bool add_copy);
156 
157  BaseType *array_var();
158  Array *get_array();
159 
160  // virtual unsigned int width(bool constrained = false);
161 
162  virtual int components(bool constrained = false);
163 
164  virtual bool projection_yields_grid();
165 
166  virtual void clear_constraint();
167 
168  virtual void print_decl(ostream &out, string space = " ",
169  bool print_semi = true,
170  bool constraint_info = false,
171  bool constrained = false);
172 
173  virtual void print_xml(ostream &out, string space = " ",
174  bool constrained = false);
175  virtual void print_xml_writer(XMLWriter &xml, bool constrained = false);
176 
177  virtual void print_val(ostream &out, string space = "",
178  bool print_decl_p = true);
179 
180  virtual void print_decl(FILE *out, string space = " ",
181  bool print_semi = true,
182  bool constraint_info = false,
183  bool constrained = false);
184  virtual void print_xml(FILE *out, string space = " ",
185  bool constrained = false);
186  virtual void print_val(FILE *out, string space = "",
187  bool print_decl_p = true);
188 
189  virtual void transfer_attributes(AttrTable *at_container);
190 
191  virtual bool check_semantics(string &msg, bool all = false);
192 
193  Map_iter map_begin() ;
194  Map_iter map_end() ;
195  Map_riter map_rbegin() ;
196  Map_riter map_rend() ;
197  Map_iter get_map_iter(int i);
198 
199  virtual void dump(ostream &strm) const ;
200 };
201 
202 } // namespace libdap
203 
204 #endif // _grid_h
205 
Map_riter map_rend()
Definition: Grid.cc:554
virtual Array * prepend_map(Array *p_new_map, bool add_copy)
Definition: Grid.cc:484
virtual void add_var_nocopy(BaseType *bt, Part part)
Definition: Grid.cc:330
Part
Names the parts of multi-section constructor data types.
Definition: Type.h:48
Contains the attributes for a dataset.
Definition: AttrTable.h:142
virtual void print_xml(ostream &out, string space=" ", bool constrained=false)
Definition: Grid.cc:819
virtual void dump(ostream &strm) const
dumps information about this object
Definition: Grid.cc:1033
Map_iter map_end()
Definition: Grid.cc:537
top level DAP object to house generic methods
Definition: AISConnect.cc:30
virtual int components(bool constrained=false)
Returns the number of components in the Grid object.
Definition: Grid.cc:585
Map_riter map_rbegin()
Returns an iterator referencing the first Map vector.
Definition: Grid.cc:544
virtual void set_array(Array *p_new_arr)
Definition: Grid.cc:389
virtual bool projection_yields_grid()
Definition: Grid.cc:692
Map_iter map_begin()
Returns an iterator referencing the first Map vector.
Definition: Grid.cc:525
virtual BaseType * ptr_duplicate()
Definition: Grid.cc:116
Map_iter get_map_iter(int i)
Definition: Grid.cc:563
virtual void add_var(BaseType *bt, Part part)
Definition: Grid.cc:264
virtual void transfer_attributes(AttrTable *at_container)
Definition: Grid.cc:610
virtual void clear_constraint()
Definition: Grid.cc:736
Holds the Grid data type.
Definition: Grid.h:122
virtual void print_val(ostream &out, string space="", bool print_decl_p=true)
Prints the value of the variable.
Definition: Grid.cc:900
virtual Array * add_map(Array *p_new_map, bool add_copy)
Definition: Grid.cc:455
Array * get_array()
Returns the Grid Array. This method returns the array using an Array*, so no cast is required...
Definition: Grid.cc:518
virtual bool is_dap2_only_type()
Definition: Grid.cc:246
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:753
The basic data type for the DODS DAP types.
Definition: BaseType.h:117
virtual bool check_semantics(string &msg, bool all=false)
Return true if this Grid is well formed.
Definition: Grid.cc:937
virtual void transform_to_dap4(D4Group *root, Constructor *container)
DAP2 to DAP4 transform.
Definition: Grid.cc:148
BaseType * array_var()
Returns the Grid Array.
Definition: Grid.cc:501
A multidimensional array of identical data types.
Definition: Array.h:112
virtual void print_xml_writer(XMLWriter &xml, bool constrained=false)
Definition: Grid.cc:847
Grid(const string &n)
The Grid constructor.
Definition: Grid.cc:86