libdap++ Updated for version 3.8.2
|
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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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 // Class for array variables. The dimensions of the array are stored in the 00033 // list SHAPE. 00034 // 00035 // jhrg 9/6/94 00036 00037 #ifndef _array_h 00038 #define _array_h 1 00039 00040 #include <string> 00041 #include <vector> 00042 00043 #ifndef _dods_limits_h 00044 #include "dods-limits.h" 00045 #endif 00046 00047 #ifndef _vector_h 00048 #include "Vector.h" 00049 #endif 00050 00051 namespace libdap 00052 { 00053 00054 const int DODS_MAX_ARRAY = DODS_INT_MAX; 00055 00099 class Array: public Vector 00100 { 00101 public: 00112 struct dimension 00113 { 00114 int size; 00115 string name; 00116 int start; 00117 int stop; 00118 int stride; 00119 int c_size; 00120 }; 00121 00122 private: 00123 std::vector<dimension> _shape; // list of dimensions (i.e., the shape) 00124 00125 friend class ArrayTest; 00126 00127 protected: 00128 void _duplicate(const Array &a); 00129 00130 //#if FILE_METHODS 00131 unsigned int print_array(FILE *out, unsigned int index, 00132 unsigned int dims, unsigned int shape[]); 00133 //#endif 00134 unsigned int print_array(ostream &out, unsigned int index, 00135 unsigned int dims, unsigned int shape[]); 00136 00137 public: 00143 typedef std::vector<dimension>::const_iterator Dim_citer ; 00150 typedef std::vector<dimension>::iterator Dim_iter ; 00151 00152 Array(const string &n, BaseType *v); 00153 Array(const string &n, const string &d, BaseType *v); 00154 Array(const Array &rhs); 00155 virtual ~Array(); 00156 00157 Array &operator=(const Array &rhs); 00158 virtual BaseType *ptr_duplicate(); 00159 00160 void add_var(BaseType *v, Part p = nil); 00161 00162 void update_length(int size); 00163 00164 void append_dim(int size, string name = ""); 00165 00166 void add_constraint(Dim_iter i, int start, int stride, int stop); 00167 void reset_constraint(); 00168 00169 void clear_constraint(); 00170 00171 Dim_iter dim_begin() ; 00172 Dim_iter dim_end() ; 00173 00174 int dimension_size(Dim_iter i, bool constrained = false); 00175 int dimension_start(Dim_iter i, bool constrained = false); 00176 int dimension_stop(Dim_iter i, bool constrained = false); 00177 int dimension_stride(Dim_iter i, bool constrained = false); 00178 string dimension_name(Dim_iter i); 00179 00180 unsigned int dimensions(bool constrained = false); 00181 00182 virtual void print_decl(ostream &out, string space = " ", 00183 bool print_semi = true, 00184 bool constraint_info = false, 00185 bool constrained = false); 00186 00187 virtual void print_xml(ostream &out, string space = " ", 00188 bool constrained = false); 00189 00190 //#if FILE_METHODS 00191 virtual void print_xml_core(FILE *out, string space, bool constrained, string tag); 00192 //#endif 00193 virtual void print_xml_core(ostream &out, string space, bool constrained, string tag); 00194 00195 // not used (?) 00196 virtual void print_as_map_xml(ostream &out, string space = " ", 00197 bool constrained = false); 00198 00199 virtual void print_val(ostream &out, string space = "", 00200 bool print_decl_p = true); 00201 00202 //#if FILE_METHODS 00203 virtual void print_xml(FILE *out, string space = " ", 00204 bool constrained = false); 00205 virtual void print_as_map_xml(FILE *out, string space = " ", 00206 bool constrained = false); 00207 virtual void print_val(FILE *out, string space = "", 00208 bool print_decl_p = true); 00209 virtual void print_decl(FILE *out, string space = " ", 00210 bool print_semi = true, 00211 bool constraint_info = false, 00212 bool constrained = false); 00213 //#endif 00214 00215 virtual bool check_semantics(string &msg, bool all = false); 00216 00217 virtual void dump(ostream &strm) const ; 00218 }; 00219 00220 } // namespace libdap 00221 00222 #endif // _array_h