1
15
16 #include <H5Tpublic.h>
17 #include <H5Dpublic.h>
18 #include <H5Gpublic.h>
19 #include <H5Spublic.h>
20 #include <H5Ppublic.h>
21 #include "mhdf.h"
22 #include "util.h"
23 #include "file-handle.h"
24 #include "status.h"
25 #include "names-and-paths.h"
26
27 int mhdf_haveSets( mhdf_FileHandle file, int* have_data, int* have_child, int* have_parent, mhdf_Status* status )
28 {
29 FileHandle* file_ptr = (FileHandle*)file;
30 hid_t root_id, set_id;
31 int result;
32 API_BEGIN;
33
34 if( !mhdf_check_valid_file( file_ptr, status ) ) return -1;
35
36 #if defined( H5Gopen_vers ) && H5Gopen_vers > 1
37 root_id = H5Gopen2( file_ptr->hdf_handle, ROOT_GROUP, H5P_DEFAULT );
38 #else
39 root_id = H5Gopen( file_ptr->hdf_handle, ROOT_GROUP );
40 #endif
41 if( root_id < 0 )
42 {
43 mhdf_setFail( status, "H5Gopen( \"%s\" ) failed.", ROOT_GROUP );
44 return -1;
45 }
46
47 result = mhdf_is_in_group( root_id, SET_GROUP_NAME, status );
48 if( result < 1 )
49 {
50 H5Gclose( root_id );
51 return result;
52 }
53
54 #if defined( H5Gopen_vers ) && H5Gopen_vers > 1
55 set_id = H5Gopen2( root_id, SET_GROUP_NAME, H5P_DEFAULT );
56 #else
57 set_id = H5Gopen( root_id, SET_GROUP_NAME );
58 #endif
59 H5Gclose( root_id );
60 if( set_id < 0 )
61 {
62 mhdf_setFail( status, "H5Gopen( \"%s\" ) failed.", SET_GROUP );
63 return -1;
64 }
65
66 result = mhdf_is_in_group( set_id, SET_META_NAME, status );
67 if( result < 0 )
68 {
69 H5Gclose( set_id );
70 return result;
71 }
72
73 if( have_data )
74 {
75 *have_data = mhdf_is_in_group( set_id, SET_DATA_NAME, status );
76 if( *have_data < 0 )
77 {
78 H5Gclose( set_id );
79 return *have_data;
80 }
81 }
82
83 if( have_child )
84 {
85 *have_child = mhdf_is_in_group( set_id, SET_CHILD_NAME, status );
86 if( *have_child < 0 )
87 {
88 H5Gclose( set_id );
89 return *have_child;
90 }
91 }
92
93 if( have_parent )
94 {
95 *have_parent = mhdf_is_in_group( set_id, SET_PARENT_NAME, status );
96 if( *have_parent < 0 )
97 {
98 H5Gclose( set_id );
99 return *have_parent;
100 }
101 }
102
103 mhdf_setOkay( status );
104 H5Gclose( set_id );
105 API_END;
106 return result;
107 }
108
109 hid_t mhdf_createSetMeta( mhdf_FileHandle file, long num_sets, long* first_id_out, mhdf_Status* status )
110 {
111 FileHandle* file_ptr = (FileHandle*)file;
112 hid_t table_id;
113 hsize_t dims[2];
114 long first_id;
115 API_BEGIN;
116
117 if( !mhdf_check_valid_file( file_ptr, status ) ) return -1;
118
119 dims[0] = (hsize_t)num_sets;
120 dims[1] = (hsize_t)4;
121 table_id = mhdf_create_table( file_ptr->hdf_handle, SET_META_PATH, MHDF_INDEX_TYPE, 2, dims, status );
122 if( table_id < 0 ) return -1;
123
124 first_id = file_ptr->max_id + 1;
125 if( !mhdf_create_scalar_attrib( table_id, START_ID_ATTRIB, H5T_NATIVE_LONG, &first_id, status ) )
126 {
127 H5Dclose( table_id );
128 return -1;
129 }
130
131 *first_id_out = first_id;
132 file_ptr->max_id += num_sets;
133 if( !mhdf_write_max_id( file_ptr, status ) )
134 {
135 H5Dclose( table_id );
136 return -1;
137 }
138 file_ptr->open_handle_count++;
139 mhdf_setOkay( status );
140
141 API_END_H( 1 );
142 return table_id;
143 }
144
145 hid_t mhdf_openSetMeta( mhdf_FileHandle file, long* num_sets, long* first_id_out, mhdf_Status* status )
146 {
147 FileHandle* file_ptr = (FileHandle*)file;
148 hid_t table_id;
149 hsize_t dims[2];
150 API_BEGIN;
151
152 if( !mhdf_check_valid_file( file_ptr, status ) ) return -1;
153
154 table_id = mhdf_open_table2( file_ptr->hdf_handle, SET_META_PATH, 2, dims, first_id_out, status );
155 if( table_id < 0 ) return -1;
156
157
160 if( dims[1] != 4 && dims[1] != 3 )
161 {
162 mhdf_setFail( status, "Invalid format for meshset table.\n" );
163 H5Dclose( table_id );
164 return -1;
165 }
166
167 *num_sets = dims[0];
168 file_ptr->open_handle_count++;
169 mhdf_setOkay( status );
170 API_END_H( 1 );
171 return table_id;
172 }
173
174 hid_t mhdf_openSetMetaSimple( mhdf_FileHandle file, mhdf_Status* status )
175 {
176 FileHandle* file_ptr = (FileHandle*)file;
177 hid_t table_id;
178 API_BEGIN;
179
180 if( !mhdf_check_valid_file( file_ptr, status ) ) return -1;
181
182 table_id = mhdf_open_table_simple( file_ptr->hdf_handle, SET_META_PATH, status );
183 if( table_id < 0 ) return -1;
184
185 file_ptr->open_handle_count++;
186 mhdf_setOkay( status );
187 API_END_H( 1 );
188 return table_id;
189 }
190
191 static int mhdf_readwriteSetMeta( hid_t table_id,
192 int read,
193 long offset,
194 long count,
195 hid_t type,
196 void* data,
197 hid_t prop,
198 mhdf_Status* status )
199 {
200 hid_t slab_id, sslab_id, smem_id, mem_id;
201 hsize_t offsets[2], counts[2], mcounts[2], moffsets[2] = { 0, 0 };
202 herr_t rval = 0;
203 int dims, i;
204 const int fill_val = -1;
205 const hsize_t one = 1;
206
207 mcounts[0] = count;
208 mcounts[1] = 4;
209 if( offset < 0 || count < 0 )
210 {
211 mhdf_setFail( status,
212 "Invalid input for %s: "
213 "offset = %ld, count = %ld\n",
214 read ? "read" : "write", offset, count );
215 return 0;
216 }
217
218 slab_id = H5Dget_space( table_id );
219 if( slab_id < 0 )
220 {
221 mhdf_setFail( status, "Internal error calling H5Dget_space." );
222 return 0;
223 }
224
225 dims = H5Sget_simple_extent_ndims( slab_id );
226 if( dims != 2 )
227 {
228 H5Sclose( slab_id );
229 mhdf_setFail( status, "Internal error: unexpected dataset rank: %d.", dims );
230 return 0;
231 }
232
233 dims = H5Sget_simple_extent_dims( slab_id, counts, NULL );
234 if( dims < 0 )
235 {
236 H5Sclose( slab_id );
237 mhdf_setFail( status, "Internal error calling H5Sget_simple_extend_dims." );
238 return 0;
239 }
240
241 if( (unsigned long)( offset + count ) > counts[0] )
242 {
243 H5Sclose( slab_id );
244 mhdf_setFail( status, "Requested %s of rows %ld to %ld of a %ld row table.\n", read ? "read" : "write", offset,
245 offset + count - 1, (long)counts[dims - 1] );
246 return 0;
247 }
248 counts[0] = (hsize_t)count;
249 offsets[0] = (hsize_t)offset;
250
251 if( count )
252 mem_id = H5Screate_simple( dims, mcounts, NULL );
253 else
254 {
255 mem_id = H5Screate_simple( 1, &one, NULL );
256 if( mem_id && 0 > H5Sselect_none( mem_id ) )
257 {
258 H5Sclose( mem_id );
259 mem_id = -1;
260 }
261 }
262 if( mem_id < 0 )
263 {
264 mhdf_setFail( status, "Internal error calling H5Screate_simple." );
265 return 0;
266 }
267
268
269 if( counts[1] == 4 )
270 {
271 offsets[1] = 0;
272 if( count )
273 rval = H5Sselect_hyperslab( slab_id, H5S_SELECT_SET, offsets, NULL, counts, NULL );
274 else
275 rval = H5Sselect_none( slab_id );
276 if( rval < 0 )
277 {
278 H5Sclose( mem_id );
279 H5Sclose( slab_id );
280 mhdf_setFail( status, "Internal error calling H5Sselect_hyperslab." );
281 return 0;
282 }
283
284 if( read )
285 rval = H5Dread( table_id, type, mem_id, slab_id, prop, data );
286 else
287 rval = H5Dwrite( table_id, type, mem_id, slab_id, prop, data );
288 }
289
290 else if( counts[1] == 3 )
291 {
292 rval = 0;
293 for( i = 0; i < 3 && rval >= 0; ++i )
294 {
295 smem_id = H5Scopy( mem_id );
296 sslab_id = H5Scopy( slab_id );
297 if( smem_id < 0 || sslab_id < 0 )
298 {
299 if( smem_id >= 0 ) H5Sclose( smem_id );
300 mhdf_setFail( status, "Internal error calling H5Scopy." );
301 return 0;
302 }
303
304 counts[1] = 1;
305 offsets[1] = i;
306 if( count )
307 rval = H5Sselect_hyperslab( sslab_id, H5S_SELECT_SET, offsets, NULL, counts, NULL );
308 else
309 rval = H5Sselect_none( sslab_id );
310 if( rval < 0 )
311 {
312 H5Sclose( slab_id );
313 H5Sclose( mem_id );
314 mhdf_setFail( status, "Internal error calling H5Sselect_hyperslab." );
315 return 0;
316 }
317
318 mcounts[1] = 1;
319 moffsets[1] = ( i == 2 ) ? 3 : i;
320 rval = H5Sselect_hyperslab( smem_id, H5S_SELECT_SET, moffsets, NULL, mcounts, NULL );
321 if( rval < 0 )
322 {
323 H5Sclose( sslab_id );
324 H5Sclose( slab_id );
325 H5Sclose( mem_id );
326 mhdf_setFail( status, "Internal error calling H5Sselect_hyperslab." );
327 return 0;
328 }
329
330 if( read )
331 rval = H5Dread( table_id, type, smem_id, sslab_id, prop, data );
332 else
333 rval = H5Dwrite( table_id, type, smem_id, sslab_id, prop, data );
334
335 H5Sclose( sslab_id );
336 H5Sclose( smem_id );
337 }
338
339 if( read && rval >= 0 )
340 {
341 mcounts[1] = 1;
342 moffsets[1] = 2;
343 H5Sselect_hyperslab( mem_id, H5S_SELECT_SET, moffsets, NULL, mcounts, NULL );
344 rval = H5Dfill( &fill_val, H5T_NATIVE_INT, data, type, mem_id );
345 }
346 }
347 else
348 {
349 H5Sclose( mem_id );
350 H5Sclose( slab_id );
351 mhdf_setFail( status, "Invalid dimension for meshset metadata table." );
352 return 0;
353 }
354
355 H5Sclose( slab_id );
356 H5Sclose( mem_id );
357 if( rval < 0 )
358 {
359 mhdf_setFail( status, "Internal error calling H5D%s.", read ? "read" : "write" );
360 return 0;
361 }
362
363 mhdf_setOkay( status );
364 return 1;
365 }
366
367 void mhdf_readSetMeta( hid_t table_id, long offset, long count, hid_t type, void* data, mhdf_Status* status )
368 {
369 API_BEGIN;
370 mhdf_readwriteSetMeta( table_id, 1, offset, count, type, data, H5P_DEFAULT, status );
371 API_END;
372 }
373 void mhdf_readSetMetaWithOpt( hid_t table_id,
374 long offset,
375 long count,
376 hid_t type,
377 void* data,
378 hid_t prop,
379 mhdf_Status* status )
380 {
381 API_BEGIN;
382 mhdf_readwriteSetMeta( table_id, 1, offset, count, type, data, prop, status );
383 API_END;
384 }
385
386 void mhdf_writeSetMeta( hid_t table_id, long offset, long count, hid_t type, const void* data, mhdf_Status* status )
387 {
388 API_BEGIN;
389 mhdf_readwriteSetMeta( table_id, 0, offset, count, type, (void*)data, H5P_DEFAULT, status );
390 API_END;
391 }
392 void mhdf_writeSetMetaWithOpt( hid_t table_id,
393 long offset,
394 long count,
395 hid_t type,
396 const void* data,
397 hid_t prop,
398 mhdf_Status* status )
399 {
400 API_BEGIN;
401 mhdf_readwriteSetMeta( table_id, 0, offset, count, type, (void*)data, prop, status );
402 API_END;
403 }
404
405 enum SetMetaCol
406 {
407 CONTENT = 0,
408 CHILDREN = 1,
409 PARENTS = 2,
410 FLAGS = 3
411 };
412
413 static int mhdf_readSetMetaColumn( hid_t table_id,
414 enum SetMetaCol column,
415 long offset,
416 long count,
417 hid_t type,
418 void* data,
419 hid_t prop,
420 mhdf_Status* status )
421 {
422 hid_t slab_id, mem_id;
423 hsize_t offsets[2], counts[2], mcount = count;
424 herr_t rval = 0;
425 int dims;
426 const int fill_val = -1;
427
428 if( offset < 0 || count < 0 )
429 {
430 mhdf_setFail( status,
431 "Invalid input for reading set description column: "
432 "offset = %ld, count = %ld\n",
433 offset, count );
434 return 0;
435 }
436
437
438
439 slab_id = H5Dget_space( table_id );
440 if( slab_id < 0 )
441 {
442 mhdf_setFail( status, "Internal error calling H5Dget_space." );
443 return 0;
444 }
445
446 dims = H5Sget_simple_extent_ndims( slab_id );
447 if( dims != 2 )
448 {
449 H5Sclose( slab_id );
450 mhdf_setFail( status, "Internal error: unexpected dataset rank: %d.", dims );
451 return 0;
452 }
453
454 dims = H5Sget_simple_extent_dims( slab_id, counts, NULL );
455 if( dims < 0 )
456 {
457 H5Sclose( slab_id );
458 mhdf_setFail( status, "Internal error calling H5Sget_simple_extend_dims." );
459 return 0;
460 }
461
462 if( (unsigned long)( offset + count ) > counts[0] )
463 {
464 H5Sclose( slab_id );
465 mhdf_setFail( status, "Requested read of rows %ld to %ld of a %ld row table.\n", offset, offset + count - 1,
466 (long)counts[0] );
467 return 0;
468 }
469
470
471
472 mem_id = H5Screate_simple( 1, &mcount, NULL );
473 if( mem_id < 0 )
474 {
475 H5Sclose( slab_id );
476 mhdf_setFail( status, "Internal error calling H5Screate_simple." );
477 return 0;
478 }
479
480
486 offsets[1] = column;
487 if( counts[1] == 3 )
488 {
489 if( column == PARENTS )
490 {
491 rval = H5Dfill( &fill_val, H5T_NATIVE_INT, data, type, mem_id );
492 H5Sclose( mem_id );
493 H5Sclose( slab_id );
494 if( rval < 0 )
495 {
496 mhdf_setFail( status, "Internal error calling H5Dfill" );
497 return 0;
498 }
499 else
500 {
501 mhdf_setOkay( status );
502 return 1;
503 }
504 }
505 else if( column == FLAGS )
506 --offsets[1];
507 }
508 else if( counts[1] != 4 )
509 {
510 H5Sclose( mem_id );
511 H5Sclose( slab_id );
512 mhdf_setFail( status, "Invalid dimension for meshset metadata table." );
513 return 0;
514 }
515
516
517
518
519 offsets[0] = (hsize_t)offset;
520 counts[0] = (hsize_t)count;
521 counts[1] = 1;
522 if( count )
523 rval = H5Sselect_hyperslab( slab_id, H5S_SELECT_SET, offsets, NULL, counts, NULL );
524 else
525 rval = H5Sselect_none( slab_id );
526 if( rval < 0 )
527 {
528 H5Sclose( mem_id );
529 H5Sclose( slab_id );
530 mhdf_setFail( status, "Internal error calling H5Sselect_hyperslab." );
531 return 0;
532 }
533
534
535
536 rval = H5Dread( table_id, type, mem_id, slab_id, prop, data );
537 H5Sclose( mem_id );
538 H5Sclose( slab_id );
539 if( rval < 0 )
540 {
541 mhdf_setFail( status, "Internal error calling H5Dread." );
542 return 0;
543 }
544
545 mhdf_setOkay( status );
546 return 1;
547 }
548
549 void mhdf_readSetFlags( hid_t table_id, long offset, long count, hid_t type, void* data, mhdf_Status* status )
550 {
551 API_BEGIN;
552 mhdf_readSetMetaColumn( table_id, FLAGS, offset, count, type, data, H5P_DEFAULT, status );
553 API_END;
554 }
555 void mhdf_readSetFlagsWithOpt( hid_t table_id,
556 long offset,
557 long count,
558 hid_t type,
559 void* data,
560 hid_t prop,
561 mhdf_Status* status )
562 {
563 API_BEGIN;
564 mhdf_readSetMetaColumn( table_id, FLAGS, offset, count, type, data, prop, status );
565 API_END;
566 }
567
568 void mhdf_readSetContentEndIndices( hid_t table_id,
569 long offset,
570 long count,
571 hid_t type,
572 void* data,
573 mhdf_Status* status )
574 {
575 API_BEGIN;
576 mhdf_readSetMetaColumn( table_id, CONTENT, offset, count, type, data, H5P_DEFAULT, status );
577 API_END;
578 }
579 void mhdf_readSetContentEndIndicesWithOpt( hid_t table_id,
580 long offset,
581 long count,
582 hid_t type,
583 void* data,
584 hid_t prop,
585 mhdf_Status* status )
586 {
587 API_BEGIN;
588 mhdf_readSetMetaColumn( table_id, CONTENT, offset, count, type, data, prop, status );
589 API_END;
590 }
591
592 void mhdf_readSetChildEndIndices( hid_t table_id, long offset, long count, hid_t type, void* data, mhdf_Status* status )
593 {
594 API_BEGIN;
595 mhdf_readSetMetaColumn( table_id, CHILDREN, offset, count, type, data, H5P_DEFAULT, status );
596 API_END;
597 }
598 void mhdf_readSetChildEndIndicesWithOpt( hid_t table_id,
599 long offset,
600 long count,
601 hid_t type,
602 void* data,
603 hid_t prop,
604 mhdf_Status* status )
605 {
606 API_BEGIN;
607 mhdf_readSetMetaColumn( table_id, CHILDREN, offset, count, type, data, prop, status );
608 API_END;
609 }
610
611 void mhdf_readSetParentEndIndices( hid_t table_id,
612 long offset,
613 long count,
614 hid_t type,
615 void* data,
616 mhdf_Status* status )
617 {
618 API_BEGIN;
619 mhdf_readSetMetaColumn( table_id, PARENTS, offset, count, type, data, H5P_DEFAULT, status );
620 API_END;
621 }
622 void mhdf_readSetParentEndIndicesWithOpt( hid_t table_id,
623 long offset,
624 long count,
625 hid_t type,
626 void* data,
627 hid_t prop,
628 mhdf_Status* status )
629 {
630 API_BEGIN;
631 mhdf_readSetMetaColumn( table_id, PARENTS, offset, count, type, data, prop, status );
632 API_END;
633 }
634
635 hid_t mhdf_createSetData( mhdf_FileHandle file_handle, long data_list_size, mhdf_Status* status )
636 {
637 FileHandle* file_ptr;
638 hid_t table_id;
639 hsize_t dim = (hsize_t)data_list_size;
640 API_BEGIN;
641
642 file_ptr = (FileHandle*)( file_handle );
643 if( !mhdf_check_valid_file( file_ptr, status ) ) return -1;
644
645 if( data_list_size < 1 )
646 {
647 mhdf_setFail( status, "Invalid argument.\n" );
648 return -1;
649 }
650
651 table_id = mhdf_create_table( file_ptr->hdf_handle, SET_DATA_PATH, file_ptr->id_type, 1, &dim, status );
652
653 API_END_H( 1 );
654 return table_id;
655 }
656
657 hid_t mhdf_openSetData( mhdf_FileHandle file_handle, long* data_list_size_out, mhdf_Status* status )
658 {
659 FileHandle* file_ptr;
660 hid_t table_id;
661 hsize_t dim;
662 API_BEGIN;
663
664 file_ptr = (FileHandle*)( file_handle );
665 if( !mhdf_check_valid_file( file_ptr, status ) ) return -1;
666
667 if( !data_list_size_out )
668 {
669 mhdf_setFail( status, "Invalid argument.\n" );
670 return -1;
671 }
672
673 table_id = mhdf_open_table( file_ptr->hdf_handle, SET_DATA_PATH, 1, &dim, status );
674
675 *data_list_size_out = (long)dim;
676 API_END_H( 1 );
677 return table_id;
678 }
679
680 void mhdf_writeSetData( hid_t table_id, long offset, long count, hid_t type, const void* data, mhdf_Status* status )
681 {
682 API_BEGIN;
683 mhdf_write_data( table_id, offset, count, type, data, H5P_DEFAULT, status );
684 API_END;
685 }
686 void mhdf_writeSetDataWithOpt( hid_t table_id,
687 long offset,
688 long count,
689 hid_t type,
690 const void* data,
691 hid_t prop,
692 mhdf_Status* status )
693 {
694 API_BEGIN;
695 mhdf_write_data( table_id, offset, count, type, data, prop, status );
696 API_END;
697 }
698
699 void mhdf_readSetData( hid_t table_id, long offset, long count, hid_t type, void* data, mhdf_Status* status )
700 {
701 API_BEGIN;
702 mhdf_read_data( table_id, offset, count, type, data, H5P_DEFAULT, status );
703 API_END;
704 }
705 void mhdf_readSetDataWithOpt( hid_t table_id,
706 long offset,
707 long count,
708 hid_t type,
709 void* data,
710 hid_t prop,
711 mhdf_Status* status )
712 {
713 API_BEGIN;
714 mhdf_read_data( table_id, offset, count, type, data, prop, status );
715 API_END;
716 }
717
718 hid_t mhdf_createSetChildren( mhdf_FileHandle file_handle, long child_list_size, mhdf_Status* status )
719 {
720 FileHandle* file_ptr;
721 hid_t table_id;
722 hsize_t dim = (hsize_t)child_list_size;
723 API_BEGIN;
724
725 file_ptr = (FileHandle*)( file_handle );
726 if( !mhdf_check_valid_file( file_ptr, status ) ) return -1;
727
728 if( child_list_size < 1 )
729 {
730 mhdf_setFail( status, "Invalid argument.\n" );
731 return -1;
732 }
733
734 table_id = mhdf_create_table( file_ptr->hdf_handle, SET_CHILD_PATH, file_ptr->id_type, 1, &dim, status );
735
736 API_END_H( 1 );
737 return table_id;
738 }
739
740 hid_t mhdf_openSetChildren( mhdf_FileHandle file_handle, long* child_list_size, mhdf_Status* status )
741 {
742 FileHandle* file_ptr;
743 hid_t table_id;
744 hsize_t dim;
745 API_BEGIN;
746
747 file_ptr = (FileHandle*)( file_handle );
748 if( !mhdf_check_valid_file( file_ptr, status ) ) return -1;
749
750 if( !child_list_size )
751 {
752 mhdf_setFail( status, "Invalid argument.\n" );
753 return -1;
754 }
755
756 table_id = mhdf_open_table( file_ptr->hdf_handle, SET_CHILD_PATH, 1, &dim, status );
757
758 *child_list_size = (long)dim;
759 API_END_H( 1 );
760 return table_id;
761 }
762
763 hid_t mhdf_createSetParents( mhdf_FileHandle file_handle, long parent_list_size, mhdf_Status* status )
764 {
765 FileHandle* file_ptr;
766 hid_t table_id;
767 hsize_t dim = (hsize_t)parent_list_size;
768 API_BEGIN;
769
770 file_ptr = (FileHandle*)( file_handle );
771 if( !mhdf_check_valid_file( file_ptr, status ) ) return -1;
772
773 if( parent_list_size < 1 )
774 {
775 mhdf_setFail( status, "Invalid argument.\n" );
776 return -1;
777 }
778
779 table_id = mhdf_create_table( file_ptr->hdf_handle, SET_PARENT_PATH, file_ptr->id_type, 1, &dim, status );
780
781 API_END_H( 1 );
782 return table_id;
783 }
784
785 hid_t mhdf_openSetParents( mhdf_FileHandle file_handle, long* parent_list_size, mhdf_Status* status )
786 {
787 FileHandle* file_ptr;
788 hid_t table_id;
789 hsize_t dim;
790 API_BEGIN;
791
792 file_ptr = (FileHandle*)( file_handle );
793 if( !mhdf_check_valid_file( file_ptr, status ) ) return -1;
794
795 if( !parent_list_size )
796 {
797 mhdf_setFail( status, "Invalid argument.\n" );
798 return -1;
799 }
800
801 table_id = mhdf_open_table( file_ptr->hdf_handle, SET_PARENT_PATH, 1, &dim, status );
802
803 *parent_list_size = (long)dim;
804 API_END_H( 1 );
805 return table_id;
806 }
807
808 void mhdf_writeSetParentsChildren( hid_t table_id,
809 long offset,
810 long count,
811 hid_t type,
812 const void* data,
813 mhdf_Status* status )
814 {
815 API_BEGIN;
816 mhdf_write_data( table_id, offset, count, type, data, H5P_DEFAULT, status );
817 API_END;
818 }
819 void mhdf_writeSetParentsChildrenWithOpt( hid_t table_id,
820 long offset,
821 long count,
822 hid_t type,
823 const void* data,
824 hid_t prop,
825 mhdf_Status* status )
826 {
827 API_BEGIN;
828 mhdf_write_data( table_id, offset, count, type, data, prop, status );
829 API_END;
830 }
831
832 void mhdf_readSetParentsChildren( hid_t table_id, long offset, long count, hid_t type, void* data, mhdf_Status* status )
833 {
834 API_BEGIN;
835 mhdf_read_data( table_id, offset, count, type, data, H5P_DEFAULT, status );
836 API_END;
837 }
838 void mhdf_readSetParentsChildrenWithOpt( hid_t table_id,
839 long offset,
840 long count,
841 hid_t type,
842 void* data,
843 hid_t prop,
844 mhdf_Status* status )
845 {
846 API_BEGIN;
847 mhdf_read_data( table_id, offset, count, type, data, prop, status );
848 API_END;
849 }