Moved extent generator definition up
This commit is contained in:
parent
bf0be4fb61
commit
03fce51182
@ -90,10 +90,31 @@ namespace CosmoTool {
|
||||
|
||||
#undef HDF5_TYPE
|
||||
|
||||
// Extent generator
|
||||
template<std::size_t r>
|
||||
struct hdf5_extent_gen {
|
||||
typedef typename boost::detail::multi_array::extent_gen<r> type;
|
||||
|
||||
static inline type build(hsize_t *d)
|
||||
{
|
||||
return (hdf5_extent_gen<r-1>::build(d))[d[r-1]];
|
||||
}
|
||||
};
|
||||
|
||||
template<>
|
||||
struct hdf5_extent_gen<0> {
|
||||
static inline boost::multi_array_types::extent_gen build(hsize_t *d)
|
||||
{
|
||||
return boost::extents;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
//!_______________________________________________________________________________________
|
||||
//!
|
||||
//! write_hdf5 multi_array
|
||||
//!
|
||||
//! \author Guilhem Lavaux (2014-2015)
|
||||
//! \author leo Goodstadt (04 March 2013)
|
||||
//!
|
||||
//!_______________________________________________________________________________________
|
||||
@ -214,24 +235,11 @@ namespace CosmoTool {
|
||||
class InvalidDimensions: virtual std::exception {
|
||||
};
|
||||
|
||||
template<std::size_t r>
|
||||
struct hdf5_extent_gen {
|
||||
typedef typename boost::detail::multi_array::extent_gen<r> type;
|
||||
|
||||
static inline type build(hsize_t *d)
|
||||
{
|
||||
return (hdf5_extent_gen<r-1>::build(d))[d[r-1]];
|
||||
}
|
||||
};
|
||||
|
||||
template<>
|
||||
struct hdf5_extent_gen<0> {
|
||||
static inline boost::multi_array_types::extent_gen build(hsize_t *d)
|
||||
{
|
||||
return boost::extents;
|
||||
}
|
||||
};
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// Conditional resize support
|
||||
// If the Array type support resize then it is called. Otherwise
|
||||
// the dimensions are checked and lead to a failure if they are different
|
||||
|
||||
template<typename Array> class array_has_resize {
|
||||
struct Fallback { int resize; };
|
||||
@ -281,10 +289,12 @@ namespace CosmoTool {
|
||||
hdf5_check_array(data, dims);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
template<typename ArrayType, typename hdf5_data_type>
|
||||
void hdf5_read_array_typed(H5::CommonFG& fg, const std::string& data_set_name,
|
||||
ArrayType& data,
|
||||
const hdf5_data_type& datatype, bool auto_resize = true)
|
||||
ArrayType& data,
|
||||
const hdf5_data_type& datatype, bool auto_resize = true)
|
||||
{
|
||||
H5::DataSet dataset = fg.openDataSet(data_set_name);
|
||||
H5::DataSpace dataspace = dataset.getSpace();
|
||||
@ -309,8 +319,7 @@ namespace CosmoTool {
|
||||
{
|
||||
typedef typename ArrayType::element T;
|
||||
|
||||
get_hdf5_data_type<T> hdf_data_type;
|
||||
hdf5_read_array_typed(fg, data_set_name, data, hdf_data_type.type(), auto_resize);
|
||||
hdf5_read_array_typed(fg, data_set_name, data, get_hdf5_data_type<T>::type(), auto_resize);
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user