bes  Updated for version 3.20.6
HDF5Array.h
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-2016 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 
27 #ifndef _HDF5ARRAY_H
28 #define _HDF5ARRAY_H
29 
30 #include <H5Ipublic.h>
31 #include <H5Rpublic.h>
32 
33 #include "Array.h"
34 #include "h5get.h"
35 
36 
48 class HDF5Array:public libdap::Array {
49  private:
50  int d_num_dim;
51  int d_num_elm;
52 
53  hsize_t d_memneed;
54  string var_path;
55 
56  // Parse constraint expression and make HDF5 coordinate point location.
57  // return number of elements to read.
58  int format_constraint(int *cor, int *step, int *edg);
59 
60  hid_t mkstr(int size, H5T_str_t pad);
61 
62  bool m_array_of_structure(hid_t dsetid, std::vector<char>&values,bool has_values,int values_offset,int nelms,int* offset,int*count,int*step);
63  bool m_array_in_structure();
64  bool m_array_of_reference(hid_t dset_id,hid_t dtype_id);
65  void m_intern_plain_array_data(char *convbuf,hid_t memtype);
66  void m_array_of_atomic(hid_t, hid_t,int,int*,int*,int*);
67 
68  void do_array_read(hid_t dset_id,hid_t dtype_id,std::vector<char>&values,bool has_values,int values_offset,int nelms,int* offset,int* count, int* step);
69 
70  bool do_h5_array_type_read(hid_t dsetid, hid_t memb_id,std::vector<char>&values,bool has_values,int values_offset, int at_nelms,int* at_offset,int*at_count,int* at_step);
71 
72  inline int INDEX_nD_TO_1D (const std::vector < int > &dims,
73  const std::vector < int > &pos);
74  bool obtain_next_pos(std::vector<int>& pos, std::vector<int>&start,std::vector<int>&end,std::vector<int>&step,int rank_change);
75 
76  template<typename T> int subset(
77  const T input[],
78  int rank,
79  std::vector<int> & dim,
80  int start[],
81  int stride[],
82  int edge[],
83  std::vector<T> *poutput,
84  std::vector<int>& pos,
85  int index);
86  friend class HDF5Structure;
87  public:
88 
90  HDF5Array(const std::string & n, const std::string &d, libdap::BaseType * v);
91  virtual ~ HDF5Array();
92 
98  virtual libdap::BaseType *ptr_duplicate();
99 
101  virtual bool read();
102 
104  friend std::string return_type(hid_t datatype);
105 
107  void set_memneed(size_t need);
108 
110  void set_numdim(int ndims);
111 
113  void set_numelm(int nelms);
114 
115  void set_varpath(const std::string vpath) { var_path = vpath;}
116  libdap::BaseType *h5dims_transform_to_dap4(libdap::D4Group *root);
117 };
118 
119 #endif
HDF5Array::set_numdim
void set_numdim(int ndims)
remembers number of dimensions of this array.
Definition: HDF5Array.cc:1450
HDF5Array::set_memneed
void set_memneed(size_t need)
remembers memory size needed.
Definition: HDF5Array.cc:1446
HDF5Array::ptr_duplicate
virtual libdap::BaseType * ptr_duplicate()
Definition: HDF5Array.cc:54
HDF5Array::HDF5Array
HDF5Array(const std::string &n, const std::string &d, libdap::BaseType *v)
Constructor.
Definition: HDF5Array.cc:58
HDF5Array::set_numelm
void set_numelm(int nelms)
remembers number of elements in this array.
Definition: HDF5Array.cc:1454
HDF5Structure
Definition: HDF5Structure.h:43
HDF5Array::return_type
friend std::string return_type(hid_t datatype)
See return_type function defined in h5dds.cc.
HDF5Array::read
virtual bool read()
Reads HDF5 array data into local buffer.
Definition: HDF5Array.cc:114
h5get.h
HDF5Array
Definition: HDF5Array.h:48