Array.h

Go to the documentation of this file.
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 const int DODS_MAX_ARRAY = DODS_INT_MAX;
00052 
00096 class Array: public Vector
00097 {
00098 public:
00109     struct dimension
00110     {
00111         int size;  
00112         string name;    
00113         int start;  
00114         int stop;  
00115         int stride;  
00116         int c_size;  
00117 #if array_selected
00118         bool selected; 
00119 #endif
00120     };
00121 
00122 private:
00123     std::vector<dimension> _shape; // list of dimensions (i.e., the shape)
00124     unsigned int print_array(FILE *out, unsigned int index,
00125                              unsigned int dims, unsigned int shape[]);
00126     unsigned int print_array(ostream &out, unsigned int index,
00127                              unsigned int dims, unsigned int shape[]);
00128 
00129     friend class ArrayTest;
00130 
00131 protected:
00132     void _duplicate(const Array &a);
00133     void print_xml_core(FILE *out, string space, bool constrained, string tag);
00134     void print_xml_core(ostream &out, string space, bool constrained, string tag);
00135 
00136 public:
00142     typedef std::vector<dimension>::const_iterator Dim_citer ;
00149     typedef std::vector<dimension>::iterator Dim_iter ;
00150 
00151     Array(const string &n = "", BaseType *v = 0);
00152     Array(const Array &rhs);
00153     virtual ~Array();
00154 
00155     Array &operator=(const Array &rhs);
00156     virtual BaseType *ptr_duplicate();
00157 
00158     void add_var(BaseType *v, Part p = nil);
00159 
00160     void update_length(int size);
00161 
00162     void append_dim(int size, string name = "");
00163 
00164     void add_constraint(Dim_iter i, int start, int stride, int stop);
00165     void reset_constraint();
00166 
00167     void clear_constraint();
00168 
00169     Dim_iter dim_begin() ;
00170     Dim_iter dim_end() ;
00171 
00172     int dimension_size(Dim_iter i, bool constrained = false);
00173     int dimension_start(Dim_iter i, bool constrained = false);
00174     int dimension_stop(Dim_iter i, bool constrained = false);
00175     int dimension_stride(Dim_iter i, bool constrained = false);
00176     string dimension_name(Dim_iter i);
00177 
00178     unsigned int dimensions(bool constrained = false);
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_decl(ostream &out, string space = "    ",
00185                             bool print_semi = true,
00186                             bool constraint_info = false,
00187                             bool constrained = false);
00188 
00189     virtual void print_xml(FILE *out, string space = "    ",
00190                            bool constrained = false);
00191     virtual void print_xml(ostream &out, string space = "    ",
00192                            bool constrained = false);
00193 
00194     virtual void print_as_map_xml(FILE *out, string space = "    ",
00195                                   bool constrained = false);
00196     virtual void print_as_map_xml(ostream &out, string space = "    ",
00197                                   bool constrained = false);
00198 
00199     virtual void print_val(FILE *out, string space = "",
00200                            bool print_decl_p = true);
00201     virtual void print_val(ostream &out, string space = "",
00202                            bool print_decl_p = true);
00203 
00204     virtual bool check_semantics(string &msg, bool all = false);
00205 
00206     virtual void dump(ostream &strm) const ;
00207 };
00208 
00209 #endif // _array_h

Generated on Wed Jan 2 04:13:16 2008 for libdap++ by  doxygen 1.5.4