6 #ifndef ECHELON_HDF5_SLICE_HPP 7 #define ECHELON_HDF5_SLICE_HPP 9 #include <echelon/hdf5/precursor/dataspace.hpp> 10 #include <echelon/hdf5/precursor/dataset.hpp> 11 #include <echelon/hdf5/storage_layer.hpp> 12 #include <echelon/hdf5/container_adaption.hpp> 13 #include <echelon/hdf5/range.hpp> 14 #include <echelon/hdf5/array_slice.hpp> 30 slice(hdf5::precursor::dataset sliced_dataset_,
31 const std::vector<totally_bound_range_t>& ranges);
45 auto current_shape = shape_adl(source);
47 std::vector<hsize_t> mem_shape(begin(current_shape), end(current_shape));
49 hdf5::precursor::dataspace mem_space(mem_shape);
50 hdf5::precursor::dataspace file_space = selected_dataspace_;
51 hdf5::precursor::type datatype = sliced_dataset_.datatype();
53 write(sliced_dataset_, datatype, mem_space, file_space, source);
67 auto current_shape = shape_adl(sink);
69 std::vector<hsize_t> mem_shape(begin(current_shape), end(current_shape));
71 hdf5::precursor::dataspace mem_space(mem_shape);
72 hdf5::precursor::dataspace file_space = source.selected_dataspace_;
73 hdf5::precursor::type datatype = source.sliced_dataset_.datatype();
75 read(source.sliced_dataset_, datatype, mem_space, file_space, sink);
87 void operator<<=(const array_slice<T>& source)
89 auto current_shape = source.original_shape();
91 std::vector<hsize_t> mem_shape(begin(current_shape), end(current_shape));
93 hdf5::precursor::dataspace mem_space(mem_shape);
94 hdf5::precursor::dataspace file_space = selected_dataspace_;
95 hdf5::precursor::type datatype = sliced_dataset_.datatype();
97 auto slice_shape = source.shape();
98 std::vector<hsize_t> count;
100 for (std::size_t i = 0; i < slice_shape.size(); ++i)
102 count.push_back(slice_shape[i] / source.stride()[i]);
105 mem_space.select_hyperslab(H5S_SELECT_SET, source.offset(), source.stride(), count);
107 write(sliced_dataset_, datatype, mem_space, file_space, source);
118 template <
typename T>
119 friend void operator<<=(const array_slice<T>& sink,
const slice& source)
121 auto current_shape = sink.original_shape();
123 std::vector<hsize_t> mem_shape(begin(current_shape), end(current_shape));
125 hdf5::precursor::dataspace mem_space(mem_shape);
126 hdf5::precursor::dataspace file_space = source.selected_dataspace_;
127 hdf5::precursor::type datatype = source.sliced_dataset_.datatype();
129 auto slice_shape = sink.shape();
130 std::vector<hsize_t> count;
132 for (std::size_t i = 0; i < slice_shape.size(); ++i)
134 count.push_back(slice_shape[i] / sink.stride()[i]);
137 mem_space.select_hyperslab(H5S_SELECT_SET, sink.offset(), sink.stride(), count);
139 read(source.sliced_dataset_, datatype, mem_space, file_space, sink);
144 const std::vector<hsize_t>&
shape()
const;
147 hdf5::precursor::dataset sliced_dataset_;
148 hdf5::precursor::dataspace selected_dataspace_;
150 std::vector<hsize_t> size_;
echelon's core namespace
Definition: attribute.cpp:10
void operator<<=(const T &source)
Writes the content of a data source into the slice.
Definition: hdf5/slice.hpp:43
A slice (rectangular portion) of an HDF5 dataset.
Definition: hdf5/slice.hpp:27
const std::vector< hsize_t > & shape() const
The shape of the slice.
Definition: hdf5/slice.cpp:42
friend void operator<<=(T &sink, const slice &source)
Reads the content of the slice into a data sink.
Definition: hdf5/slice.hpp:65