00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035 #ifndef _vector_h
00036 #define _vector_h 1
00037
00038 #ifndef _basetype_h
00039 #include "BaseType.h"
00040 #endif
00041
00042 #ifndef _dds_h
00043 #include "DDS.h"
00044 #endif
00045
00046 #ifndef constraint_evaluator_h
00047 #include "ConstraintEvaluator.h"
00048 #endif
00049
00050 namespace libdap
00051 {
00052
00078 class Vector: public BaseType
00079 {
00080 private:
00081 int _length;
00082 BaseType *_var;
00083
00084
00085 char *_buf;
00086 vector<string> d_str;
00087 vector<BaseType *> _vec;
00088
00089
00090
00091
00092 unsigned int _capacity;
00093
00094 protected:
00095
00096 void _duplicate(const Vector &v);
00097
00098 bool is_cardinal_type() const;
00099 unsigned int create_cardinal_data_buffer_for_type(unsigned int numEltsOfType);
00100 void delete_cardinal_data_buffer();
00101
00102 template <class CardType> void set_cardinal_values_internal(const CardType* fromArray, int numElts);
00103
00104 public:
00105 Vector(const string &n, BaseType *v, const Type &t);
00106 Vector(const string &n, const string &d, BaseType *v, const Type &t);
00107 Vector(const Vector &rhs);
00108
00109 virtual ~Vector();
00110
00111 Vector &operator=(const Vector &rhs);
00112 virtual BaseType *ptr_duplicate() = 0;
00113
00114 virtual void set_name(const std::string& name);
00115
00116 virtual int element_count(bool leaves);
00117
00118 virtual void set_send_p(bool state);
00119
00120 virtual void set_read_p(bool state);
00121
00122 virtual unsigned int width();
00123
00124 virtual int length() const;
00125
00126 virtual void set_length(int l);
00127
00128 virtual void intern_data(ConstraintEvaluator &eval, DDS &dds);
00129 virtual bool serialize(ConstraintEvaluator &eval, DDS &dds,
00130 Marshaller &m, bool ce_eval = true);
00131 virtual bool deserialize(UnMarshaller &um, DDS *dds, bool reuse = false);
00132
00133 virtual unsigned int val2buf(void *val, bool reuse = false);
00134 virtual unsigned int buf2val(void **val);
00135
00136 void set_vec(unsigned int i, BaseType *val);
00137
00138 void vec_resize(int l);
00139
00140 void clear_local_data();
00141
00142 virtual unsigned int get_value_capacity() const;
00143 virtual void reserve_value_capacity(unsigned int numElements);
00144 virtual void reserve_value_capacity();
00145
00146 virtual unsigned int set_value_slice_from_row_major_vector
00147 (const Vector& rowMajorData, unsigned int startElement);
00148
00149 virtual bool set_value(dods_byte *val, int sz);
00150 virtual bool set_value(vector<dods_byte> &val, int sz);
00151 virtual bool set_value(dods_int16 *val, int sz);
00152 virtual bool set_value(vector<dods_int16> &val, int sz);
00153 virtual bool set_value(dods_uint16 *val, int sz);
00154 virtual bool set_value(vector<dods_uint16> &val, int sz);
00155 virtual bool set_value(dods_int32 *val, int sz);
00156 virtual bool set_value(vector<dods_int32> &val, int sz);
00157 virtual bool set_value(dods_uint32 *val, int sz);
00158 virtual bool set_value(vector<dods_uint32> &val, int sz);
00159 virtual bool set_value(dods_float32 *val, int sz);
00160 virtual bool set_value(vector<dods_float32> &val, int sz);
00161 virtual bool set_value(dods_float64 *val, int sz);
00162 virtual bool set_value(vector<dods_float64> &val, int sz);
00163 virtual bool set_value(string *val, int sz);
00164 virtual bool set_value(vector<string> &val, int sz);
00165
00166 virtual void value(dods_byte *b) const;
00167 virtual void value(dods_int16 *b) const;
00168 virtual void value(dods_uint16 *b) const;
00169 virtual void value(dods_int32 *b) const;
00170 virtual void value(dods_uint32 *b) const;
00171 virtual void value(dods_float32 *b) const;
00172 virtual void value(dods_float64 *b) const;
00173 virtual void value(vector<string> &b) const;
00174
00175 virtual void *value();
00176
00177 virtual BaseType *var(const string &name = "", bool exact_match = true,
00178 btp_stack *s = 0);
00179 virtual BaseType *var(const string &name, btp_stack &s);
00180 virtual BaseType *var(unsigned int i);
00181
00182 virtual void add_var(BaseType *v, Part p = nil);
00183 virtual bool check_semantics(string &msg, bool all = false);
00184
00185 virtual void dump(ostream &strm) const ;
00186 };
00187
00188 }
00189
00190 #endif