bes Updated for version 3.20.13
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
49class HDF5Array:public libdap::Array {
50
51 private:
52
53 int d_num_dim = 0;
54 int d_num_elm = 0;
55
56 hsize_t d_memneed = 0;
57 string var_path;
58
59 // Parse constraint expression and make HDF5 coordinate point location.
60 // return number of elements to read.
61 int format_constraint(int *cor, int *step, int *edg);
62
63#if 0
64 hid_t mkstr(int size, H5T_str_t pad);
65#endif
66
67 bool m_array_of_structure(hid_t dsetid, std::vector<char>&values,bool has_values,int values_offset,int nelms,const int* offset,const int*count,const int*step);
68 bool m_array_in_structure();
69 bool m_array_of_reference(hid_t dset_id,hid_t dtype_id);
70 bool m_array_of_reference_new_h5_apis(hid_t dset_id,hid_t dtype_id);
71 void m_intern_plain_array_data(char *convbuf,hid_t memtype);
72 void m_array_of_atomic(hid_t, hid_t,int,int*,int*,int*);
73
74 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);
75
76 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);
77
78 inline int INDEX_nD_TO_1D (const std::vector < int > &dims,
79 const std::vector < int > &pos);
80 bool obtain_next_pos(std::vector<int>& pos, std::vector<int>&start,std::vector<int>&end,std::vector<int>&step,int rank_change);
81
82 template<typename T> int subset(
83 const T input[],
84 int rank,
85 std::vector<int> & dim,
86 int start[],
87 int stride[],
88 int edge[],
89 std::vector<T> *poutput,
90 std::vector<int>& pos,
91 int index);
92 friend class HDF5Structure;
93 public:
94
96 HDF5Array(const std::string & n, const std::string &d, libdap::BaseType * v);
97 ~ HDF5Array() override = default;
98
104 libdap::BaseType *ptr_duplicate() override;
105
107 bool read() override;
108
110 void set_memneed(size_t need);
111
113 void set_numdim(int ndims);
114
116 void set_numelm(int nelms);
117
118 void set_varpath(const std::string& vpath) { var_path = vpath;}
119 libdap::BaseType *h5dims_transform_to_dap4(libdap::D4Group *root,const std::vector<std::string> &dimpath);
120};
121
122#endif
libdap::BaseType * ptr_duplicate() override
Definition: HDF5Array.cc:54
bool read() override
Reads HDF5 array data into local buffer.
Definition: HDF5Array.cc:109
void set_numdim(int ndims)
remembers number of dimensions of this array.
Definition: HDF5Array.cc:1732
void set_numelm(int nelms)
remembers number of elements in this array.
Definition: HDF5Array.cc:1736
void set_memneed(size_t need)
remembers memory size needed.
Definition: HDF5Array.cc:1728