RMF
DataSetCreationPropertiesD.h
Go to the documentation of this file.
1/**
2 * \file RMF/HDF5/DataSetCreationPropertiesD.h
3 * \brief Handle read/write of Model data from/to files.
4 *
5 * Copyright 2007-2022 IMP Inventors. All rights reserved.
6 *
7 */
8
9#ifndef RMF_HDF5_DATA_SET_CREATION_PROPERTIES_D_H
10#define RMF_HDF5_DATA_SET_CREATION_PROPERTIES_D_H
11
12#include "RMF/config.h"
14
15RMF_ENABLE_WARNINGS namespace RMF {
16 namespace HDF5 {
17
18 /** Data sets can be compressed using one of several algorithms.
19 */
21 GZIP_COMPRESSION,
22 SLIB_COMPRESSION,
23 NO_COMPRESSION
24 };
25
26 /** Define properties for creating an HDF5 data set.*/
27 template <class TypeTraits, unsigned int D>
28 struct DataSetCreationPropertiesD : DataSetAccessPropertiesD<TypeTraits, D> {
29
30 using DataSetAccessPropertiesD<TypeTraits, D>::get_handle;
31 void set_compression(Compression comp) {
32 if (comp == GZIP_COMPRESSION) {
33 RMF_HDF5_CALL(H5Pset_deflate(get_handle(), 9));
34 } else if (comp == SLIB_COMPRESSION) {
35 RMF_HDF5_CALL(H5Pset_szip(get_handle(), H5_SZIP_NN_OPTION_MASK, 32));
36 }
37 }
38 /** See
39 \external{https://docs.hdfgroup.org/releases/hdf5/v1_14/v1_14_4/documentation/doxygen/group___d_c_p_l.html#ga3584d592e377da3604b7604e266dcf5b,
40 H5Pset_chunk}
41 */
43 hsize_t cdims[D];
44 for (unsigned int i = 0; i < D; ++i) {
45 cdims[i] = chunk_size[i];
46 }
47 RMF_HDF5_CALL(H5Pset_chunk(get_handle(), D, cdims));
48 }
50 : DataSetAccessPropertiesD<TypeTraits, D>(H5P_DATASET_CREATE) {
51 hsize_t cdims[D];
52 cdims[0] = 512;
53 if (D > 2) {
54 std::fill(cdims + 1, cdims + D - 1, 4);
55 }
56 if (D > 1) {
57 cdims[D - 1] = 1;
58 }
59 RMF_HDF5_CALL(H5Pset_chunk(get_handle(), D, cdims));
60 RMF_HDF5_CALL(H5Pset_fill_value(get_handle(),
61 TypeTraits::get_hdf5_fill_type(),
62 &TypeTraits::get_fill_value()));
63 RMF_HDF5_CALL(H5Pset_fill_time(get_handle(), H5D_FILL_TIME_ALLOC));
64 RMF_HDF5_CALL(H5Pset_alloc_time(get_handle(), H5D_ALLOC_TIME_INCR));
65 }
66
67 //! Sets custom fill value instead of the default one
68 /** Sets custom fill value instead of the default one, which
69 is used as a default value for dataset entries that were not
70 written explicitly
71 (see HDF5 documentation for more details about fill values)
72
73 @param pValue a pointer to the fill value
74 */
75 void set_custom_fill_value(typename TypeTraits::Type* pValue){
76 RMF_HDF5_CALL(H5Pset_fill_value(get_handle(),
77 TypeTraits::get_hdf5_fill_type(),
78 pValue)
79 );
80 }
81 };
82
83 } /* namespace HDF5 */
84} /* namespace RMF */
85
86RMF_DISABLE_WARNINGS
87
88#endif /* RMF_HDF5_DATA_SET_CREATION_PROPERTIES_D_H */
Handle read/write of Model data from/to files.
#define RMF_HDF5_CALL(v)
The namespace for all HDF5 functionality in the library.
The namespace for all functionality in the library.
void set_chunk_size(DataSetIndexD< D > chunk_size)
void set_custom_fill_value(typename TypeTraits::Type *pValue)
Sets custom fill value instead of the default one.