bes  Updated for version 3.20.13
HDF4_DDS.h
1 // This file is part of the hdf4 data handler for the OPeNDAP data server.
3 //
4 // Author: Kent Yang <myang6@hdfgroup.org>
5 // Copyright (c) 2010-2014 The HDF Group
6 // The idea is borrowed from GDAL OPeNDAP handler that is implemented by
7 // James Gallagher<jgallagher@opendap.org>
8 
9 #ifndef HDF4_DDS_H_
10 #define HDF4_DDS_H_
11 
12 #include "config.h"
13 
14 #include "hdf.h"
15 #include "mfhdf.h"
16 
17 #ifdef USE_HDFEOS2_LIB
18 #include "HdfEosDef.h"
19 #endif
20 
21 #include <libdap/DDS.h>
22 #include <libdap/InternalErr.h>
23 
24 
39 class HDF4DDS : public libdap::DDS {
40 private:
41  int sdfd;
42  int fileid;
43  int gridfd;
44  int swathfd;
45 
46  void m_duplicate(const HDF4DDS &src)
47  {
48  sdfd = src.sdfd;
49  fileid = src.fileid;
50  gridfd = src.gridfd;
51  swathfd = src.swathfd;
52  }
53 
54 public:
55  explicit HDF4DDS(libdap::DDS *ddsIn) : libdap::DDS(*ddsIn), sdfd(-1),fileid(-1),gridfd(-1),swathfd(-1) {}
56 
57  HDF4DDS(const HDF4DDS &rhs) : libdap::DDS(rhs) {
58  m_duplicate(rhs);
59  }
60 
61  HDF4DDS & operator= (const HDF4DDS &rhs) {
62  if (this == &rhs)
63  return *this;
64 
65  libdap::DDS::operator=(rhs);
66 
67  m_duplicate(rhs);
68 
69  return *this;
70  }
71 
72  ~HDF4DDS() {
73 
74  if (sdfd != -1)
75  SDend(sdfd);
76  if (fileid != -1)
77  Hclose(fileid);
78 
79 #ifdef USE_HDFEOS2_LIB
80  if (gridfd != -1)
81  GDclose(gridfd);
82  if (swathfd != -1)
83  SWclose(swathfd);
84 #endif
85  }
86 
87  void setHDF4Dataset(const int sdfd_in, const int fileid_in, const int gridfd_in, const int swathfd_in ) {
88  sdfd = sdfd_in;
89  fileid = fileid_in;
90  gridfd = gridfd_in;
91  swathfd = swathfd_in;
92  }
93 
94  void setHDF4Dataset(const int sdfd_in,const int fileid_in) {
95  sdfd = sdfd_in;
96  fileid = fileid_in;
97  }
98 };
99 
100 #endif
101 
102 
103