9 #ifndef RMF_HDF5_MUTABLE_ATTRIBUTES_H
10 #define RMF_HDF5_MUTABLE_ATTRIBUTES_H
12 #include "RMF/config.h"
33 template <
class A,
class B>
36 template <
class A,
class B,
class C>
39 template <
class A,
class B,
class C,
class D>
52 template <
class TypeTraits>
53 void set_attribute(std::string name,
typename TypeTraits::Types value) {
55 if (H5Aexists(P::get_handle(), name.c_str())) {
59 bool missing = !H5Aexists(P::get_handle(), name.c_str());
64 H5Aopen(P::get_handle(), name.c_str(), H5P_DEFAULT),
66 RMF_HDF5_HANDLE(s, H5Aget_space(a), &H5Sclose);
69 if (value.size() != dim) {
75 RMF_HDF5_HANDLE(s, H5Screate(H5S_SIMPLE), &H5Sclose);
76 hsize_t dim = std::max(value.size(), size_t(1));
77 hsize_t max = H5S_UNLIMITED;
79 RMF_HDF5_HANDLE(a, H5Acreate2(P::get_handle(), name.c_str(),
80 TypeTraits::get_hdf5_disk_type(), s,
81 H5P_DEFAULT, H5P_DEFAULT),
84 RMF_HDF5_HANDLE(a, H5Aopen(P::get_handle(), name.c_str(), H5P_DEFAULT),
86 TypeTraits::write_values_attribute(a, value);
96 #define RMF_HDF5_ATTRIBUTE(lcname, UCName, PassValue, ReturnValue, PassValues, \
98 void set_##lcname##_attribute(std::string nm, PassValues value) { \
99 set_attribute<UCName##Traits>(nm, value); \
103 RMF_HDF5_ATTRIBUTE(
char,
Char,
char,
char, std::string, std::string);
Various general useful macros for IMP.
Handle read/write of Model data from/to files.
Include all non-deprecated headers in RMF.HDF5.
#define RMF_FOREACH_SIMPLE_TYPE(macroname)