RMF
Toggle main menu visibility
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"
13
#include "
DataSetAccessPropertiesD.h
"
14
15
RMF_ENABLE_WARNINGS
namespace
RMF
{
16
namespace
HDF5
{
17
18
/** Data sets can be compressed using one of several algorithms.
19
*/
20
enum
Compression
{
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
*/
42
void
set_chunk_size
(
DataSetIndexD<D>
chunk_size) {
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
}
49
DataSetCreationPropertiesD
()
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
86
RMF_DISABLE_WARNINGS
87
88
#endif
/* RMF_HDF5_DATA_SET_CREATION_PROPERTIES_D_H */
DataSetAccessPropertiesD.h
Handle read/write of Model data from/to files.
RMF_HDF5_CALL
#define RMF_HDF5_CALL(v)
Definition
HDF5/infrastructure_macros.h:28
RMF::HDF5::DataSetAccessPropertiesD
Definition
DataSetAccessPropertiesD.h:21
RMF::HDF5::DataSetIndexD
Definition
DataSetIndexD.h:26
RMF::HDF5
The namespace for all HDF5 functionality in the library.
Definition
ConstAttributes.h:21
RMF::HDF5::Compression
Compression
Definition
DataSetCreationPropertiesD.h:20
RMF
The namespace for all functionality in the library.
Definition
BufferConstHandle.h:21
RMF::HDF5::DataSetCreationPropertiesD
Definition
DataSetCreationPropertiesD.h:28
RMF::HDF5::DataSetCreationPropertiesD::set_chunk_size
void set_chunk_size(DataSetIndexD< D > chunk_size)
Definition
DataSetCreationPropertiesD.h:42
RMF::HDF5::DataSetCreationPropertiesD::set_custom_fill_value
void set_custom_fill_value(typename TypeTraits::Type *pValue)
Sets custom fill value instead of the default one.
Definition
DataSetCreationPropertiesD.h:75