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 #ifndef _basetype_h
00046 #include "BaseType.h"
00047 #endif
00048
00049 #ifndef _constructor_h
00050 #include "Constructor.h"
00051 #endif
00052
00053 #ifndef base_type_factory_h
00054 #include "BaseTypeFactory.h"
00055 #endif
00056
00057 #ifndef _das_h
00058 #include "DAS.h"
00059 #endif
00060
00061 #ifndef A_DapObj_h
00062 #include "DapObj.h"
00063 #endif
00064
00065 using std::cout;
00066
00067 namespace libdap
00068 {
00069
00172 class DDS : public DapObj
00173 {
00174 private:
00175 BaseTypeFactory *d_factory;
00176
00177 string name;
00178 string _filename;
00179 string _container_name;
00180 Structure *d_container;
00181
00182
00183
00184
00185
00186
00187 int d_dap_major;
00188 int d_dap_minor;
00189
00190
00191
00192 int d_client_dap_major;
00193 int d_client_dap_minor;
00194
00195 string d_request_xml_base;
00196
00197 AttrTable d_attr;
00198
00199 vector<BaseType *> vars;
00200 #if 0
00201 bool is_global_attr(string name);
00202 void add_global_attribute(AttrTable::entry *entry);
00203 #endif
00204 BaseType *find_hdf4_dimension_attribute_home(AttrTable::entry *source);
00205
00206 int d_timeout;
00207
00208
00209 friend class DDSTest;
00210
00211 protected:
00212 void duplicate(const DDS &dds);
00213 BaseType *leaf_match(const string &name, BaseType::btp_stack *s = 0);
00214 BaseType *exact_match(const string &name, BaseType::btp_stack *s = 0);
00215 #if 0
00216 void transfer_attr(DAS *das, const AttrTable::entry *ep, BaseType *btp,
00217 const string &suffix = "");
00218 void transfer_attr_table(DAS *das, AttrTable *at, BaseType *btp,
00219 const string &suffix = "");
00220 void transfer_attr_table(DAS *das, AttrTable *at, Constructor *c,
00221 const string &suffix = "");
00222 #endif
00223 virtual AttrTable *find_matching_container(AttrTable::entry *source,
00224 BaseType **dest_variable);
00225
00226 public:
00227 typedef std::vector<BaseType *>::const_iterator Vars_citer ;
00228 typedef std::vector<BaseType *>::iterator Vars_iter ;
00229 typedef std::vector<BaseType *>::reverse_iterator Vars_riter ;
00230
00231 DDS(BaseTypeFactory *factory, const string &n = "");
00232 DDS(const DDS &dds);
00233
00234 virtual ~DDS();
00235
00236 DDS & operator=(const DDS &rhs);
00237
00238 virtual void transfer_attributes(DAS *das);
00239
00240 string get_dataset_name() const;
00241 void set_dataset_name(const string &n);
00242
00247 BaseTypeFactory *get_factory() const
00248 {
00249 return d_factory;
00250 }
00251
00258 BaseTypeFactory *set_factory(BaseTypeFactory *factory)
00259 {
00260 BaseTypeFactory *t = d_factory;
00261 d_factory = factory;
00262 return t;
00263 }
00264
00265 virtual AttrTable &get_attr_table();
00266
00267 string filename();
00268 void filename(const string &fn);
00269
00271 int get_dap_major() const { return d_dap_major; }
00273 int get_dap_minor() const { return d_dap_minor; }
00274
00276 void set_dap_major(int p) { d_dap_major = p; }
00278 void set_dap_minor(int p) { d_dap_minor = p; }
00279
00280 void set_dap_version(const string &version_string);
00281
00283 int get_client_dap_major() const { return d_client_dap_major; }
00285 int get_client_dap_minor() const { return d_client_dap_minor; }
00286
00288 void set_client_dap_major(int p) { d_client_dap_major = p; }
00290 void set_client_dap_minor(int p) { d_client_dap_minor = p; }
00291
00292 void set_client_dap_version(const string &version_string);
00293
00295 string get_request_xml_base() const { return d_request_xml_base; }
00296
00298 void set_request_xml_base(const string &xb) { d_request_xml_base = xb; }
00299
00300 string container_name() ;
00301 void container_name( const string &cn ) ;
00302 Structure *container() ;
00303
00304 void add_var(BaseType *bt);
00305
00307 void del_var(const string &n);
00308
00309 BaseType *var(const string &n, BaseType::btp_stack &s);
00310 BaseType *var(const string &n, BaseType::btp_stack *s = 0);
00311 int num_var();
00312
00314 Vars_iter var_begin();
00316 Vars_riter var_rbegin();
00318 Vars_iter var_end();
00320 Vars_riter var_rend();
00322 Vars_iter get_vars_iter(int i);
00324 BaseType *get_var_index(int i);
00326 void del_var(Vars_iter i);
00328 void del_var(Vars_iter i1, Vars_iter i2);
00329
00330 void timeout_on();
00331 void timeout_off();
00332 void set_timeout(int t);
00333 int get_timeout();
00334
00335 void parse(string fname);
00336 void parse(int fd);
00337 void parse(FILE *in = stdin);
00338
00339 void print(FILE *out);
00340
00341 void print(ostream &out);
00342
00343 void print_constrained(FILE *out);
00344
00345 void print_constrained(ostream &out);
00346
00347 void print_xml(FILE *out, bool constrained, const string &blob);
00348
00349 void print_xml(ostream &out, bool constrained, const string &blob);
00350
00351 void mark_all(bool state);
00352 bool mark(const string &name, bool state);
00353 bool check_semantics(bool all = false);
00354
00355 void tag_nested_sequences();
00356
00357 virtual void dump(ostream &strm) const ;
00358 };
00359
00360 }
00361
00362 #endif // _dds_h