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
00036
00037
00038
00039
00040
00041
00042 #ifndef _basetype_h
00043 #define _basetype_h 1
00044
00045
00046 #include <vector>
00047 #include <stack>
00048 #include <iostream>
00049 #include <string>
00050
00051 #ifndef _attrtable_h
00052 #include "AttrTable.h"
00053 #endif
00054
00055 #ifndef _internalerr_h
00056 #include "InternalErr.h"
00057 #endif
00058
00059 #ifndef __DODS_DATATYPES_
00060 #include "dods-datatypes.h"
00061 #endif
00062
00063 #ifndef A_DapObj_h
00064 #include "DapObj.h"
00065 #endif
00066
00067 #include "Marshaller.h"
00068 #include "UnMarshaller.h"
00069
00070 using namespace std;
00071
00072 namespace libdap
00073 {
00074
00075 class DDS;
00076 class ConstraintEvaluator;
00077
00096 enum Part {
00097 nil,
00098 array,
00099 maps
00100 };
00101
00129 enum Type {
00130 dods_null_c,
00131 dods_byte_c,
00132 dods_int16_c,
00133 dods_uint16_c,
00134 dods_int32_c,
00135 dods_uint32_c,
00136 dods_float32_c,
00137 dods_float64_c,
00138 dods_str_c,
00139 dods_url_c,
00140 dods_array_c,
00141 dods_structure_c,
00142 dods_sequence_c,
00143 dods_grid_c
00144 };
00145
00188 class BaseType : public DapObj
00189 {
00190 private:
00191 string _name;
00192 Type _type;
00193
00194 bool _read_p;
00195 bool _send_p;
00196 bool d_in_selection;
00197 bool _synthesized_p;
00198
00199
00200
00201
00202 BaseType *d_parent;
00203
00204
00205 AttrTable d_attr;
00206
00207 protected:
00208 void _duplicate(const BaseType &bt);
00209
00210 public:
00211 typedef stack<BaseType *> btp_stack;
00212
00213 BaseType(const string &n = "", const Type &t = dods_null_c);
00214
00215 BaseType(const BaseType ©_from);
00216 virtual ~BaseType();
00217
00218 virtual string toString();
00219
00220 virtual void dump(ostream &strm) const ;
00221
00222 BaseType &operator=(const BaseType &rhs);
00223
00230 virtual BaseType *ptr_duplicate() = 0;
00231
00232 string name() const;
00233 virtual void set_name(const string &n);
00234
00235 Type type() const;
00236 void set_type(const Type &t);
00237 string type_name() const;
00238
00239 virtual bool is_simple_type();
00240 virtual bool is_vector_type();
00241 virtual bool is_constructor_type();
00242
00243 virtual bool synthesized_p();
00244 virtual void set_synthesized_p(bool state);
00245
00246 virtual int element_count(bool leaves = false);
00247
00248 virtual bool read_p();
00249 virtual void set_read_p(bool state);
00250
00251 virtual bool send_p();
00252 virtual void set_send_p(bool state);
00253
00254 virtual AttrTable &get_attr_table();
00255 virtual void set_attr_table(const AttrTable &at);
00256
00257 virtual bool is_in_selection();
00258 virtual void set_in_selection(bool state);
00259
00260 virtual void set_parent(BaseType *parent);
00261 virtual BaseType *get_parent();
00262
00263
00264
00265
00266
00297 virtual BaseType *var(const string &name = "", bool exact_match = true,
00298 btp_stack *s = 0);
00299 virtual BaseType *var(const string &name, btp_stack &s);
00300
00301 virtual void add_var(BaseType *bt, Part part = nil);
00302
00303 virtual bool read(const string &dataset);
00304
00305 virtual bool check_semantics(string &msg, bool all = false);
00306
00307 virtual bool ops(BaseType *b, int op, const string &dataset);
00308
00309 virtual void print_decl(FILE *out, string space = " ",
00310 bool print_semi = true,
00311 bool constraint_info = false,
00312 bool constrained = false);
00313
00314 virtual void print_decl(ostream &out, string space = " ",
00315 bool print_semi = true,
00316 bool constraint_info = false,
00317 bool constrained = false);
00318
00319 virtual void print_xml(FILE *out, string space = " ",
00320 bool constrained = false);
00321
00322 virtual void print_xml(ostream &out, string space = " ",
00323 bool constrained = false);
00324
00327
00339 virtual unsigned int width() = 0;
00340
00361 virtual unsigned int buf2val(void **val) = 0;
00362
00392 virtual unsigned int val2buf(void *val, bool reuse = false) = 0;
00393
00407 virtual void intern_data(const string &dataset, ConstraintEvaluator &eval,
00408 DDS &dds);
00409
00438 virtual bool serialize(const string &dataset, ConstraintEvaluator &eval,
00439 DDS &dds, Marshaller &m, bool ce_eval = true) = 0;
00440
00465 virtual bool deserialize(UnMarshaller &um, DDS *dds, bool reuse = false) = 0;
00466
00481 virtual void print_val(FILE *out, string space = "",
00482 bool print_decl_p = true) = 0;
00483
00498 virtual void print_val(ostream &out, string space = "",
00499 bool print_decl_p = true) = 0;
00501 };
00502
00503 }
00504
00505 #endif // _basetype_h