9 #ifndef H5PROPERTY_LIST_MISC_HPP
10 #define H5PROPERTY_LIST_MISC_HPP
12 #include <H5Ppublic.h>
17 inline hid_t convert_plist_type(
PropertyType propertyType) {
20 switch (propertyType) {
22 return H5P_OBJECT_CREATE;
24 return H5P_FILE_CREATE;
26 return H5P_FILE_ACCESS;
28 return H5P_DATASET_CREATE;
30 return H5P_DATASET_ACCESS;
32 return H5P_DATASET_XFER;
34 return H5P_GROUP_CREATE;
36 return H5P_GROUP_ACCESS;
38 return H5P_DATATYPE_CREATE;
40 return H5P_DATATYPE_ACCESS;
42 return H5P_STRING_CREATE;
44 return H5P_ATTRIBUTE_CREATE;
46 return H5P_OBJECT_COPY;
48 return H5P_LINK_CREATE;
50 return H5P_LINK_ACCESS;
52 HDF5ErrMapper::ToException<PropertyException>(
53 "Unsupported property list type");
59 template <PropertyType T>
61 : _hid(H5P_DEFAULT) {}
63 template <PropertyType T>
66 other._hid = H5P_DEFAULT;
69 template <PropertyType T>
72 const auto hid = other.
_hid;
73 other._hid = H5P_DEFAULT;
78 template <PropertyType T>
81 if (_hid != H5P_DEFAULT) {
86 template <PropertyType T>
88 if (_hid != H5P_DEFAULT) {
91 if ((_hid = H5Pcreate(convert_plist_type(T))) < 0) {
92 HDF5ErrMapper::ToException<PropertyException>(
93 "Unable to create property list");
97 template <PropertyType T>
100 _initializeIfNeeded();
101 property.apply(_hid);
104 template <PropertyType T>
105 template <
typename F,
typename... Args>
107 this->_initializeIfNeeded();
108 if (funct(this->_hid, args...) < 0) {
109 HDF5ErrMapper::ToException<PropertyException>(
110 "Error setting raw hdf5 property.");
114 inline void Chunking::apply(
const hid_t hid)
const {
115 if (H5Pset_chunk(hid,
static_cast<int>(_dims.size()), _dims.data()) < 0) {
116 HDF5ErrMapper::ToException<PropertyException>(
117 "Error setting chunk property");
121 inline void Deflate::apply(
const hid_t hid)
const {
122 if (!H5Zfilter_avail(H5Z_FILTER_DEFLATE)) {
123 HDF5ErrMapper::ToException<PropertyException>(
124 "Error setting deflate property");
127 if (H5Pset_deflate(hid, _level) < 0) {
128 HDF5ErrMapper::ToException<PropertyException>(
129 "Error setting deflate property");
133 inline void Shuffle::apply(
const hid_t hid)
const {
134 if (!H5Zfilter_avail(H5Z_FILTER_SHUFFLE)) {
135 HDF5ErrMapper::ToException<PropertyException>(
136 "Error setting shuffle property");
139 if (H5Pset_shuffle(hid) < 0) {
140 HDF5ErrMapper::ToException<PropertyException>(
141 "Error setting shuffle property");
145 inline void Caching::apply(
const hid_t hid)
const {
146 if (H5Pset_chunk_cache(hid, _numSlots, _cacheSize, _w0) < 0) {
147 HDF5ErrMapper::ToException<PropertyException>(
148 "Error setting dataset cache parameters");
154 #endif // H5PROPERTY_LIST_HPP