OPeNDAP Hyrax Back End Server (BES)  Updated for version 3.8.3
HDF4_DMR.h
Go to the documentation of this file.
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 //#define USE_DAP4 1
22 //#undef USE_DAP4
23 #ifdef USE_DAP4
24 #include <DMR.h>
25 #include <InternalErr.h>
26 
27 using namespace libdap;
28 
43 class HDF4DMR : public libdap::DMR {
44 private:
45  int sdfd;
46  int fileid;
47  int gridfd;
48  int swathfd;
49 
50  void m_duplicate(const HDF4DMR &src)
51  {
52  sdfd = src.sdfd;
53  fileid = src.fileid;
54  gridfd = src.gridfd;
55  swathfd = src.swathfd;
56  }
57 
58 public:
59  HDF4DMR(libdap::DMR *dmr) : libdap::DMR(*dmr), sdfd(-1),fileid(-1),gridfd(-1),swathfd(-1) {}
60  HDF4DMR(libdap::D4BaseTypeFactory *factory,const string &name):libdap::DMR(factory,name),sdfd(-1),fileid(-1),gridfd(-1),swathfd(-1) {}
61 
62  HDF4DMR(const HDF4DMR &rhs) : libdap::DMR(rhs) {
63  m_duplicate(rhs);
64  }
65 
66  HDF4DMR & operator= (const HDF4DMR &rhs) {
67  if (this == &rhs)
68  return *this;
69 
70  dynamic_cast<libdap::DMR &>(*this) = rhs;
71  m_duplicate(rhs);
72 
73  return *this;
74  }
75 
76  ~HDF4DMR() {
77 
78  if (sdfd != -1)
79  SDend(sdfd);
80  if (fileid != -1)
81  Hclose(fileid);
82 
83 #ifdef USE_HDFEOS2_LIB
84  if (gridfd != -1)
85  GDclose(gridfd);
86  if (swathfd != -1)
87  SWclose(swathfd);
88 #endif
89  }
90 
91  void setHDF4Dataset(const int sdfd_in, const int fileid_in, const int gridfd_in, const int swathfd_in ) {
92  sdfd = sdfd_in;
93  fileid = fileid_in;
94  gridfd = gridfd_in;
95  swathfd = swathfd_in;
96  }
97 
98  void setHDF4Dataset(const int sdfd_in,const int fileid_in) {
99  sdfd = sdfd_in;
100  fileid = fileid_in;
101  }
102 };
103 #endif
104 
105 #endif
106 
107 
108 
static class NCMLUtil overview