1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
|
#include <string>
#include "H5Include.h"
#include "H5RefCounter.h"
#include "H5Exception.h"
#include "H5IdComponent.h"
#include "H5Idtemplates.h"
#include "H5PropList.h"
#include "H5Object.h"
#include "H5AbstractDs.h"
#include "H5FaccProp.h"
#include "H5FcreatProp.h"
#include "H5DcreatProp.h"
#include "H5DxferProp.h"
#include "H5DataSpace.h"
#include "H5DataSet.h"
#include "H5CommonFG.h"
#include "H5Group.h"
#include "H5File.h"
#include "H5Alltypes.h"
#ifndef H5_NO_NAMESPACE
namespace H5 {
#endif
// Default constructor
Group::Group() : H5Object() {}
// Copy constructor: makes a copy of the original Group object
Group::Group( const Group& original ) : H5Object( original ) {}
// Creates a new group in this group using the common function
// provided in FGtemplates.h.
Group Group::createGroup( const string& name, size_t size_hint )
{
return( createGroup( name.c_str(), size_hint ));
}
Group Group::createGroup( const char* name, size_t size_hint )
{
try {
Group group = createGroupT( id, name, size_hint );
return( group );
}
catch( File_GroupException error )
{
throw GroupIException();
}
}
// Creates a copy of an existing Group using its id
Group::Group( const hid_t group_id ) : H5Object( group_id ) {};
// Opens an existing group in this group using the common function
// provided in FGtemplates.h.
Group Group::openGroup( const string& name )
{
return( openGroup( name.c_str() ));
}
Group Group::openGroup( const char* name )
{
try {
Group group = openGroupT( id, name );
return( group );
}
catch( File_GroupException error )
{
throw GroupIException();
}
}
// Creates a dataset in this group using the common function
// provided in FGtemplates.h
DataSet Group::createDataSet( const string& name, const DataType& data_type, const DataSpace& data_space, const DSetCreatPropList& create_plist )
{
return( createDataSet( name.c_str(), data_type, data_space, create_plist ));
}
DataSet Group::createDataSet( const char* name, const DataType& data_type, const DataSpace& data_space, const DSetCreatPropList& create_plist )
{
try {
DataSet dataset = createDataSetT( id, name, data_type, data_space, create_plist );
return( dataset );
}
catch( File_GroupException error )
{
throw GroupIException();
}
}
// Opens a dataset in this group using the common function
// provided in FGtemplates.h
DataSet Group::openDataSet( const string& name )
{
return( openDataSet( name.c_str() ));
}
DataSet Group::openDataSet( const char* name )
{
try {
DataSet dataset = openDataSetT( id, name );
return( dataset );
}
catch( File_GroupException error )
{
throw GroupIException();
}
}
// This private member function calls the C API H5Topen to open the
// named datatype and returns the datatype's identifier. The function
// is used by the functions openXxxType's below for opening the sub-types
hid_t Group::p_openDataType( const char* name ) const
{
// Call C function H5Topen to open the named datatype in this group,
// giving the group id
hid_t datatype_id = H5Topen( id, name );
// If the datatype id is valid, return it, otherwise, throw an exception.
if( datatype_id > 0 )
return( datatype_id );
else
{
throw GroupIException();
}
}
//
// The following member functions use the private function
// p_openDataType to open a named datatype in this group
//
// Opens the named generic datatype in this group.
DataType Group::openDataType( const string& name ) const
{
return( openDataType( name.c_str()) );
}
DataType Group::openDataType( const char* name ) const
{
DataType data_type( p_openDataType( name ));
return( data_type );
}
// Opens the named enumeration datatype in this group.
EnumType Group::openEnumType( const string& name ) const
{
return( openEnumType( name.c_str()) );
}
EnumType Group::openEnumType( const char* name ) const
{
EnumType enum_type( p_openDataType( name ));
return( enum_type );
}
// Opens the named compound datatype in this group.
CompType Group::openCompType( const string& name ) const
{
return( openCompType( name.c_str()) );
}
CompType Group::openCompType( const char* name ) const
{
CompType comp_type( p_openDataType( name ));
return( comp_type );
}
// Opens the named integer datatype in this group.
IntType Group::openIntType( const string& name ) const
{
return( openIntType( name.c_str()) );
}
IntType Group::openIntType( const char* name ) const
{
IntType int_type( p_openDataType( name ));
return( int_type );
}
// Opens the named floating-point datatype in this group.
FloatType Group::openFloatType( const string& name ) const
{
return( openFloatType( name.c_str()) );
}
FloatType Group::openFloatType( const char* name ) const
{
FloatType float_type( p_openDataType( name ));
return( float_type );
}
// Opens the named string datatype of this group
StrType Group::openStrType( const string& name ) const
{
return( openStrType( name.c_str()) );
}
StrType Group::openStrType( const char* name ) const
{
StrType str_type( p_openDataType( name ));
return( str_type );
}
// Iterates a user's function over the entries of a group.
int Group::iterateElems( const string& name, int *idx, H5G_iterate_t op , void *op_data )
{
return( iterateElems( name.c_str(), idx, op, op_data ));
}
int Group::iterateElems( const char* name, int *idx, H5G_iterate_t op , void *op_data )
{
int ret_value = H5Giterate( id, name, idx, op, op_data );
if( ret_value >= 0 )
return( ret_value );
else // raise exception when H5Aiterate returns a negative value
{
throw GroupIException();
}
}
// Creates a link of the specified type from new_name to current_name;
// both names are interpreted relative to this group.
void Group::link( H5G_link_t link_type, const string& curr_name, const string& new_name )
{
link( link_type, curr_name.c_str(), new_name.c_str() );
}
void Group::link( H5G_link_t link_type, const char* curr_name, const char* new_name )
{
try {
linkT( id, link_type, curr_name, new_name );
}
catch( File_GroupException error )
{
throw GroupIException();
}
}
// Removes the specified name from this group.
void Group::unlink( const string& name )
{
unlink( name.c_str() );
}
void Group::unlink( const char* name )
{
try {
unlinkT( id, name );
}
catch( File_GroupException error )
{
throw GroupIException();
}
}
// Renames an object from this group.
void Group::move( const string& src, const string& dst )
{
move( src.c_str(), dst.c_str() );
}
void Group::move( const char* src, const char* dst )
{
try {
moveT( id, src, dst );
}
catch( File_GroupException error )
{
throw GroupIException();
}
}
// Retrieves information about an object.
void Group::getObjinfo( const string& name, hbool_t follow_link, H5G_stat_t& statbuf )
{
getObjinfo( name.c_str(), follow_link, statbuf );
}
void Group::getObjinfo( const char* name, hbool_t follow_link, H5G_stat_t& statbuf )
{
try {
getObjinfoT( id, name, follow_link, statbuf );
}
catch( File_GroupException error )
{
throw GroupIException();
}
}
// Returns the name of the object that the symbolic link points to.
string Group::getLinkval( const string& name, size_t size )
{
return( getLinkval( name.c_str(), size ));
}
string Group::getLinkval( const char* name, size_t size )
{
try {
string value = getLinkvalT( id, name, size );
return( value );
}
catch( File_GroupException error )
{
throw GroupIException();
}
}
// Sets comment for an object specified by its name.
void Group::setComment( const string& name, const string& comment )
{
setComment( name.c_str(), comment );
}
void Group::setComment( const char* name, const char* comment )
{
try {
setCommentT( id, name, comment );
}
catch( File_GroupException error )
{
throw GroupIException();
}
}
// Retrieves the comment of an object specified by its name
string Group::getComment( const string& name, size_t bufsize )
{
return( getComment( name.c_str(), bufsize ));
}
string Group::getComment( const char* name, size_t bufsize )
{
try {
string comment = getCommentT( id, name, bufsize );
return( comment );
}
catch( File_GroupException error )
{
throw GroupIException();
}
}
// Mounts the file 'child' onto this group.
void Group::mount( const string& name, H5File& child, PropList& plist )
{
mount( name.c_str(), child, plist );
}
void Group::mount( const char* name, H5File& child, PropList& plist )
{
try {
mountT( id, name, child.getId(), plist );
}
catch( File_GroupException error )
{
throw GroupIException();
}
}
// Unmounts the file named 'name' from this parent group.
void Group::unmount( const string& name )
{
unmount( name.c_str() );
}
void Group::unmount( const char* name )
{
try {
unmountT( id, name );
}
catch( File_GroupException error )
{
throw GroupIException();
}
}
// Calls the C API H5Gclose to close this group. Used by IdComponent::reset
void Group::p_close() const
{
herr_t ret_value = H5Gclose( id );
if( ret_value < 0 )
{
throw GroupIException();
}
}
// The destructor of this instance calls IdComponent::reset to
// reset its identifier - no longer true
// Older compilers (baldric) don't support template member functions
// and IdComponent::reset is one; so at this time, the resetId is not
// a member function so it can be template to work around that problem.
Group::~Group()
{
// The group id will be closed properly
resetIdComponent( this );
}
#ifndef H5_NO_NAMESPACE
} // end namespace
#endif
|