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 #ifndef _dds_h
00038 #define _dds_h 1
00039
00040 #include <cstdio>
00041 #include <iostream>
00042 #include <string>
00043 #include <vector>
00044
00045
00046
00047 #ifndef _basetype_h
00048 #include "BaseType.h"
00049 #endif
00050
00051 #ifndef _constructor_h
00052 #include "Constructor.h"
00053 #endif
00054
00055 #ifndef base_type_factory_h
00056 #include "BaseTypeFactory.h"
00057 #endif
00058
00059 #ifndef _das_h
00060 #include "DAS.h"
00061 #endif
00062
00063 #ifndef A_DapObj_h
00064 #include "DapObj.h"
00065 #endif
00066
00067 using std::cout;
00068
00069 namespace libdap
00070 {
00071
00174 class DDS : public DapObj
00175 {
00176 private:
00177 BaseTypeFactory *d_factory;
00178
00179 string name;
00180
00181 string _filename;
00182
00183 int d_protocol_major;
00184 int d_protocol_minor;
00185
00186 AttrTable d_attr;
00187
00188 vector<BaseType *> vars;
00189 #if 0
00190 bool is_global_attr(string name);
00191 void add_global_attribute(AttrTable::entry *entry);
00192 #endif
00193 BaseType *find_hdf4_dimension_attribute_home(AttrTable::entry *source);
00194
00195 int d_timeout;
00196
00197
00198 friend class DDSTest;
00199
00200 protected:
00201 void duplicate(const DDS &dds);
00202 BaseType *leaf_match(const string &name, BaseType::btp_stack *s = 0);
00203 BaseType *exact_match(const string &name, BaseType::btp_stack *s = 0);
00204 #if 0
00205 void transfer_attr(DAS *das, const AttrTable::entry *ep, BaseType *btp,
00206 const string &suffix = "");
00207 void transfer_attr_table(DAS *das, AttrTable *at, BaseType *btp,
00208 const string &suffix = "");
00209 void transfer_attr_table(DAS *das, AttrTable *at, Constructor *c,
00210 const string &suffix = "");
00211 #endif
00212 virtual AttrTable *find_matching_container(AttrTable::entry *source,
00213 BaseType **dest_variable);
00214
00215 public:
00216 typedef std::vector<BaseType *>::const_iterator Vars_citer ;
00217 typedef std::vector<BaseType *>::iterator Vars_iter ;
00218 typedef std::vector<BaseType *>::reverse_iterator Vars_riter ;
00219
00220 DDS(BaseTypeFactory *factory, const string &n = "");
00221 DDS(const DDS &dds);
00222
00223 virtual ~DDS();
00224
00225 DDS & operator=(const DDS &rhs);
00226
00227 virtual void transfer_attributes(DAS *das);
00228
00229 string get_dataset_name() const;
00230 void set_dataset_name(const string &n);
00231
00236 BaseTypeFactory *get_factory() const
00237 {
00238 return d_factory;
00239 }
00240
00246 BaseTypeFactory *set_factory(BaseTypeFactory *factory)
00247 {
00248 BaseTypeFactory *t = d_factory;
00249 d_factory = factory;
00250 return t;
00251 }
00252
00253 virtual AttrTable &get_attr_table();
00254
00255 string filename();
00256 void filename(const string &fn);
00257
00258 void add_var(BaseType *bt);
00259
00261 void del_var(const string &n);
00262
00263 BaseType *var(const string &n, BaseType::btp_stack &s);
00264 BaseType *var(const string &n, BaseType::btp_stack *s = 0);
00265 int num_var();
00266
00268 Vars_iter var_begin();
00270 Vars_riter var_rbegin();
00272 Vars_iter var_end();
00274 Vars_riter var_rend();
00276 Vars_iter get_vars_iter(int i);
00278 BaseType *get_var_index(int i);
00280 void del_var(Vars_iter i);
00282 void del_var(Vars_iter i1, Vars_iter i2);
00283
00284 void timeout_on();
00285 void timeout_off();
00286 void set_timeout(int t);
00287 int get_timeout();
00288
00289 void parse(string fname);
00290 void parse(int fd);
00291 void parse(FILE *in = stdin);
00292
00293 void print(FILE *out);
00294 void print(ostream &out);
00295 void print_constrained(FILE *out);
00296 void print_constrained(ostream &out);
00297
00298 void print_xml(FILE *out, bool constrained, const string &blob);
00299 void print_xml(ostream &out, bool constrained, const string &blob);
00300
00301 void mark_all(bool state);
00302 bool mark(const string &name, bool state);
00303 bool check_semantics(bool all = false);
00304
00305 void tag_nested_sequences();
00306
00307 virtual void dump(ostream &strm) const ;
00308 };
00309
00310 }
00311
00312 #endif // _dds_h