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 
00041 #include <string>
00042 
00043 #include <vector>
00044 
00045 #ifndef _dods_limits_h
00046 #include "dods-limits.h"
00047 #endif
00048 
00049 #ifndef _vector_h
00050 #include "Vector.h"
00051 #endif
00052 
00053 const int DODS_MAX_ARRAY = DODS_INT_MAX;
00054 
00098 class Array: public Vector
00099 {
00100 public:
00111     struct dimension
00112     {
00113         int size;  
00114         string name;    
00115         int start;  
00116         int stop;  
00117         int stride;  
00118         int c_size;  
00119         bool selected; 
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 
00127     friend class ArrayTest;
00128 
00129 protected:
00130     void _duplicate(const Array &a);
00131     void print_xml_core(FILE *out, string space, bool constrained, string tag);
00132 
00133 public:
00139     typedef std::vector<dimension>::const_iterator Dim_citer ;
00146     typedef std::vector<dimension>::iterator Dim_iter ;
00147 
00148     Array(const string &n = "", BaseType *v = 0);
00149     Array(const Array &rhs);
00150     virtual ~Array();
00151 
00152     Array &operator=(const Array &rhs);
00153     virtual BaseType *ptr_duplicate();
00154 
00155     void add_var(BaseType *v, Part p = nil);
00156 
00157     void update_length(int size);
00158 
00159     void append_dim(int size, string name = "");
00160 
00161     void add_constraint(Dim_iter i, int start, int stride, int stop);
00162     void reset_constraint();
00163 
00164     void clear_constraint();
00165 
00166     Dim_iter dim_begin() ;
00167     Dim_iter dim_end() ;
00168 
00169     int dimension_size(Dim_iter i, bool constrained = false);
00170     int dimension_start(Dim_iter i, bool constrained = false);
00171     int dimension_stop(Dim_iter i, bool constrained = false);
00172     int dimension_stride(Dim_iter i, bool constrained = false);
00173     string dimension_name(Dim_iter i);
00174 
00175     unsigned int dimensions(bool constrained = false);
00176 
00177     virtual void print_decl(FILE *out, string space = "    ",
00178                             bool print_semi = true,
00179                             bool constraint_info = false,
00180                             bool constrained = false);
00181 
00182     virtual void print_xml(FILE *out, string space = "    ",
00183                            bool constrained = false);
00184 
00185     virtual void print_as_map_xml(FILE *out, string space = "    ",
00186                                   bool constrained = false);
00187 
00188     virtual void print_val(FILE *out, string space = "",
00189                            bool print_decl_p = true);
00190 
00191     virtual bool check_semantics(string &msg, bool all = false);
00192 
00193     virtual void dump(ostream &strm) const ;
00194 };
00195 
00196 #endif // _array_h

Generated on Wed Jun 27 12:56:38 2007 for libdap++ by  doxygen 1.4.7