FiberVISH 0.2
Fish - The Fiber Bundle API for the Vish Visualization Shell
H++/H5Group.hpp
1#ifndef __H5_GROUP_HPP
2#define __H5_GROUP_HPP
3
4#include "H5Object.hpp"
5#include "H5DataType.hpp"
6#include "H5Dataset.hpp"
7#include "H5Property.hpp"
8#include "H5File.hpp"
9
10#include <string>
11
12class H5File;
13
17class H5Group : public H5Object
18{
20 H5Group(hid_t src_id);
21
23 H5Object::get_typed_object() const;
24
25
26protected:
27 H5Group() = delete;
28 H5Group(const H5Group&) = delete;
29
30 ~H5Group();
31
32public:
33 H5Group(hid_t ParentGroup, const char*groupname, const refptr<H5GroupAccess>&AP = nullptr);
34
35 H5Group(hid_t ParentGroup, const std::string&groupname, const refptr<H5GroupAccess>&AP = nullptr)
36 : H5Group(ParentGroup, groupname.c_str(), AP)
37 {}
38
39
40 H5Group(const refptr<H5Group>&ParentGroup, const char*groupname, const refptr<H5GroupAccess>&AP = nullptr)
41 : H5Group( ParentGroup?ParentGroup->getHid():H5I_INVALID_HID, groupname, AP)
42 {}
43 H5Group(const refptr<H5Group>&ParentGroup, const std::string&groupname, const refptr<H5GroupAccess>&AP = nullptr)
44 : H5Group( ParentGroup?ParentGroup->getHid():H5I_INVALID_HID, groupname, AP)
45 {}
46
47 H5Group(const refptr<H5File>&ParentGroup, const char*groupname, const refptr<H5GroupAccess>&AP = nullptr)
48 : H5Group( ParentGroup?ParentGroup->getHid():H5I_INVALID_HID, groupname, AP)
49 {}
50
51 H5Group(const refptr<H5File>&ParentGroup, const std::string&groupname, const refptr<H5GroupAccess>&AP = nullptr)
52 : H5Group( ParentGroup?ParentGroup->getHid():H5I_INVALID_HID, groupname, AP)
53 {}
54
55
56
57 struct Create {};
58
59 H5Group(const Create&, hid_t ParentGroup, const char*new_groupname,
60 const refptr<H5LinkCreateProperty >&link_creation_property_list_identifier = nullptr,
61 const refptr<H5GroupCreateProperty>&group_creation_property_list_identifier = nullptr,
62 const refptr<H5GroupAccess>&group_access_property_list_identifier = nullptr);
63
64 H5Group(const Create&C, const refptr<H5Group>&ParentGroup, const char*new_groupname,
65 const refptr<H5LinkCreateProperty >&link_creation_property_list_identifier = nullptr,
66 const refptr<H5GroupCreateProperty>&group_creation_property_list_identifier = nullptr,
67 const refptr<H5GroupAccess>&group_access_property_list_identifier = nullptr)
68 : H5Group(C, ParentGroup?ParentGroup->getHid():H5I_INVALID_HID, new_groupname,
69 link_creation_property_list_identifier ,
70 group_creation_property_list_identifier,
71 group_access_property_list_identifier )
72 {}
73
74 H5Group(const Create&C, const refptr<H5File>&ParentGroup, const char*new_groupname,
75 const refptr<H5LinkCreateProperty >&link_creation_property_list_identifier = nullptr,
76 const refptr<H5GroupCreateProperty>&group_creation_property_list_identifier = nullptr,
77 const refptr<H5GroupAccess>&group_access_property_list_identifier = nullptr)
78 : H5Group(C, ParentGroup?ParentGroup->getHid():H5I_INVALID_HID, new_groupname,
79 link_creation_property_list_identifier ,
80 group_creation_property_list_identifier,
81 group_access_property_list_identifier )
82 {}
83
84
85 H5Group(const Create&C, hid_t ParentGroup, const std::string&new_groupname,
86 const refptr<H5LinkCreateProperty >&link_creation_property_list_identifier = nullptr,
87 const refptr<H5GroupCreateProperty>&group_creation_property_list_identifier = nullptr,
88 const refptr<H5GroupAccess>&group_access_property_list_identifier = nullptr)
89 : H5Group(C, ParentGroup, new_groupname.c_str() ,
90 link_creation_property_list_identifier ,
91 group_creation_property_list_identifier,
92 group_access_property_list_identifier)
93 {}
94
95 H5Group(const Create&C, const refptr<H5Group>&ParentGroup, const std::string&new_groupname,
96 const refptr<H5LinkCreateProperty >&link_creation_property_list_identifier = nullptr,
97 const refptr<H5GroupCreateProperty>&group_creation_property_list_identifier = nullptr,
98 const refptr<H5GroupAccess>&group_access_property_list_identifier = nullptr)
99 : H5Group(C, ParentGroup, new_groupname.c_str() ,
100 link_creation_property_list_identifier ,
101 group_creation_property_list_identifier,
102 group_access_property_list_identifier)
103 {}
104
105 H5Group(const Create&C, const refptr<H5File>&ParentGroup, const std::string&new_groupname,
106 const refptr<H5LinkCreateProperty >&link_creation_property_list_identifier = nullptr,
107 const refptr<H5GroupCreateProperty>&group_creation_property_list_identifier = nullptr,
108 const refptr<H5GroupAccess>&group_access_property_list_identifier = nullptr)
109 : H5Group(C, ParentGroup, new_groupname.c_str() ,
110 link_creation_property_list_identifier ,
111 group_creation_property_list_identifier,
112 group_access_property_list_identifier )
113 {}
114
115
116
117 hsize_t NumberOfEntries() const;
118
119 hsize_t get_nlinks() const
120 {
121 return NumberOfEntries();
122 }
123
133 bool get_group_info(H5G_info_t&group_info) const;
134
136 get_group_info() const
137 {
138 std::pair<bool,H5G_info_t> retval = {false,{} };
139 retval.first = get_group_info(retval.second);
140 return retval;
141 }
142
143 hid_t Dopen_id(const char*datasetname, const refptr<H5DatasetAccess>&AP) const;
144
145 hid_t Dopen_id(const std::string&datasetname, const refptr<H5DatasetAccess>&AP) const
146 {
147 return Dopen_id( datasetname.c_str(), AP );
148 }
149
150 MemCore::RefPtr<H5Group> Gopen(const char*groupname, const refptr<H5GroupAccess>&AP) const;
151
152 refptr<H5Group> Gopen(const std::string&groupname, const refptr<H5GroupAccess>&AP) const
153 {
154 return Gopen( groupname.c_str(), AP);
155 }
156
157 refptr<H5Dataset> Dopen(const char*datasetname, const refptr<H5DatasetAccess>&AP = nullptr) const;
158
159 refptr<H5Dataset> Dopen(const std::string&datasetname, const refptr<H5DatasetAccess>&AP = nullptr) const
160 {
161 return Dopen( datasetname.c_str(), AP );
162 }
163
164 bool isNamedDataType(const char*groupname) const;
165
166 refptr<H5DataType> Topen(const char*groupname) const;
167
168/*
169 class Member
170 {
171 refptr<H5Group> myGroup;
172 std::string myName;
173
174 public:
175 Member(const MemCore::RefPtr<H5Group>&theGroup,
176 const std::string&theName);
177
178 ~Member();
179
180 refptr<H5Object> open();
181 };
182
183 Member create_member(const std::string&name) const;
184*/
185
186
187 struct Iterator
188 {
189 ~Iterator();
190
191 virtual herr_t apply( hid_t loc_id, const char *name, const H5L_info_t *info) = 0;
192
193 herr_t iterate(const H5Group&G, H5_index_t index_type = H5_INDEX_NAME, H5_iter_order_t order = H5_ITER_NATIVE, hsize_t *idx = 0);
194 };
195
196 herr_t traverse(Iterator&It, H5_index_t index_type = H5_INDEX_NAME, H5_iter_order_t order = H5_ITER_NATIVE, hsize_t *idx = 0) const;
197
198
199 using iterator_f = std::function<herr_t(hid_t loc_id, const char *name, const H5L_info2_t *info)>;
200
212 herr_t iterate(const iterator_f&F,
213 H5_index_t index_type = H5_INDEX_NAME, H5_iter_order_t order = H5_ITER_NATIVE, hsize_t *idx = 0) const;
214
215
216 using iterator_f2 = std::function<herr_t(hid_t loc_id, const char *name, const H5L_type_t link_type)>;
217
235 herr_t iterate(const iterator_f2&F,
236 H5_index_t index_type = H5_INDEX_NAME, H5_iter_order_t order = H5_ITER_NATIVE, hsize_t *idx = 0) const;
237
238
243 herr_t rename(const std::string&src, const std::string&dst) const;
244
249static herr_t remove( hid_t loc_id, const char *name);
250static herr_t remove( hid_t loc_id, const std::string&name)
251 {
252 return remove( loc_id, name.c_str());
253 }
254
255 herr_t remove( const char *name) const
256 {
257 return remove( getHid(), name);
258 }
259
260 herr_t remove(const std::string&name) const
261 {
262 return remove( name.c_str());
263 }
264
268static herr_t create_external(const std::string&link_destination_filename,
269 const std::string&link_destination_object_name,
270 hid_t loc_id,
271 const std::string&link_name,
272 hid_t lcpl_id,
273 hid_t lapl_id);
274
275
279 herr_t create_external(const std::string&link_destination_filename,
280 const std::string&link_destination_object_name,
281 const std::string&link_name,
282 hid_t lcpl_id,
283 hid_t lapl_id)
284 const
285 {
286 return create_external(link_destination_filename,
287 link_destination_object_name,
288 getHid(),
289 link_name,
290 lcpl_id,
291 lapl_id);
292
293 }
294
298static herr_t create_external(const std::string&link_destination_filename,
299 const std::string&link_destination_object_name,
300 hid_t loc_id,
301 const std::string&link_name,
302 const refptr<H5LinkCreateProperty>&lcpl = nullptr,
303 const refptr<H5ExternalLinkAccess>&lapl = nullptr)
304 {
305 return create_external(link_destination_filename,
306 link_destination_object_name,
307 loc_id,
308 link_name,
309 H5Property::getId( lcpl ),
310 H5Property::getId( lapl ) );
311 }
312
313
317 herr_t create_external(const std::string&link_destination_filename,
318 const std::string&link_destination_object_name,
319 const std::string&link_name,
320 const refptr<H5LinkCreateProperty>&lcpl = nullptr,
321 const refptr<H5ExternalLinkAccess>&lapl = nullptr)
322 {
323 return create_external(link_destination_filename,
324 link_destination_object_name,
325 getHid(),
326 link_name,
327 H5Property::getId( lcpl ),
328 H5Property::getId( lapl ) );
329 }
330};
331
332
333#endif // __H5_GROUP_HPP
Definition H++/H5File.hpp:13
A group within an HDF5 file.
Definition H++/H5Group.hpp:18
static herr_t remove(hid_t loc_id, const char *name)
Delete an entry from a group.
Definition H++/H5Group.cpp:205
herr_t iterate(const iterator_f &F, H5_index_t index_type=H5_INDEX_NAME, H5_iter_order_t order=H5_ITER_NATIVE, hsize_t *idx=0) const
Allow for lambda iterator:
Definition H++/H5Group.cpp:168
herr_t create_external(const std::string &link_destination_filename, const std::string &link_destination_object_name, const std::string &link_name, const refptr< H5LinkCreateProperty > &lcpl=nullptr, const refptr< H5ExternalLinkAccess > &lapl=nullptr)
Create an external link in this group.
Definition H++/H5Group.hpp:317
bool get_group_info(H5G_info_t &group_info) const
Get info about a group, which is part of H5G_info_t :
Definition H++/H5Group.cpp:66
herr_t rename(const std::string &src, const std::string &dst) const
Rename a member within the same group.
Definition H++/H5Group.cpp:141
static herr_t create_external(const std::string &link_destination_filename, const std::string &link_destination_object_name, hid_t loc_id, const std::string &link_name, hid_t lcpl_id, hid_t lapl_id)
Calls H5Lcreate_external()
Definition H++/H5Group.cpp:210
herr_t create_external(const std::string &link_destination_filename, const std::string &link_destination_object_name, const std::string &link_name, hid_t lcpl_id, hid_t lapl_id) const
Create an external link in this group.
Definition H++/H5Group.hpp:279
static herr_t create_external(const std::string &link_destination_filename, const std::string &link_destination_object_name, hid_t loc_id, const std::string &link_name, const refptr< H5LinkCreateProperty > &lcpl=nullptr, const refptr< H5ExternalLinkAccess > &lapl=nullptr)
Create an external link in the group specified by loc_id .
Definition H++/H5Group.hpp:298
Base class for groups, datasets and named datatypes.
Definition H++/H5Object.hpp:122
static hid_t getId(const refptr< H5Property > &P)
Return the associated HDF5 ID if this is a valid pointer, otherwise return H5P_DEFAULT .
Definition H++/H5Group.hpp:57
Definition H++/H5Group.hpp:188