RMF
Toggle main menu visibility
Group.h
Go to the documentation of this file.
1
/**
2
* \file RMF/HDF5/Group.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_GROUP_H
10
#define RMF_HDF5_GROUP_H
11
12
#include "RMF/config.h"
13
#include "
ConstGroup.h
"
14
#include "
MutableAttributes.h
"
15
16
RMF_ENABLE_WARNINGS
17
18
namespace
RMF
{
19
namespace
HDF5
{
20
21
typedef
MutableAttributes<ConstGroup>
GroupAttributes;
22
#ifndef RMF_DOXYGEN
23
typedef
std::vector<GroupAttributes> GroupAttributesList;
24
#endif
25
26
/** Wrap an HDF5 Group. See
27
\external{https://docs.hdfgroup.org/releases/hdf5/v1_14/v1_14_4/documentation/doxygen/group___h5_g.html,
28
the HDF5 manual} for more information.
29
*/
30
class
RMFEXPORT Group :
public
MutableAttributes<ConstGroup> {
31
typedef
MutableAttributes<ConstGroup> P;
32
friend
class
File;
33
unsigned
int
get_number_of_links()
const
{
34
H5G_info_t info;
35
RMF_HDF5_CALL
(H5Gget_info(get_handle(), &info));
36
unsigned
int
n = info.nlinks;
37
return
n;
38
}
39
#ifndef SWIG
40
protected
:
41
Group(std::shared_ptr<SharedHandle> h);
42
#endif
43
public
:
44
Group() {}
45
#if !defined(RMF_DOXYGEN) && !defined(SWIG)
46
static
Group get_from_const_group(
ConstGroup
g) {
47
return
Group(g.get_shared_handle());
48
}
49
#endif
50
51
RMF_SHOWABLE(Group,
"Group "
<< get_name());
52
53
// create from an existing group
54
Group(Group parent, std::string name);
55
Group add_child_group(std::string name);
56
template
<
class
TypeTraits,
unsigned
int
D>
57
DataSetD<TypeTraits, D>
add_child_data_set(std::string name) {
58
DataSetCreationPropertiesD<TypeTraits, D>
props;
59
return
DataSetD<TypeTraits, D>
(P::get_shared_handle(), name, props);
60
}
61
template
<
class
TypeTraits,
unsigned
int
D>
62
DataSetD<TypeTraits, D>
add_child_data_set(
63
std::string name,
DataSetCreationPropertiesD<TypeTraits, D>
props) {
64
return
DataSetD<TypeTraits, D>
(Object::get_shared_handle(), name, props);
65
}
66
template
<
class
TypeTraits,
unsigned
int
D>
67
DataSetD<TypeTraits, D>
get_child_data_set(std::string name)
const
{
68
DataSetAccessPropertiesD<TypeTraits, D>
props;
69
return
DataSetD<TypeTraits, D>
(Object::get_shared_handle(), name, props);
70
}
71
template
<
class
TypeTraits,
unsigned
int
D>
72
DataSetD<TypeTraits, D>
get_child_data_set(
73
std::string name,
DataSetAccessPropertiesD<TypeTraits, D>
props)
const
{
74
return
DataSetD<TypeTraits, D>
(Object::get_shared_handle(), name, props);
75
}
76
#define RMF_HDF5_DATA_SET_METHODS_D(lcname, UCName, PassValue, ReturnValue, \
77
PassValues, ReturnValues, D) \
78
DataSetD<UCName##Traits, D> get_child_##lcname##_data_set_##D##d( \
79
std::string name, \
80
DataSetAccessPropertiesD<UCName##Traits, D> props) const { \
81
return get_child_data_set<UCName##Traits, D>(name, props); \
82
} \
83
DataSetD<UCName##Traits, D> add_child_##lcname##_data_set_##D##d( \
84
std::string name, DataSetCreationPropertiesD<UCName##Traits, D> props) { \
85
return add_child_data_set<UCName##Traits, D>(name, props); \
86
} \
87
DataSetD<UCName##Traits, D> get_child_##lcname##_data_set_##D##d( \
88
std::string name) const { \
89
DataSetAccessPropertiesD<UCName##Traits, D> props; \
90
return get_child_data_set<UCName##Traits, D>(name, props); \
91
} \
92
DataSetD<UCName##Traits, D> add_child_##lcname##_data_set_##D##d( \
93
std::string name) { \
94
DataSetCreationPropertiesD<UCName##Traits, D> props; \
95
return add_child_data_set<UCName##Traits, D>(name, props); \
96
}
97
98
#define RMF_HDF5_DATA_SET_METHODS(lcname, UCName, PassValue, ReturnValue, \
99
PassValues, ReturnValues) \
100
RMF_HDF5_DATA_SET_METHODS_D(lcname, UCName, PassValue, ReturnValue, \
101
PassValues, ReturnValues, 1); \
102
RMF_HDF5_DATA_SET_METHODS_D(lcname, UCName, PassValue, ReturnValue, \
103
PassValues, ReturnValues, 2); \
104
RMF_HDF5_DATA_SET_METHODS_D(lcname, UCName, PassValue, ReturnValue, \
105
PassValues, ReturnValues, 3)
106
107
/** \name Untemplated methods
108
When using Python, you must call the non-templated methods listed
109
below.
110
@{
111
*/
112
RMF_HDF5_FOREACH_TYPE(RMF_HDF5_DATA_SET_METHODS);
113
/** @} */
114
115
Group get_child_group(
unsigned
int
i)
const
;
116
117
//! get child group with given name without checks
118
//! - verify group exists using get_has_child()
119
//! and that it's a group using get_child_is_group()
120
Group
get_child_group
(std::string name)
const
;
121
};
122
123
}
/* namespace HDF5 */
124
}
/* namespace RMF */
125
126
RMF_DISABLE_WARNINGS
127
128
#endif
/* RMF_HDF5_GROUP_H */
ConstGroup.h
Handle read/write of Model data from/to files.
RMF_HDF5_CALL
#define RMF_HDF5_CALL(v)
Definition
HDF5/infrastructure_macros.h:28
MutableAttributes.h
Handle read/write of Model data from/to files.
RMF::HDF5::ConstGroup
Definition
ConstGroup.h:30
RMF::HDF5::DataSetAccessPropertiesD
Definition
DataSetAccessPropertiesD.h:21
RMF::HDF5::DataSetD
Definition
DataSetD.h:33
RMF::HDF5::Group::get_child_group
Group get_child_group(std::string name) const
RMF::HDF5::MutableAttributes
Definition
MutableAttributes.h:25
RMF::HDF5
The namespace for all HDF5 functionality in the library.
Definition
ConstAttributes.h:21
RMF
The namespace for all functionality in the library.
Definition
BufferConstHandle.h:21
RMF::HDF5::DataSetCreationPropertiesD
Definition
DataSetCreationPropertiesD.h:28