9 #ifndef RMF_HDF5_DATA_SET_D_H
10 #define RMF_HDF5_DATA_SET_D_H
12 #include "RMF/config.h"
32 template <
class TypeTraits,
unsigned int D>
41 DataSetD(std::shared_ptr<SharedHandle> parent, std::string name,
43 :
P(parent, name, props) {}
44 DataSetD(std::shared_ptr<SharedHandle> parent, std::string name,
46 :
P(parent, name, props) {}
49 #if !defined(SWIG) && !defined(RMF_DOXYGEN)
51 :
P(file, name, props) {}
56 void set_value(
const DataSetIndexD<D>& ijk,
typename TypeTraits::Type value) {
57 RMF_IF_CHECK { P::check_index(ijk); }
59 RMF_HDF5_CALL(H5Sselect_hyperslab(P::get_data_space(), H5S_SELECT_SET,
60 ijk.get(), P::get_ones(), P::get_ones(),
62 TypeTraits::write_value_dataset(Object::get_handle(),
63 P::get_input_data_space().get_hid(),
64 P::get_data_space(), value);
66 RMF_SHOWABLE(
DataSetD,
"DataSet" << D <<
"D " << P::get_name());
69 void set_row(
const RowIndex& ijkr,
const typename TypeTraits::Types& value) {
71 std::copy(ijkr.begin(), ijkr.end(), ijk.begin());
73 RMF_IF_CHECK { P::check_index(ijk); }
75 std::fill(size, size + D - 1, 1);
76 size[D - 1] = P::get_size()[D - 1];
78 RMF_HDF5_CALL(H5Sselect_hyperslab(P::get_data_space(), H5S_SELECT_SET,
79 ijk.get(), P::get_ones(), &size[0],
81 TypeTraits::write_values_dataset(Object::get_handle(),
82 P::get_row_data_space().get_hid(),
83 P::get_data_space(), value);
88 const typename TypeTraits::Types& value) {
93 unsigned int total = 1;
94 for (
unsigned int i = 0; i < D; ++i) {
96 last[i] += size[i] - 1;
98 RMF_USAGE_CHECK(total == value.size(),
99 RMF::internal::get_error_message(
100 "Block has size ", total,
" but found ", value.size(),
102 P::check_index(last);
105 RMF_HDF5_CALL(H5Sselect_hyperslab(P::get_data_space(), H5S_SELECT_SET,
106 lb.get(), P::get_ones(), size.get(),
108 hsize_t sz = value.size();
109 RMF_HDF5_HANDLE(input, H5Screate_simple(1, &sz,
nullptr), &H5Sclose);
110 TypeTraits::write_values_dataset(Object::get_handle(), input,
111 P::get_data_space(), value);
115 std::copy(ijk.begin(), ijk.end(), nd);
118 P::initialize_handles();
124 #define RMF_HDF5_DECLARE_DATA_SET(lcname, Ucname, PassValue, ReturnValue, \
125 PassValues, ReturnValues) \
126 typedef DataSetD<Ucname##Traits, 1> Ucname##DataSet1D; \
127 typedef std::vector<Ucname##DataSet1D> Ucname##DataSet1Ds; \
128 typedef DataSetD<Ucname##Traits, 2> Ucname##DataSet2D; \
129 typedef std::vector<Ucname##DataSet2D> Ucname##DataSet2Ds; \
130 typedef DataSetD<Ucname##Traits, 3> Ucname##DataSet3D; \
131 typedef std::vector<Ucname##DataSet3D> Ucname##DataSet3Ds; \
132 typedef MutableAttributes<Ucname##DataSet1D> Ucname##DataSet1DAttributes; \
133 typedef MutableAttributes<Ucname##DataSet2D> Ucname##DataSet2DAttributes; \
134 typedef MutableAttributes<Ucname##DataSet3D> Ucname##DataSet3DAttributes; \
135 typedef std::vector<Ucname##DataSet1DAttributes> \
136 Ucname##DataSet1DAttributesList; \
137 typedef std::vector<Ucname##DataSet2DAttributes> \
138 Ucname##DataSet2DAttributesList; \
139 typedef std::vector<Ucname##DataSet3DAttributes> \
140 Ucname##DataSet3DAttributesList
146 RMF_HDF5_FOREACH_TYPE(RMF_HDF5_DECLARE_DATA_SET);
Handle read/write of Model data from/to files.
Various general useful macros for IMP.
Handle read/write of Model data from/to files.
void set_block(const Index &lb, const Index &size, const typename TypeTraits::Types &value)
Write a rectangular block starting at ln of size size.
Handle read/write of Model data from/to files.
Handle read/write of Model data from/to files.