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 #ifdef WIN32
00047 #include <rpc.h>
00048 #include <winsock2.h>
00049 #include <xdr.h>
00050 #define xdr_proc_t int *
00051 #else
00052 #include <rpc/types.h>
00053 #include <netinet/in.h>
00054 #include <rpc/xdr.h>
00055 #endif
00056
00057 #include <vector>
00058 #include <stack>
00059 #include <iostream>
00060 #include <string>
00061
00062 #ifndef _attrtable_h
00063 #include "AttrTable.h"
00064 #endif
00065
00066 #ifndef _internalerr_h
00067 #include "InternalErr.h"
00068 #endif
00069
00070 #ifndef __DODS_DATATYPES_
00071 #include "dods-datatypes.h"
00072 #endif
00073
00074 #ifndef A_DapObj_h
00075 #include "DapObj.h"
00076 #endif
00077
00078 using namespace std;
00079
00080 class BaseType;
00081 class DDS;
00082 class ConstraintEvaluator;
00083
00084 typedef stack<BaseType *> btp_stack;
00085
00104 enum Part {
00105 nil,
00106 array,
00107 maps
00108 };
00109
00137 enum Type {
00138 dods_null_c,
00139 dods_byte_c,
00140 dods_int16_c,
00141 dods_uint16_c,
00142 dods_int32_c,
00143 dods_uint32_c,
00144 dods_float32_c,
00145 dods_float64_c,
00146 dods_str_c,
00147 dods_url_c,
00148 dods_array_c,
00149 dods_structure_c,
00150 dods_sequence_c,
00151 dods_grid_c
00152 };
00153
00196 class BaseType : public DapObj
00197 {
00198 private:
00199 string _name;
00200 Type _type;
00201
00202
00203
00204
00205 xdrproc_t _xdr_coder;
00206
00207 bool _read_p;
00208 bool _send_p;
00209 bool d_in_selection;
00210 bool _synthesized_p;
00211
00212
00213
00214
00215 BaseType *d_parent;
00216
00217
00218 AttrTable d_attr;
00219
00220 protected:
00221 void _duplicate(const BaseType &bt);
00222
00223 public:
00224 BaseType(const string &n = "", const Type &t = dods_null_c,
00225 xdrproc_t xdr = NULL);
00226
00227 BaseType(const BaseType ©_from);
00228 virtual ~BaseType();
00229
00230 virtual string toString();
00231
00232 virtual void dump(ostream &strm) const ;
00233
00234 BaseType &operator=(const BaseType &rhs);
00235
00242 virtual BaseType *ptr_duplicate() = 0;
00243
00244 string name() const;
00245 virtual void set_name(const string &n);
00246
00247 Type type() const;
00248 void set_type(const Type &t);
00249 string type_name() const;
00250
00251 virtual bool is_simple_type();
00252 virtual bool is_vector_type();
00253 virtual bool is_constructor_type();
00254
00255 virtual bool synthesized_p();
00256 virtual void set_synthesized_p(bool state);
00257
00258 virtual int element_count(bool leaves = false);
00259
00260 virtual bool read_p();
00261 virtual void set_read_p(bool state);
00262
00263 virtual bool send_p();
00264 virtual void set_send_p(bool state);
00265
00266 virtual AttrTable &get_attr_table();
00267 virtual void set_attr_table(const AttrTable &at);
00268
00269 virtual bool is_in_selection();
00270 virtual void set_in_selection(bool state);
00271
00272 xdrproc_t xdr_coder();
00273
00274 virtual void set_parent(BaseType *parent);
00275 virtual BaseType *get_parent();
00276
00277
00278
00279
00280
00311 virtual BaseType *var(const string &name = "", bool exact_match = true,
00312 btp_stack *s = 0);
00313 virtual BaseType *var(const string &name, btp_stack &s);
00314
00315 virtual void add_var(BaseType *bt, Part part = nil);
00316
00317 virtual bool read(const string &dataset);
00318
00319 virtual bool check_semantics(string &msg, bool all = false);
00320
00321 virtual bool ops(BaseType *b, int op, const string &dataset);
00322
00323 virtual void print_decl(FILE *out, string space = " ",
00324 bool print_semi = true,
00325 bool constraint_info = false,
00326 bool constrained = false);
00327
00328 virtual void print_xml(FILE *out, string space = " ",
00329 bool constrained = false);
00330
00333
00345 virtual unsigned int width() = 0;
00346
00365 virtual unsigned int buf2val(void **val) = 0;
00366
00394 virtual unsigned int val2buf(void *val, bool reuse = false) = 0;
00395
00426 virtual bool serialize(const string &dataset, ConstraintEvaluator &eval,
00427 DDS &dds, XDR *sink, bool ce_eval = true) = 0;
00428
00455 virtual bool deserialize(XDR *source, DDS *dds, bool reuse = false) = 0;
00456
00471 virtual void print_val(FILE *out, string space = "",
00472 bool print_decl_p = true) = 0;
00474 };
00475
00476 #endif // _basetype_h