OPeNDAP Hyrax Back End Server (BES)  Updated for version 3.8.3
HDF5Structure.cc
Go to the documentation of this file.
1 // This file is part of the hdf5 data handler for the OPeNDAP data server.
3 //
4 // Copyright (c) 2005 OPeNDAP, Inc.
5 // Copyright (c) 2007-2013 The HDF Group, Inc.
6 // Author: James Gallagher <jgallagher@opendap.org>
7 // Hyo-Kyung Lee <hyoklee@hdfgroup.org>
8 //
9 // This is free software; you can redistribute it and/or modify it under the
10 // terms of the GNU Lesser General Public License as published by the Free
11 // Software Foundation; either version 2.1 of the License, or (at your
12 // option) any later version.
13 //
14 // This software is distributed in the hope that it will be useful, but
15 // WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
16 // or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
17 // License for more details.
18 //
19 // You should have received a copy of the GNU Lesser General Public License
20 // along with this software; if not, write to the Free Software Foundation,
21 // Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
22 
23 // #define DODS_DEBUG
29 
30 
31 #include <string>
32 #include <ctype.h>
33 #include "config_hdf5.h"
34 #include "hdf5.h"
35 #include "h5dds.h"
36 #include "HDF5Structure.h"
37 #include "InternalErr.h"
38 #include "debug.h"
39 
41 {
42  return new HDF5Structure(*this);
43 }
44 
45 HDF5Structure::HDF5Structure(const string & n, const string &d)
46  : Structure(n, d)
47 {
48  ty_id = -1;
49  dset_id = -1;
50  array_index = 0;
51  array_size = 1;
52  array_entire_size = 1;
53 }
54 
56 {
57 }
58 
60 {
61  if (this == &rhs)
62  return *this;
63 
64  static_cast < Structure & >(*this) = rhs; // run Structure assignment
65 
66 
67  return *this;
68 }
69 
71 {
72 
73  int i = 0;
74  int err = 0;
75  Constructor::Vars_iter q;
76 
77  DBG(cerr
78  << ">read() dataset=" << dataset()
79  << " array_index= " << array_index << endl);
80 
81  if (read_p())
82  return true;
83 
84 
85  // Read each member in the structure.
86  for (q = var_begin(); err == 0 && q != var_end(); ++q, ++i) {
87  DBG(cerr << "=read() i=" << i << endl);
88  BaseType *p = static_cast < BaseType * >(*q);
89  p->read();
90  }
91 
92  set_read_p(true);
93  // Release the handles.
94 #if 0
95  if (H5Tclose(ty_id) < 0) {
96  throw InternalErr(__FILE__, __LINE__, "Unable to close the datatype.");
97  }
98  if (H5Dclose(dset_id) < 0) {
99  throw InternalErr(__FILE__, __LINE__, "Unable to close the dset.");
100  }
101 #endif
102 
103 
104  return true;
105 }
106 
107 void HDF5Structure::set_did(hid_t dset)
108 {
109  dset_id = dset;
110 }
111 
112 void HDF5Structure::set_tid(hid_t type)
113 {
114  ty_id = type;
115 }
116 
118 {
119  return dset_id;
120 }
121 
123 {
124  return ty_id;
125 }
126 
128 {
129  array_index = i;
130 }
131 
133 {
134  return array_index;
135 }
136 
138 {
139  array_size = i;
140 }
141 
143 {
144  return array_size;
145 }
146 
148 {
149  array_entire_size = i;
150 }
151 
153 {
154  return array_entire_size;
155 }
HDF5Structure & operator=(const HDF5Structure &rhs)
Assignment operator for dynamic cast into generic Structure.
void set_entire_array_size(int i)
returns the entire array size of this Structure if it's a part of array of structures.
hid_t get_tid()
returns HDF5 datatype id.
This class converts HDF5 compound type into DAP structure for the default option. ...
int get_array_index()
returns the array index of this Structure if it's a part of array of structures.
Data structure and retrieval processing header for the default option.
void set_array_size(int i)
remembers the array size for subsetting if it's a part of array of structures.
virtual BaseType * ptr_duplicate()
Clone this instance.
void set_array_index(int i)
remembers the array index of this Structure if it's a part of array of structures.
hid_t get_did()
returns HDF5 dataset id.
int get_array_size()
returns the array size for subsetting if it's a part of array of structures.
void set_did(hid_t dset)
remembers HDF5 datatype id.
int get_entire_array_size()
returns the entire array size of this Structure if it's a part of array of structures.
virtual bool read()
Reads HDF5 structure data by calling each member's read method in this structure. ...
HDF5Structure(const string &n, const string &d)
Constructor.
void set_tid(hid_t type)
remembers HDF5 datatype id.
virtual ~HDF5Structure()