Use a type alias to ensure compatibility with more versions of HDF5

This commit is contained in:
Guilhem Lavaux 2017-12-16 17:33:21 +01:00
parent aa42376cbe
commit 2cf9274b2e

View File

@ -51,6 +51,11 @@ knowledge of the CeCILL license and that you accept its terms.
#include <H5Cpp.h> #include <H5Cpp.h>
namespace CosmoTool { namespace CosmoTool {
#if (H5_VERS_MAJOR == 1) && (H5_VERS_MINOR <= 8)
typedef H5::CommonFG H5_CommonFileGroup;
#else
typedef H5::Group H5_CommonFileGroup;
#endif
//!_______________________________________________________________________________________ //!_______________________________________________________________________________________
//! //!
@ -129,7 +134,7 @@ namespace CosmoTool {
//! //!
//!_______________________________________________________________________________________ //!_______________________________________________________________________________________
template<typename ArrayType, typename hdf5_data_type> template<typename ArrayType, typename hdf5_data_type>
void hdf5_write_array(H5::H5Location& fg, const std::string& data_set_name, void hdf5_write_array(H5_CommonFileGroup& fg, const std::string& data_set_name,
const ArrayType& data, const ArrayType& data,
const hdf5_data_type& datatype, const hdf5_data_type& datatype,
const std::vector<hsize_t>& dimensions, const std::vector<hsize_t>& dimensions,
@ -156,7 +161,7 @@ namespace CosmoTool {
template<typename ArrayType, typename hdf5_data_type> template<typename ArrayType, typename hdf5_data_type>
void hdf5_write_array(H5::H5Location& fg, const std::string& data_set_name, void hdf5_write_array(H5_CommonFileGroup& fg, const std::string& data_set_name,
const ArrayType& data, const ArrayType& data,
const hdf5_data_type& datatype, const hdf5_data_type& datatype,
bool doCreate = true, bool doCreate = true,
@ -165,7 +170,7 @@ namespace CosmoTool {
std::vector<hsize_t> dimensions(data.shape(), data.shape() + data.num_dimensions()); std::vector<hsize_t> dimensions(data.shape(), data.shape() + data.num_dimensions());
hdf5_write_array(fg, data_set_name, data, datatype, dimensions, doCreate, useBases); hdf5_write_array(fg, data_set_name, data, datatype, dimensions, doCreate, useBases);
} }
/* HDF5 complex type */ /* HDF5 complex type */
template<typename T> template<typename T>
class hdf5_ComplexType class hdf5_ComplexType
@ -255,14 +260,14 @@ namespace CosmoTool {
}; };
template<typename ArrayType> template<typename ArrayType>
void hdf5_write_array(H5::H5Location& fg, const std::string& data_set_name, const ArrayType& data ) void hdf5_write_array(H5_CommonFileGroup& fg, const std::string& data_set_name, const ArrayType& data )
{ {
typedef typename ArrayType::element T; typedef typename ArrayType::element T;
get_hdf5_data_type<T> hdf_data_type; get_hdf5_data_type<T> hdf_data_type;
hdf5_write_array(fg, data_set_name, data, hdf_data_type.type()); hdf5_write_array(fg, data_set_name, data, hdf_data_type.type());
} }
// HDF5 array reader // HDF5 array reader
// //
// Author Guilhem Lavaux (May 2014) // Author Guilhem Lavaux (May 2014)
@ -341,7 +346,7 @@ namespace CosmoTool {
// ---------------------------------------------------------------------- // ----------------------------------------------------------------------
template<typename ArrayType, typename hdf5_data_type> template<typename ArrayType, typename hdf5_data_type>
void hdf5_read_array_typed(H5::H5Location& fg, const std::string& data_set_name, void hdf5_read_array_typed(H5_CommonFileGroup& fg, const std::string& data_set_name,
ArrayType& data, ArrayType& data,
const hdf5_data_type& datatype, bool auto_resize = true, bool useBases = false) const hdf5_data_type& datatype, bool auto_resize = true, bool useBases = false)
{ {
@ -377,7 +382,7 @@ namespace CosmoTool {
} }
template<typename ArrayType> template<typename ArrayType>
void hdf5_read_array(H5::H5Location& fg, const std::string& data_set_name, ArrayType& data, bool auto_resize = true, void hdf5_read_array(H5_CommonFileGroup& fg, const std::string& data_set_name, ArrayType& data, bool auto_resize = true,
bool useBases = false ) bool useBases = false )
{ {
typedef typename ArrayType::element T; typedef typename ArrayType::element T;