bes  Updated for version 3.20.13
HDF4_DMR.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_DMR_H_
10 #define HDF4_DMR_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/DMR.h>
22 #include <libdap/InternalErr.h>
23 
24 
39 class HDF4DMR : public libdap::DMR {
40 private:
41  int sdfd;
42  int fileid;
43  int gridfd;
44  int swathfd;
45 
46  void m_duplicate(const HDF4DMR &src)
47  {
48  sdfd = src.sdfd;
49  fileid = src.fileid;
50  gridfd = src.gridfd;
51  swathfd = src.swathfd;
52  }
53 
54 public:
55  explicit HDF4DMR(libdap::DMR *dmr) : libdap::DMR(*dmr), sdfd(-1),fileid(-1),gridfd(-1),swathfd(-1) {}
56  HDF4DMR(libdap::D4BaseTypeFactory *factory,const string &name):libdap::DMR(factory,name),sdfd(-1),fileid(-1),gridfd(-1),swathfd(-1) {}
57 
58  HDF4DMR(const HDF4DMR &rhs) : libdap::DMR(rhs) {
59  m_duplicate(rhs);
60  }
61 
62  HDF4DMR & operator= (const HDF4DMR &rhs) {
63  if (this == &rhs)
64  return *this;
65 
66 #if 0
67  dynamic_cast<libdap::DMR &>(*this) = rhs;
68 #endif
69  libdap::DMR::operator=(rhs);
70  m_duplicate(rhs);
71 
72  return *this;
73  }
74 
75  ~HDF4DMR() {
76 
77  if (sdfd != -1)
78  SDend(sdfd);
79  if (fileid != -1)
80  Hclose(fileid);
81 
82 #ifdef USE_HDFEOS2_LIB
83  if (gridfd != -1)
84  GDclose(gridfd);
85  if (swathfd != -1)
86  SWclose(swathfd);
87 #endif
88  }
89 
90  void setHDF4Dataset(const int sdfd_in, const int fileid_in, const int gridfd_in, const int swathfd_in ) {
91  sdfd = sdfd_in;
92  fileid = fileid_in;
93  gridfd = gridfd_in;
94  swathfd = swathfd_in;
95  }
96 
97  void setHDF4Dataset(const int sdfd_in,const int fileid_in) {
98  sdfd = sdfd_in;
99  fileid = fileid_in;
100  }
101 };
102 
103 #endif
104 
105 
106