libdap Updated for version 3.21.1
libdap4 is an implementation of OPeNDAP's DAP protocol.
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#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
61namespace libdap {
62
63class D4Grup;
64class XMLWriter;
65
120
121class Grid : public Constructor {
122private:
123 // BaseType *d_array_var; // weak pointer to the
124 bool d_is_array_set;
125
126protected: // subclasses need access [mjohnson 11 nov 2009]
127 void m_duplicate(const Grid &s);
128
129public:
130 Grid(const string &n);
131 Grid(const string &n, const string &d);
132 Grid(const Grid &rhs);
133 virtual ~Grid();
134
135 typedef std::vector<BaseType *>::const_iterator Map_citer;
136 typedef std::vector<BaseType *>::iterator Map_iter;
137 typedef std::vector<BaseType *>::reverse_iterator Map_riter;
138
139 Grid &operator=(const Grid &rhs);
140 virtual BaseType *ptr_duplicate();
141
142 virtual void transform_to_dap4(D4Group *root, Constructor *container);
143
144 virtual bool is_dap2_only_type();
145
146 virtual void add_var(BaseType *bt, Part part);
147 virtual void add_var_nocopy(BaseType *bt, Part part);
148
149 virtual void set_array(Array *p_new_arr);
150 virtual Array *add_map(Array *p_new_map, bool add_copy);
151 virtual Array *prepend_map(Array *p_new_map, bool add_copy);
152
154 Array *get_array();
155
156 // virtual unsigned int width(bool constrained = false);
157
158 virtual int components(bool constrained = false);
159
160 virtual bool projection_yields_grid();
161
162 virtual void clear_constraint();
163
164 virtual void print_decl(ostream &out, string space = " ", bool print_semi = true, bool constraint_info = false,
165 bool constrained = false);
166
167 virtual void print_xml(ostream &out, string space = " ", bool constrained = false);
168 virtual void print_xml_writer(XMLWriter &xml, bool constrained = false);
169
170 virtual void print_val(ostream &out, string space = "", bool print_decl_p = true);
171
172 virtual void print_decl(FILE *out, string space = " ", bool print_semi = true, bool constraint_info = false,
173 bool constrained = false);
174 virtual void print_xml(FILE *out, string space = " ", bool constrained = false);
175 virtual void print_val(FILE *out, string space = "", bool print_decl_p = true);
176
177 virtual void transfer_attributes(AttrTable *at_container);
178
179 virtual bool check_semantics(string &msg, bool all = false);
180
185 Map_iter get_map_iter(int i);
186
187 virtual void dump(ostream &strm) const;
188};
189
190} // namespace libdap
191
192#endif // _grid_h
A multidimensional array of identical data types.
Definition Array.h:121
Contains the attributes for a dataset.
Definition AttrTable.h:150
The basic data type for the DODS DAP types.
Definition BaseType.h:118
Constructor(const string &name, const Type &type, bool is_dap4=false)
Definition Constructor.h:52
virtual BaseType * ptr_duplicate()
Definition Grid.cc:96
std::vector< BaseType * >::const_iterator Map_citer
Definition Grid.h:135
BaseType * array_var()
Returns the Grid Array.
Definition Grid.cc:440
virtual void transform_to_dap4(D4Group *root, Constructor *container)
DAP2 to DAP4 transform.
Definition Grid.cc:109
virtual void print_xml(ostream &out, string space=" ", bool constrained=false)
Definition Grid.cc:701
Map_iter map_begin()
Returns an iterator referencing the first Map vector.
Definition Grid.cc:448
Map_iter get_map_iter(int i)
Definition Grid.cc:473
virtual void set_array(Array *p_new_arr)
Definition Grid.cc:344
virtual void clear_constraint()
Definition Grid.cc:633
virtual void print_val(ostream &out, string space="", bool print_decl_p=true)
Prints the value of the variable.
Definition Grid.cc:769
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:645
virtual Array * prepend_map(Array *p_new_map, bool add_copy)
Definition Grid.cc:426
std::vector< BaseType * >::reverse_iterator Map_riter
Definition Grid.h:137
virtual ~Grid()
Definition Grid.cc:92
Grid(const string &n)
The Grid constructor.
Definition Grid.cc:74
void m_duplicate(const Grid &s)
Definition Grid.cc:63
std::vector< BaseType * >::iterator Map_iter
Definition Grid.h:136
Array * get_array()
Returns the Grid Array. This method returns the array using an Array*, so no cast is required.
Definition Grid.cc:445
virtual void transfer_attributes(AttrTable *at_container)
Definition Grid.cc:513
virtual bool projection_yields_grid()
Definition Grid.cc:592
Map_iter map_end()
Definition Grid.cc:458
Map_riter map_rend()
Definition Grid.cc:468
virtual void dump(ostream &strm) const
dumps information about this object
Definition Grid.cc:904
virtual Array * add_map(Array *p_new_map, bool add_copy)
Definition Grid.cc:399
virtual int components(bool constrained=false)
Returns the number of components in the Grid object.
Definition Grid.cc:490
virtual void print_xml_writer(XMLWriter &xml, bool constrained=false)
Definition Grid.cc:707
virtual bool check_semantics(string &msg, bool all=false)
Return true if this Grid is well formed.
Definition Grid.cc:806
virtual void add_var(BaseType *bt, Part part)
Definition Grid.cc:216
Grid & operator=(const Grid &rhs)
Definition Grid.cc:98
virtual void add_var_nocopy(BaseType *bt, Part part)
Definition Grid.cc:283
Map_riter map_rbegin()
Returns an iterator referencing the first Map vector.
Definition Grid.cc:461
virtual bool is_dap2_only_type()
Definition Grid.cc:202
top level DAP object to house generic methods
Definition AISConnect.cc:30
Part
Names the parts of multi-section constructor data types.
Definition Type.h:48