From c853abe354aa35ef809362d538b646f29bb95275 Mon Sep 17 00:00:00 2001 From: Guilhem Lavaux Date: Wed, 11 Feb 2015 21:38:43 +0100 Subject: [PATCH] Simplified template substitution. Also more general. --- src/hdf5_array.hpp | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/src/hdf5_array.hpp b/src/hdf5_array.hpp index 98ea28f..c6ce5c9 100644 --- a/src/hdf5_array.hpp +++ b/src/hdf5_array.hpp @@ -181,38 +181,34 @@ namespace CosmoTool { } }; - template + template void hdf5_read_array(H5::CommonFG& fg, const std::string& data_set_name, - boost::multi_array& data, + ArrayType& data, const hdf5_data_type& datatype) { H5::DataSet dataset = fg.openDataSet(data_set_name); H5::DataSpace dataspace = dataset.getSpace(); - std::vector dimensions(DIMENSIONS); + std::vector dimensions(data.num_dimensions()); - if (dataspace.getSimpleExtentNdims() != DIMENSIONS) + if (dataspace.getSimpleExtentNdims() != data.num_dimensions()) { throw InvalidDimensions(); } dataspace.getSimpleExtentDims(dimensions.data()); - data.resize(hdf5_extent_gen::build(dimensions.data())); + data.resize(hdf5_extent_gen::build(dimensions.data())); dataset.read(data.data(), datatype); } - template - void hdf5_read_array(H5::CommonFG& fg, const std::string& data_set_name, boost::multi_array& data ) + template + void hdf5_read_array(H5::CommonFG& fg, const std::string& data_set_name, ArrayType& data ) { + typedef typename ArrayType::element T; + get_hdf5_data_type hdf_data_type; hdf5_read_array(fg, data_set_name, data, hdf_data_type.type()); } - template - void hdf5_read_array(H5::CommonFG& fg, const std::string& data_set_name, boost::multi_array, DIMENSIONS>& data ) - { - hdf5_read_array(fg, data_set_name, data, hdf5_ComplexType::ctype()->type); - } - #define CTOOL_HDF5_NAME(STRUCT) BOOST_PP_CAT(hdf5_,STRUCT) #define CTOOL_HDF5_INSERT_ELEMENT(r, STRUCT, element) \