libdap++  Updated for version 3.13.3
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() ;
211  Map_riter map_rbegin() ;
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 
Map_riter map_rend()
Definition: Grid.cc:715
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:653
virtual void add_var_nocopy(BaseType *bt, Part part)
Definition: Grid.cc:506
Part
Names the parts of multi-section constructor data types.
Definition: BaseType.h:95
virtual bool serialize(ConstraintEvaluator &eval, DDS &dds, Marshaller &m, bool ce_eval=true)
Move data to the net.
Definition: Grid.cc:281
virtual void dump(ostream &strm) const
dumps information about this object
Definition: Grid.cc:1161
Contains the attributes for a dataset.
Definition: AttrTable.h:150
Grid & operator=(const Grid &rhs)
Definition: Grid.cc:128
virtual void print_xml(ostream &out, string space=" ", bool constrained=false)
Definition: Grid.cc:946
virtual void set_in_selection(bool state)
Set the in_selection property.
Definition: Grid.cc:204
Map_iter map_end()
Definition: Grid.cc:700
virtual void set_send_p(bool state)
Definition: Grid.cc:180
stack< BaseType * > btp_stack
Definition: BaseType.h:233
std::vector< BaseType * >::const_iterator Map_citer
Definition: Grid.h:137
virtual int components(bool constrained=false)
Returns the number of components in the Grid object.
Definition: Grid.cc:745
Map_riter map_rbegin()
Returns an iterator referencing the first Map vector.
Definition: Grid.cc:707
virtual void set_array(Array *p_new_arr)
Definition: Grid.cc:577
virtual int element_count(bool leaves=false)
Count the members of constructor types.
Definition: Grid.cc:161
virtual bool projection_yields_grid()
Definition: Grid.cc:819
Map_iter map_begin()
Returns an iterator referencing the first Map vector.
Definition: Grid.cc:692
virtual BaseType * ptr_duplicate()
Definition: Grid.cc:122
Map_iter get_map_iter(int i)
Definition: Grid.cc:724
virtual void intern_data(ConstraintEvaluator &eval, DDS &dds)
Definition: Grid.cc:261
virtual void add_var(BaseType *bt, Part part)
Definition: Grid.cc:421
virtual void transfer_attributes(AttrTable *at_container)
Definition: Grid.cc:765
virtual void clear_constraint()
Definition: Grid.cc:863
virtual ~Grid()
Definition: Grid.cc:111
virtual void set_read_p(bool state)
Sets the value of the read_p property.
Definition: Grid.cc:192
Holds the Grid data type.
Definition: Grid.h:121
virtual void print_val(ostream &out, string space="", bool print_decl_p=true)
Prints the value of the variable.
Definition: Grid.cc:1028
virtual Array * add_map(Array *p_new_map, bool add_copy)
Definition: Grid.cc:621
Array * get_array()
Returns the Grid Array. This method returns the array using an Array*, so no cast is required...
Definition: Grid.cc:681
std::vector< BaseType * >::iterator Map_iter
Definition: Grid.h:138
virtual unsigned int val2buf(void *, bool)
Loads class data.
Definition: Constructor.h:99
std::vector< BaseType * >::reverse_iterator Map_riter
Definition: Grid.h:139
virtual bool is_dap2_only_type()
Definition: Grid.cc:155
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:880
Evaluate a constraint expression.
virtual bool deserialize(UnMarshaller &um, DDS *dds, bool reuse=false)
Receive data from the net.
Definition: Grid.cc:341
virtual unsigned int buf2val(void **)
Reads the class data.
Definition: Constructor.h:102
virtual BaseType * var(const string &n, bool exact=true, btp_stack *s=0)
Definition: Grid.cc:387
The basic data type for the DODS DAP types.
Definition: BaseType.h:199
abstract base class used to marshal/serialize dap data objects
Definition: Marshaller.h:53
void m_duplicate(const Grid &s)
Definition: Grid.cc:58
virtual bool check_semantics(string &msg, bool all=false)
Return true if this Grid is well formed.
Definition: Grid.cc:1064
BaseType * array_var()
Returns the Grid Array.
Definition: Grid.cc:672
virtual unsigned int width(bool constrained=false)
Definition: Grid.cc:235
A multidimensional array of identical data types.
Definition: Array.h:103
virtual void print_xml_writer(XMLWriter &xml, bool constrained=false)
Definition: Grid.cc:974
Grid(const string &n)
The Grid constructor.
Definition: Grid.cc:87