OPeNDAP Hyrax Back End Server (BES)  Updated for version 3.8.3
HDF5Url.cc
Go to the documentation of this file.
1 // This file is part of hdf5_handler a HDF5 file handler for the OPeNDAP
2 // data server.
3 
4 // Author: Hyo-Kyung Lee <hyoklee@hdfgroup.org> and Muqun Yang
5 // <myang6@hdfgroup.org>
6 
7 // Copyright (c) 2009-2013 The HDF Group, Inc. and OPeNDAP, Inc.
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
20 // License along with this library; if not, write to the Free Software
21 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
22 //
23 // You can contact OPeNDAP, Inc. at PO Box 112, Saunderstown, RI. 02874-0112.
24 // You can contact The HDF Group, Inc. at 1800 South Oak Street,
25 // Suite 203, Champaign, IL 61820
26 
36 
37 
38 #include "config_hdf5.h"
39 
40 #include <string>
41 #include <ctype.h>
42 
43 #include "HDF5Url.h"
44 #include "InternalErr.h"
45 
46 HDF5Url::HDF5Url(const string &n, const string &d) : Url(n, d)
47 {
48  ty_id = -1;
49  dset_id = -1;
50 }
51 
53 {
54  return new HDF5Url(*this);
55 }
56 
58 {
59  hobj_ref_t rbuf;
60 
61  if (H5Dread(dset_id, H5T_STD_REF_OBJ, H5S_ALL, H5S_ALL, H5P_DEFAULT,
62  &rbuf) < 0) {
63  throw InternalErr(__FILE__, __LINE__, "H5Dread() failed.");
64  }
65 
66  hid_t did_r = H5Rdereference(dset_id, H5R_OBJECT, &rbuf);
67  char name[DODS_NAMELEN];
68  if (did_r < 0){
69  throw InternalErr(__FILE__, __LINE__, "H5Rdereference() failed.");
70  }
71  if (H5Iget_name(did_r, name, DODS_NAMELEN) < 0){
72  throw InternalErr(__FILE__, __LINE__, "Unable to retrieve the name of the object.");
73  }
74  string reference = name;
75  set_value(reference);
76 
77  // Release the handles.
78  if (H5Tclose(ty_id) < 0) {
79  throw InternalErr(__FILE__, __LINE__, "Unable to close the datatype.");
80  }
81  if (H5Dclose(dset_id) < 0) {
82  throw InternalErr(__FILE__, __LINE__, "Unable to close the dset.");
83  }
84 
85 
86  return true;
87 }
88 
89 void HDF5Url::set_did(hid_t dset)
90 {
91  dset_id = dset;
92 }
93 
94 void HDF5Url::set_tid(hid_t type)
95 {
96  ty_id = type;
97 }
98 
100 {
101  return dset_id;
102 }
103 
105 {
106  return ty_id;
107 }
This class generates DAP URL type for the default option.
void set_tid(hid_t type)
remembers HDF5 datatype id.
Definition: HDF5Url.cc:94
virtual BaseType * ptr_duplicate()
Clone this instance.
Definition: HDF5Url.cc:52
hid_t get_tid()
returns HDF5 datatype id.
Definition: HDF5Url.cc:104
#define DODS_NAMELEN
Maximum length of variable or attribute name(default option only).
Definition: hdf5_handler.h:43
HDF5Url(const string &n, const string &d)
Constructor.
Definition: HDF5Url.cc:46
virtual bool read()
Reads HDF5 reference data into local buffer as a string.
Definition: HDF5Url.cc:57
void set_did(hid_t dset)
remembers HDF5 dataset id.
Definition: HDF5Url.cc:89
hid_t get_did()
returns HDF5 dataset id.
Definition: HDF5Url.cc:99