Simplified template substitution. Also more general.
This commit is contained in:
parent
a26de4a2fa
commit
c853abe354
@ -181,38 +181,34 @@ namespace CosmoTool {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
template<typename T, std::size_t DIMENSIONS, typename hdf5_data_type>
|
template<typename ArrayType, typename hdf5_data_type>
|
||||||
void hdf5_read_array(H5::CommonFG& fg, const std::string& data_set_name,
|
void hdf5_read_array(H5::CommonFG& fg, const std::string& data_set_name,
|
||||||
boost::multi_array<T, DIMENSIONS>& data,
|
ArrayType& data,
|
||||||
const hdf5_data_type& datatype)
|
const hdf5_data_type& datatype)
|
||||||
{
|
{
|
||||||
H5::DataSet dataset = fg.openDataSet(data_set_name);
|
H5::DataSet dataset = fg.openDataSet(data_set_name);
|
||||||
H5::DataSpace dataspace = dataset.getSpace();
|
H5::DataSpace dataspace = dataset.getSpace();
|
||||||
std::vector<hsize_t> dimensions(DIMENSIONS);
|
std::vector<hsize_t> dimensions(data.num_dimensions());
|
||||||
|
|
||||||
if (dataspace.getSimpleExtentNdims() != DIMENSIONS)
|
if (dataspace.getSimpleExtentNdims() != data.num_dimensions())
|
||||||
{
|
{
|
||||||
throw InvalidDimensions();
|
throw InvalidDimensions();
|
||||||
}
|
}
|
||||||
|
|
||||||
dataspace.getSimpleExtentDims(dimensions.data());
|
dataspace.getSimpleExtentDims(dimensions.data());
|
||||||
data.resize(hdf5_extent_gen<DIMENSIONS>::build(dimensions.data()));
|
data.resize(hdf5_extent_gen<ArrayType::dimensionality>::build(dimensions.data()));
|
||||||
dataset.read(data.data(), datatype);
|
dataset.read(data.data(), datatype);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T, std::size_t DIMENSIONS>
|
template<typename ArrayType>
|
||||||
void hdf5_read_array(H5::CommonFG& fg, const std::string& data_set_name, boost::multi_array<T, DIMENSIONS>& data )
|
void hdf5_read_array(H5::CommonFG& fg, const std::string& data_set_name, ArrayType& data )
|
||||||
{
|
{
|
||||||
|
typedef typename ArrayType::element T;
|
||||||
|
|
||||||
get_hdf5_data_type<T> hdf_data_type;
|
get_hdf5_data_type<T> hdf_data_type;
|
||||||
hdf5_read_array(fg, data_set_name, data, hdf_data_type.type());
|
hdf5_read_array(fg, data_set_name, data, hdf_data_type.type());
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T, std::size_t DIMENSIONS>
|
|
||||||
void hdf5_read_array(H5::CommonFG& fg, const std::string& data_set_name, boost::multi_array<std::complex<T>, DIMENSIONS>& data )
|
|
||||||
{
|
|
||||||
hdf5_read_array(fg, data_set_name, data, hdf5_ComplexType<T>::ctype()->type);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#define CTOOL_HDF5_NAME(STRUCT) BOOST_PP_CAT(hdf5_,STRUCT)
|
#define CTOOL_HDF5_NAME(STRUCT) BOOST_PP_CAT(hdf5_,STRUCT)
|
||||||
#define CTOOL_HDF5_INSERT_ELEMENT(r, STRUCT, element) \
|
#define CTOOL_HDF5_INSERT_ELEMENT(r, STRUCT, element) \
|
||||||
|
Loading…
Reference in New Issue
Block a user