File: def_hdf5.hpp

package info (click to toggle)
armadillo 1%3A10.1.2%2Bdfsg-6
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 8,320 kB
  • sloc: cpp: 148,245; makefile: 66; sh: 34
file content (154 lines) | stat: -rw-r--r-- 6,638 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
// Copyright 2008-2016 Conrad Sanderson (http://conradsanderson.id.au)
// Copyright 2008-2016 National ICT Australia (NICTA)
// 
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
// 
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// ------------------------------------------------------------------------


#if defined(ARMA_USE_HDF5)

#if !defined(ARMA_USE_HDF5_ALT)
  
  // macros needed if the wrapper run-time library is not being used
  
  #define arma_H5Tcopy      H5Tcopy
  #define arma_H5Tcreate    H5Tcreate
  #define arma_H5Tinsert    H5Tinsert
  #define arma_H5Tequal     H5Tequal
  #define arma_H5Tclose     H5Tclose

  #define arma_H5Dopen      H5Dopen
  #define arma_H5Dget_type  H5Dget_type
  #define arma_H5Dclose     H5Dclose
  #define arma_H5Dwrite     H5Dwrite
  #define arma_H5Dget_space H5Dget_space
  #define arma_H5Dread      H5Dread
  #define arma_H5Dcreate    H5Dcreate

  #define arma_H5Sget_simple_extent_ndims   H5Sget_simple_extent_ndims
  #define arma_H5Sget_simple_extent_dims    H5Sget_simple_extent_dims
  #define arma_H5Sclose                     H5Sclose
  #define arma_H5Screate_simple             H5Screate_simple

  #define arma_H5Ovisit     H5Ovisit

  #define arma_H5Eset_auto  H5Eset_auto
  #define arma_H5Eget_auto  H5Eget_auto

  #define arma_H5Fopen      H5Fopen
  #define arma_H5Fcreate    H5Fcreate
  #define arma_H5Fclose     H5Fclose
  #define arma_H5Fis_hdf5   H5Fis_hdf5

  #define arma_H5Gcreate    H5Gcreate
  #define arma_H5Gopen      H5Gopen
  #define arma_H5Gclose     H5Gclose
  
  #define arma_H5Lexists    H5Lexists
  #define arma_H5Ldelete    H5Ldelete
  
  #define arma_H5T_NATIVE_UCHAR   H5T_NATIVE_UCHAR
  #define arma_H5T_NATIVE_CHAR    H5T_NATIVE_CHAR
  #define arma_H5T_NATIVE_SHORT   H5T_NATIVE_SHORT
  #define arma_H5T_NATIVE_USHORT  H5T_NATIVE_USHORT
  #define arma_H5T_NATIVE_INT     H5T_NATIVE_INT
  #define arma_H5T_NATIVE_UINT    H5T_NATIVE_UINT
  #define arma_H5T_NATIVE_LONG    H5T_NATIVE_LONG
  #define arma_H5T_NATIVE_ULONG   H5T_NATIVE_ULONG
  #define arma_H5T_NATIVE_LLONG   H5T_NATIVE_LLONG
  #define arma_H5T_NATIVE_ULLONG  H5T_NATIVE_ULLONG
  #define arma_H5T_NATIVE_FLOAT   H5T_NATIVE_FLOAT
  #define arma_H5T_NATIVE_DOUBLE  H5T_NATIVE_DOUBLE

#else

// prototypes for the wrapper functions defined in the wrapper run-time library (src/wrapper.cpp)

extern "C"
  {
  // Wrapper functions for H5* functions.
  hid_t  arma_H5Tcopy(hid_t dtype_id);
  hid_t  arma_H5Tcreate(H5T_class_t cl, size_t size);
  herr_t arma_H5Tinsert(hid_t dtype_id, const char* name, size_t offset, hid_t field_id);
  htri_t arma_H5Tequal(hid_t dtype_id1, hid_t dtype_id2);
  herr_t arma_H5Tclose(hid_t dtype_id);
  
  hid_t  arma_H5Dopen(hid_t loc_id, const char* name, hid_t dapl_id);
  hid_t  arma_H5Dget_type(hid_t dataset_id);
  herr_t arma_H5Dclose(hid_t dataset_id);
  hid_t  arma_H5Dcreate(hid_t loc_id, const char* name, hid_t dtype_id, hid_t space_id, hid_t lcpl_id, hid_t dcpl_id, hid_t dapl_id);
  herr_t arma_H5Dwrite(hid_t dataset_id, hid_t mem_type_id, hid_t mem_space_id, hid_t file_space_id, hid_t xfer_plist_id, const void* buf);
  hid_t  arma_H5Dget_space(hid_t dataset_id);
  herr_t arma_H5Dread(hid_t dataset_id, hid_t mem_type_id, hid_t mem_space_id, hid_t file_space_id, hid_t xfer_plist_id, void* buf);
  
  int    arma_H5Sget_simple_extent_ndims(hid_t space_id);
  int    arma_H5Sget_simple_extent_dims(hid_t space_id, hsize_t* dims, hsize_t* maxdims);
  herr_t arma_H5Sclose(hid_t space_id);
  hid_t  arma_H5Screate_simple(int rank, const hsize_t* current_dims, const hsize_t* maximum_dims);
  
  herr_t arma_H5Ovisit(hid_t object_id, H5_index_t index_type, H5_iter_order_t order, H5O_iterate_t op, void* op_data);
  
  herr_t arma_H5Eset_auto(hid_t estack_id, H5E_auto_t func, void* client_data);
  herr_t arma_H5Eget_auto(hid_t estack_id, H5E_auto_t* func, void** client_data);
  
  hid_t  arma_H5Fopen(const char* name, unsigned flags, hid_t fapl_id);
  hid_t  arma_H5Fcreate(const char* name, unsigned flags, hid_t fcpl_id, hid_t fapl_id);
  herr_t arma_H5Fclose(hid_t file_id);
  htri_t arma_H5Fis_hdf5(const char* name);
  
  hid_t  arma_H5Gcreate(hid_t loc_id, const char* name, hid_t lcpl_id, hid_t gcpl_id, hid_t gapl_id);
  hid_t  arma_H5Gopen(hid_t loc_id, const char* name, hid_t gapl_id);
  herr_t arma_H5Gclose(hid_t group_id);
  
  htri_t arma_H5Lexists(hid_t loc_id, const char* name, hid_t lapl_id);
  herr_t arma_H5Ldelete(hid_t loc_id, const char* name, hid_t lapl_id);
  
  // Wrapper variables that represent the hid_t values for the H5T_NATIVE_*
  // types.  Note that H5T_NATIVE_UCHAR itself is a macro that resolves to about
  // forty other macros, and we definitely don't want to hijack those,
  // so this is the best way to go about wrapping these...
  extern hid_t arma_H5T_NATIVE_UCHAR;
  extern hid_t arma_H5T_NATIVE_CHAR;
  extern hid_t arma_H5T_NATIVE_SHORT;
  extern hid_t arma_H5T_NATIVE_USHORT;
  extern hid_t arma_H5T_NATIVE_INT;
  extern hid_t arma_H5T_NATIVE_UINT;
  extern hid_t arma_H5T_NATIVE_LONG;
  extern hid_t arma_H5T_NATIVE_ULONG;
  extern hid_t arma_H5T_NATIVE_LLONG;
  extern hid_t arma_H5T_NATIVE_ULLONG;
  extern hid_t arma_H5T_NATIVE_FLOAT;
  extern hid_t arma_H5T_NATIVE_DOUBLE;
  
  }
  
  // Lastly, we have to hijack H5open() and H5check_version(), which are called
  // by some expanded macros of the other H5* functions.  This means we can't
  // create arma_H5open(), because we can't modify those macros.  Instead, we'll
  // create arma::H5open() and arma::H5check_version(), and then issue a using
  // directive so that arma::H5open() and arma::H5check_version() are always
  // called.
  //
  // There is potential danger in the use of a using directive like this, but in
  // this case, I can't think of a better way to solve the problem, and I doubt
  // this will cause problems in any situations that aren't truly bizarre.  And
  // if it does cause problems, the user can #define ARMA_DONT_USE_WRAPPER or
  // #undef ARMA_USE_WRAPPER in their Armadillo configuration.
  herr_t H5open();
  herr_t H5check_version(unsigned majnum, unsigned minnum, unsigned relnum);
  
  using arma::H5open;
  using arma::H5check_version;
  
#endif

#endif