source: mmcs/armadillo_bits/hdf5_bones.hpp @ 8daa049

matrices
Last change on this file since 8daa049 was 9dd61b1, checked in by rboet <rboet@…>, 9 years ago

Avance del proyecto 60%

  • Property mode set to 100644
File size: 5.6 KB
Line 
1// Copyright (C) 2014 Ryan Curtin
2//
3// This Source Code Form is subject to the terms of the Mozilla Public
4// License, v. 2.0. If a copy of the MPL was not distributed with this
5// file, You can obtain one at http://mozilla.org/MPL/2.0/.
6
7
8#if defined(ARMA_USE_HDF5)
9
10#if !defined(ARMA_USE_HDF5_ALT)
11 
12  // macros needed if the wrapper run-time library is not being used
13 
14  #define arma_H5Tcopy      H5Tcopy
15  #define arma_H5Tcreate    H5Tcreate
16  #define arma_H5Tinsert    H5Tinsert
17  #define arma_H5Tequal     H5Tequal
18  #define arma_H5Tclose     H5Tclose
19
20  #define arma_H5Dopen      H5Dopen
21  #define arma_H5Dget_type  H5Dget_type
22  #define arma_H5Dclose     H5Dclose
23  #define arma_H5Dwrite     H5Dwrite
24  #define arma_H5Dget_space H5Dget_space
25  #define arma_H5Dread      H5Dread
26  #define arma_H5Dcreate    H5Dcreate
27
28  #define arma_H5Sget_simple_extent_ndims   H5Sget_simple_extent_ndims
29  #define arma_H5Sget_simple_extent_dims    H5Sget_simple_extent_dims
30  #define arma_H5Sclose                     H5Sclose
31  #define arma_H5Screate_simple             H5Screate_simple
32
33  #define arma_H5Ovisit     H5Ovisit
34
35  #define arma_H5Eset_auto  H5Eset_auto
36  #define arma_H5Eget_auto  H5Eget_auto
37
38  #define arma_H5Fopen      H5Fopen
39  #define arma_H5Fcreate    H5Fcreate
40  #define arma_H5Fclose     H5Fclose
41  #define arma_H5Fis_hdf5   H5Fis_hdf5
42
43  #define arma_H5T_NATIVE_UCHAR   H5T_NATIVE_UCHAR
44  #define arma_H5T_NATIVE_CHAR    H5T_NATIVE_CHAR
45  #define arma_H5T_NATIVE_SHORT   H5T_NATIVE_SHORT
46  #define arma_H5T_NATIVE_USHORT  H5T_NATIVE_USHORT
47  #define arma_H5T_NATIVE_INT     H5T_NATIVE_INT
48  #define arma_H5T_NATIVE_UINT    H5T_NATIVE_UINT
49  #define arma_H5T_NATIVE_LONG    H5T_NATIVE_LONG
50  #define arma_H5T_NATIVE_ULONG   H5T_NATIVE_ULONG
51  #define arma_H5T_NATIVE_LLONG   H5T_NATIVE_LLONG
52  #define arma_H5T_NATIVE_ULLONG  H5T_NATIVE_ULLONG
53  #define arma_H5T_NATIVE_FLOAT   H5T_NATIVE_FLOAT
54  #define arma_H5T_NATIVE_DOUBLE  H5T_NATIVE_DOUBLE
55
56#else
57
58// prototypes for the wrapper functions defined in the wrapper run-time library (src/wrapper.cpp)
59
60extern "C"
61  {
62  // Wrapper functions for H5* functions.
63  hid_t  arma_H5Tcopy(hid_t dtype_id);
64  hid_t  arma_H5Tcreate(H5T_class_t cl, size_t size);
65  herr_t arma_H5Tinsert(hid_t dtype_id, const char* name, size_t offset, hid_t field_id);
66  htri_t arma_H5Tequal(hid_t dtype_id1, hid_t dtype_id2);
67  herr_t arma_H5Tclose(hid_t dtype_id);
68 
69  hid_t  arma_H5Dopen(hid_t loc_id, const char* name, hid_t dapl_id);
70  hid_t  arma_H5Dget_type(hid_t dataset_id);
71  herr_t arma_H5Dclose(hid_t dataset_id);
72  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);
73  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);
74  hid_t  arma_H5Dget_space(hid_t dataset_id);
75  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);
76 
77  int    arma_H5Sget_simple_extent_ndims(hid_t space_id);
78  int    arma_H5Sget_simple_extent_dims(hid_t space_id, hsize_t* dims, hsize_t* maxdims);
79  herr_t arma_H5Sclose(hid_t space_id);
80  hid_t  arma_H5Screate_simple(int rank, const hsize_t* current_dims, const hsize_t* maximum_dims);
81 
82  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);
83 
84  herr_t arma_H5Eset_auto(hid_t estack_id, H5E_auto_t func, void* client_data);
85  herr_t arma_H5Eget_auto(hid_t estack_id, H5E_auto_t* func, void** client_data);
86 
87  hid_t  arma_H5Fopen(const char* name, unsigned flags, hid_t fapl_id);
88  hid_t  arma_H5Fcreate(const char* name, unsigned flags, hid_t fcpl_id, hid_t fapl_id);
89  herr_t arma_H5Fclose(hid_t file_id);
90  htri_t arma_H5Fis_hdf5(const char* name);
91 
92  // Wrapper variables that represent the hid_t values for the H5T_NATIVE_*
93  // types.  Note that H5T_NATIVE_UCHAR itself is a macro that resolves to about
94  // forty other macros, and we definitely don't want to hijack those,
95  // so this is the best way to go about wrapping these...
96  extern hid_t arma_H5T_NATIVE_UCHAR;
97  extern hid_t arma_H5T_NATIVE_CHAR;
98  extern hid_t arma_H5T_NATIVE_SHORT;
99  extern hid_t arma_H5T_NATIVE_USHORT;
100  extern hid_t arma_H5T_NATIVE_INT;
101  extern hid_t arma_H5T_NATIVE_UINT;
102  extern hid_t arma_H5T_NATIVE_LONG;
103  extern hid_t arma_H5T_NATIVE_ULONG;
104  extern hid_t arma_H5T_NATIVE_LLONG;
105  extern hid_t arma_H5T_NATIVE_ULLONG;
106  extern hid_t arma_H5T_NATIVE_FLOAT;
107  extern hid_t arma_H5T_NATIVE_DOUBLE;
108 
109  }
110 
111  // Lastly, we have to hijack H5open() and H5check_version(), which are called
112  // by some expanded macros of the other H5* functions.  This means we can't
113  // create arma_H5open(), because we can't modify those macros.  Instead, we'll
114  // create arma::H5open() and arma::H5check_version(), and then issue a using
115  // directive so that arma::H5open() and arma::H5check_version() are always
116  // called.
117  //
118  // There is potential danger in the use of a using directive like this, but in
119  // this case, I can't think of a better way to solve the problem, and I doubt
120  // this will cause problems in any situations that aren't truly bizarre.  And
121  // if it does cause problems, the user can #define ARMA_DONT_USE_WRAPPER or
122  // #undef ARMA_USE_WRAPPER in their Armadillo configuration.
123  herr_t H5open();
124  herr_t H5check_version(unsigned majnum, unsigned minnum, unsigned relnum);
125 
126  using arma::H5open;
127  using arma::H5check_version;
128 
129#endif
130
131#endif
Note: See TracBrowser for help on using the repository browser.