25class MutableAttributes :
public Base {
29 MutableAttributes() {}
31 MutableAttributes(
const A& h)
33 template <
class A,
class B>
34 MutableAttributes(
const A& h,
const B& i)
36 template <
class A,
class B,
class C>
37 MutableAttributes(
const A& h,
const B& i,
const C& j)
39 template <
class A,
class B,
class C,
class D>
40 MutableAttributes(
const A& h,
const B& i,
const C& j,
const D& k)
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);