libdap  Updated for version 3.17.0
Grid.h
00001 
00002 // -*- mode: c++; c-basic-offset:4 -*-
00003 
00004 // This file is part of libdap, A C++ implementation of the OPeNDAP Data
00005 // Access Protocol.
00006 
00007 // Copyright (c) 2002,2003 OPeNDAP, Inc.
00008 // Author: James Gallagher <jgallagher@opendap.org>
00009 //
00010 // This library is free software; you can redistribute it and/or
00011 // modify it under the terms of the GNU Lesser General Public
00012 // License as published by the Free Software Foundation; either
00013 // version 2.1 of the License, or (at your option) any later version.
00014 //
00015 // This library is distributed in the hope that it will be useful,
00016 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00017 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00018 // Lesser General Public License for more details.
00019 //
00020 // You should have received a copy of the GNU Lesser General Public
00021 // License along with this library; if not, write to the Free Software
00022 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
00023 //
00024 // You can contact OPeNDAP, Inc. at PO Box 112, Saunderstown, RI. 02874-0112.
00025 
00026 // (c) COPYRIGHT URI/MIT 1994-1999
00027 // Please read the full copyright statement in the file COPYRIGHT_URI.
00028 //
00029 // Authors:
00030 //      jhrg,jimg       James Gallagher <jgallagher@gso.uri.edu>
00031 
00032 // Interface to the Grid ctor class. Grids contain a single array (the `main'
00033 // array) of dimension N and N single dimension arrays (map arrays). For any
00034 // dimension n of the main array, the size of the nth map array must match
00035 // the size of the main array's nth dimension. Grids are used to map
00036 // non-integer scales to multidimensional point data.
00037 //
00038 // jhrg 9/15/94
00039 
00040 #ifndef _grid_h
00041 #define _grid_h 1
00042 
00043 #include <vector>
00044 
00045 #ifndef _basetype_h
00046 #include "BaseType.h"
00047 #endif
00048 
00049 #ifndef _array_h
00050 #include "Array.h"
00051 #endif
00052 
00053 #ifndef _constructor_h
00054 #include "Constructor.h"
00055 #endif
00056 
00057 #ifndef constraint_evaluator_h
00058 #include "ConstraintEvaluator.h"
00059 #endif
00060 
00061 namespace libdap
00062 {
00063 
00064 class D4Grup;
00065 class XMLWriter;
00066 
00122 class Grid: public Constructor
00123 {
00124 private:
00125     //BaseType *d_array_var;    // weak pointer to the
00126     bool d_is_array_set;
00127 
00128 protected: // subclasses need access [mjohnson 11 nov 2009]
00129     void m_duplicate(const Grid &s);
00130 
00131 public:
00132 
00133     Grid(const string &n);
00134     Grid(const string &n, const string &d);
00135     Grid(const Grid &rhs);
00136     virtual ~Grid();
00137 
00138     typedef std::vector<BaseType *>::const_iterator Map_citer ;
00139     typedef std::vector<BaseType *>::iterator Map_iter ;
00140     typedef std::vector<BaseType *>::reverse_iterator Map_riter ;
00141 
00142 
00143     Grid &operator=(const Grid &rhs);
00144     virtual BaseType *ptr_duplicate();
00145 
00146     virtual BaseType *transform_to_dap4(D4Group *root, Constructor *container);
00147 
00148     virtual bool is_dap2_only_type();
00149 
00150     virtual void add_var(BaseType *bt, Part part);
00151     virtual void add_var_nocopy(BaseType *bt, Part part);
00152 
00153     virtual void set_array(Array* p_new_arr);
00154     virtual Array* add_map(Array* p_new_map, bool add_copy);
00155     virtual Array* prepend_map(Array* p_new_map, bool add_copy);
00156 
00157     BaseType *array_var();
00158     Array *get_array();
00159 
00160     // virtual unsigned int width(bool constrained = false);
00161 
00162     virtual int components(bool constrained = false);
00163 
00164     virtual bool projection_yields_grid();
00165 
00166     virtual void clear_constraint();
00167 
00168     virtual void print_decl(ostream &out, string space = "    ",
00169                             bool print_semi = true,
00170                             bool constraint_info = false,
00171                             bool constrained = false);
00172 
00173     virtual void print_xml(ostream &out, string space = "    ",
00174                            bool constrained = false);
00175     virtual void print_xml_writer(XMLWriter &xml, bool constrained = false);
00176 
00177     virtual void print_val(ostream &out, string space = "",
00178                            bool print_decl_p = true);
00179 
00180     virtual void print_decl(FILE *out, string space = "    ",
00181                             bool print_semi = true,
00182                             bool constraint_info = false,
00183                             bool constrained = false);
00184     virtual void print_xml(FILE *out, string space = "    ",
00185                            bool constrained = false);
00186     virtual void print_val(FILE *out, string space = "",
00187                            bool print_decl_p = true);
00188 
00189     virtual void transfer_attributes(AttrTable *at_container);
00190 
00191     virtual bool check_semantics(string &msg, bool all = false);
00192 
00193     Map_iter map_begin() ;
00194     Map_iter map_end() ;
00195     Map_riter map_rbegin() ;
00196     Map_riter map_rend() ;
00197     Map_iter get_map_iter(int i);
00198 
00199     virtual void dump(ostream &strm) const ;
00200 };
00201 
00202 } // namespace libdap
00203 
00204 #endif // _grid_h
00205