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 #define FILE_METHODS 1
00068
00069 namespace libdap
00070 {
00071
00174 class DDS : public DapObj
00175 {
00176 private:
00177 BaseTypeFactory *d_factory;
00178
00179 string name;
00180 string d_filename;
00181 string d_container_name;
00182 Structure *d_container;
00183
00184
00185 int d_dap_major;
00186 int d_dap_minor;
00187
00188 string d_request_xml_base;
00189
00190 AttrTable d_attr;
00191
00192 vector<BaseType *> vars;
00193
00194 BaseType *find_hdf4_dimension_attribute_home(AttrTable::entry *source);
00195
00196 int d_timeout;
00197
00198
00199 friend class DDSTest;
00200
00201 protected:
00202 void duplicate(const DDS &dds);
00203 BaseType *leaf_match(const string &name, BaseType::btp_stack *s = 0);
00204 BaseType *exact_match(const string &name, BaseType::btp_stack *s = 0);
00205 virtual AttrTable *find_matching_container(AttrTable::entry *source,
00206 BaseType **dest_variable);
00207
00208 public:
00209 typedef std::vector<BaseType *>::const_iterator Vars_citer ;
00210 typedef std::vector<BaseType *>::iterator Vars_iter ;
00211 typedef std::vector<BaseType *>::reverse_iterator Vars_riter ;
00212
00213 DDS(BaseTypeFactory *factory, const string &n = "");
00214 DDS(const DDS &dds);
00215
00216 virtual ~DDS();
00217
00218 DDS & operator=(const DDS &rhs);
00219
00220 virtual void transfer_attributes(DAS *das);
00221
00222 string get_dataset_name() const;
00223 void set_dataset_name(const string &n);
00224
00229 BaseTypeFactory *get_factory() const
00230 {
00231 return d_factory;
00232 }
00233
00240 BaseTypeFactory *set_factory(BaseTypeFactory *factory)
00241 {
00242 BaseTypeFactory *t = d_factory;
00243 d_factory = factory;
00244 return t;
00245 }
00246
00247 virtual AttrTable &get_attr_table();
00248
00249 string filename();
00250 void filename(const string &fn);
00251
00253 int get_dap_major() const { return d_dap_major; }
00255 int get_dap_minor() const { return d_dap_minor; }
00256
00258 void set_dap_major(int p) { d_dap_major = p; }
00260 void set_dap_minor(int p) { d_dap_minor = p; }
00261
00262 void set_dap_version(const string &version_string);
00263
00265 string get_request_xml_base() const { return d_request_xml_base; }
00266
00268 void set_request_xml_base(const string &xb) { d_request_xml_base = xb; }
00269
00270 string container_name() ;
00271 void container_name( const string &cn ) ;
00272 Structure *container() ;
00273
00274 void add_var(BaseType *bt);
00275
00277 void del_var(const string &n);
00278
00279 BaseType *var(const string &n, BaseType::btp_stack &s);
00280 BaseType *var(const string &n, BaseType::btp_stack *s = 0);
00281 int num_var();
00282
00284 Vars_iter var_begin();
00286 Vars_riter var_rbegin();
00288 Vars_iter var_end();
00290 Vars_riter var_rend();
00292 Vars_iter get_vars_iter(int i);
00294 BaseType *get_var_index(int i);
00296 void del_var(Vars_iter i);
00298 void del_var(Vars_iter i1, Vars_iter i2);
00299
00300 void timeout_on();
00301 void timeout_off();
00302 void set_timeout(int t);
00303 int get_timeout();
00304
00305 void parse(string fname);
00306 void parse(int fd);
00307 void parse(FILE *in = stdin);
00308 #if FILE_METHODS
00309 void print(FILE *out);
00310 void print_constrained(FILE *out);
00311 void print_xml(FILE *out, bool constrained, const string &blob = "");
00312 #endif
00313 void print(ostream &out);
00314 void print_constrained(ostream &out);
00315 void print_xml(ostream &out, bool constrained, const string &blob = "");
00316
00317 void mark_all(bool state);
00318 bool mark(const string &name, bool state);
00319 bool check_semantics(bool all = false);
00320
00321 void tag_nested_sequences();
00322
00323 virtual void dump(ostream &strm) const ;
00324 };
00325
00326 }
00327
00328 #endif // _dds_h