bes  Updated for version 3.20.10
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 <libdap/Array.h>
34 
35 #include "h5get.h"
36 
37 
49 class HDF5Array:public libdap::Array {
50  private:
51  int d_num_dim;
52  int d_num_elm;
53 
54  hsize_t d_memneed;
55  string var_path;
56 
57  // Parse constraint expression and make HDF5 coordinate point location.
58  // return number of elements to read.
59  int format_constraint(int *cor, int *step, int *edg);
60 
61  hid_t mkstr(int size, H5T_str_t pad);
62 
63  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);
64  bool m_array_in_structure();
65  bool m_array_of_reference(hid_t dset_id,hid_t dtype_id);
66  bool m_array_of_reference_new_h5_apis(hid_t dset_id,hid_t dtype_id);
67  void m_intern_plain_array_data(char *convbuf,hid_t memtype);
68  void m_array_of_atomic(hid_t, hid_t,int,int*,int*,int*);
69 
70  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);
71 
72  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);
73 
74  inline int INDEX_nD_TO_1D (const std::vector < int > &dims,
75  const std::vector < int > &pos);
76  bool obtain_next_pos(std::vector<int>& pos, std::vector<int>&start,std::vector<int>&end,std::vector<int>&step,int rank_change);
77 
78  template<typename T> int subset(
79  const T input[],
80  int rank,
81  std::vector<int> & dim,
82  int start[],
83  int stride[],
84  int edge[],
85  std::vector<T> *poutput,
86  std::vector<int>& pos,
87  int index);
88  friend class HDF5Structure;
89  public:
90 
92  HDF5Array(const std::string & n, const std::string &d, libdap::BaseType * v);
93  virtual ~ HDF5Array();
94 
100  virtual libdap::BaseType *ptr_duplicate();
101 
103  virtual bool read();
104 
106  friend std::string return_type(hid_t datatype);
107 
109  void set_memneed(size_t need);
110 
112  void set_numdim(int ndims);
113 
115  void set_numelm(int nelms);
116 
117  void set_varpath(const std::string vpath) { var_path = vpath;}
118  libdap::BaseType *h5dims_transform_to_dap4(libdap::D4Group *root,const std::vector<std::string> &dimpath);
119 };
120 
121 #endif
friend std::string return_type(hid_t datatype)
See return_type function defined in h5dds.cc.
virtual libdap::BaseType * ptr_duplicate()
Definition: HDF5Array.cc:54
virtual bool read()
Reads HDF5 array data into local buffer.
Definition: HDF5Array.cc:115
void set_numdim(int ndims)
remembers number of dimensions of this array.
Definition: HDF5Array.cc:1737
HDF5Array(const std::string &n, const std::string &d, libdap::BaseType *v)
Constructor.
Definition: HDF5Array.cc:58
void set_numelm(int nelms)
remembers number of elements in this array.
Definition: HDF5Array.cc:1741
void set_memneed(size_t need)
remembers memory size needed.
Definition: HDF5Array.cc:1733