Vector.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 1995-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 // This is the interface definition file for the abstract class
00033 // Vector. Vector is the parent class for List and Array.
00034 
00035 #ifndef _vector_h
00036 #define _vector_h 1
00037 
00038 
00039 #ifdef WIN32
00040 #include <rpc.h>
00041 #include <winsock2.h>
00042 #else
00043 #include <rpc/types.h>
00044 #include <netinet/in.h>
00045 #include <rpc/xdr.h>
00046 #endif
00047 
00048 #ifndef _basetype_h
00049 #include "BaseType.h"
00050 #endif
00051 
00052 #ifndef _dds_h
00053 #include "DDS.h"
00054 #endif
00055 
00056 #ifndef constraint_evaluator_h
00057 #include "ConstraintEvaluator.h"
00058 #endif
00059 
00085 class Vector: public BaseType
00086 {
00087 private:
00088     int _length;  // number of elements in the vector
00089     BaseType *_var;  // base type of the Vector
00090 
00091     // _buf was a pointer to void; delete[] complained. 6/4/2001 jhrg
00092     char *_buf;   // array which holds cardinal data
00093     vector<string> d_str;       // special storage for strings. jhrg 2/11/05
00094     vector<BaseType *> _vec; // array for other data
00095 
00096 protected:
00097     // This function copies the private members of Vector.
00098     void _duplicate(const Vector &v);
00099 
00100 public:
00101     Vector(const string &n = "", BaseType *v = 0, const Type &t = dods_null_c);
00102     Vector(const Vector &rhs);
00103 
00104     virtual ~Vector();
00105 
00106     Vector &operator=(const Vector &rhs);
00107     virtual BaseType *ptr_duplicate() = 0;
00108 
00109     virtual int element_count(bool leaves);
00110 
00111     virtual void set_send_p(bool state);
00112 
00113     virtual void set_read_p(bool state);
00114 
00115     virtual unsigned int width();
00116 
00117     virtual int length() const;
00118 
00119     virtual void set_length(int l);
00120 
00121     virtual bool serialize(const string &dataset, ConstraintEvaluator &eval,
00122                            DDS &dds, XDR *sink, bool ce_eval = true);
00123     virtual bool deserialize(XDR *source, DDS *dds, bool reuse = false);
00124 
00125     virtual unsigned int val2buf(void *val, bool reuse = false);
00126 
00127     virtual unsigned int buf2val(void **val);
00128 
00129     void set_vec(unsigned int i, BaseType *val);
00130 
00131     void vec_resize(int l);
00132 
00133     virtual bool set_value(dods_byte *val, int sz);
00134     virtual bool set_value(dods_int16 *val, int sz);
00135     virtual bool set_value(dods_uint16 *val, int sz);
00136     virtual bool set_value(dods_int32 *val, int sz);
00137     virtual bool set_value(dods_uint32 *val, int sz);
00138     virtual bool set_value(dods_float32 *val, int sz);
00139     virtual bool set_value(dods_float64 *val, int sz);
00140     virtual bool set_value(string *val, int sz);
00141 
00142     virtual void value(dods_byte *b) const;
00143     virtual void value(dods_int16 *b) const;
00144     virtual void value(dods_uint16 *b) const;
00145     virtual void value(dods_int32 *b) const;
00146     virtual void value(dods_uint32 *b) const;
00147     virtual void value(dods_float32 *b) const;
00148     virtual void value(dods_float64 *b) const;
00149     virtual void value(vector<string> &b) const;
00150 
00151     virtual BaseType *var(const string &name = "", bool exact_match = true,
00152                           btp_stack *s = 0);
00153     virtual BaseType *var(const string &name, btp_stack &s);
00154     virtual BaseType *var(unsigned int i);
00155 
00156     virtual void add_var(BaseType *v, Part p = nil);
00157     virtual bool check_semantics(string &msg, bool all = false);
00158 
00159     virtual void dump(ostream &strm) const ;
00160 };
00161 
00162 #endif /* _vector_h */

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