From 1aeaa7fbb1072d18a533b7bbf8f996f6b194de73 Mon Sep 17 00:00:00 2001 From: Quincey Koziol Date: Wed, 18 Jun 2003 15:52:54 -0500 Subject: [svn-r7059] Purpose: Refactoring Description: Track changes to H5Fget_obj_ API functions. Platforms tested: FreeBSD 4.8 (sleipnir) h5committest --- doc/html/ADGuide/Changes.html | 5 ++- doc/html/RM_H5F.html | 26 ++++++++----- doc/html/fortran/h5f_FORTRAN.html | 3 +- fortran/src/H5Ff.c | 10 +++-- fortran/src/H5Fff.f90 | 8 ++-- fortran/src/H5f90proto.h | 2 +- fortran/test/tH5F.f90 | 2 +- test/tfile.c | 80 ++++++++++++++++++++------------------- 8 files changed, 77 insertions(+), 59 deletions(-) diff --git a/doc/html/ADGuide/Changes.html b/doc/html/ADGuide/Changes.html index ead527b..c506e37 100755 --- a/doc/html/ADGuide/Changes.html +++ b/doc/html/ADGuide/Changes.html @@ -70,8 +70,9 @@ Release 1.4.x versions of this document; they are not reported here. H5Fget_obj_ids - herr_t H5Fget_obj_ids (hid_t file_id, - unsigned int types, hid_t *obj_id_list) + int H5Fget_obj_ids (hid_t file_id, + unsigned int types, + int max_objs, hid_t *obj_id_list) diff --git a/doc/html/RM_H5F.html b/doc/html/RM_H5F.html index 3408bb8..68626ce 100644 --- a/doc/html/RM_H5F.html +++ b/doc/html/RM_H5F.html @@ -529,9 +529,8 @@ facilitate moving easily between them.
Name: H5Fget_obj_count
Signature: -
herr_t H5Fget_obj_count(hid_t file_id, - unsigned int types, - unsigned int *obj_id_count +
int H5Fget_obj_count(hid_t file_id, + unsigned int types )
Purpose:
Returns the number of open object identifiers for an open file. @@ -566,12 +565,17 @@ facilitate moving easily between them. Named datatypes only + H5F_OBJ_ATTR   + + Attributes only + H5F_OBJ_ALL All of the above
(I.e., H5F_OBJ_FILE | H5F_OBJ_DATASET | - H5F_OBJ_GROUP | H5F_OBJ_DATATYPE ) + H5F_OBJ_GROUP | H5F_OBJ_DATATYPE + | H5F_OBJ_ATTR ) @@ -586,11 +590,9 @@ facilitate moving easily between them. H5F_OBJ_ALL for all currently-open HDF5 files.
unsigned int types
IN: Type of object for which identifiers are to be returned. -
unsigned int *obj_id_count -
OUT: Pointer to the returned list of open object identifiers.
Returns: -
Returns a file access property list identifier if successful; +
Returns a the number of open objects if successful; otherwise returns a negative value.
Non-C API(s):
Name: H5Fget_obj_ids
Signature: -
herr_t H5Fget_obj_ids(hid_t file_id, +
int H5Fget_obj_ids(hid_t file_id, unsigned int types, + int max_objs, hid_t *obj_id_list )
Purpose: @@ -625,6 +628,9 @@ facilitate moving easily between them. The types of object identifiers to be retrieved are specified in types using the codes listed for the same parameter in H5Fget_obj_count +

+ To retrieve identifiers for all open objects, pass a negative value + for the max_objs.

Parameters:
hid_t file_id @@ -632,11 +638,13 @@ facilitate moving easily between them. H5F_OBJ_ALL for all currently-open HDF5 files.
unsigned int types
IN: Type of object for which identifiers are to be returned. +
int max_objs +
IN: Maximum number of object identifiers to place into obj_id_list.
hid_t *obj_id_list
OUT: Pointer to the returned list of open object identifiers.
Returns: -
Returns a non-negative value if successful; +
Returns number of objects placed into obj_id_list if successful; otherwise returns a negative value.
Non-C API(s):
FORTRAN interface:   h5fget_obj_ids_f
-         SUBROUTINE h5fget_obj_ids_f(file_id, obj_type, obj_ids, hdferr)
+         SUBROUTINE h5fget_obj_ids_f(file_id, obj_type, max_objs, obj_ids, hdferr)
 
            IMPLICIT NONE 
            INTEGER(HID_T), INTENT(IN)   :: file_id  ! File identifier
@@ -310,6 +310,7 @@ FORTRAN File API -- h5f
 						    ! H5F_OBJ_DATASET_F
 						    ! H5F_OBJ_DATATYPE_F
 						    ! H5F_OBJ_ALL_F
+           INTEGER, INTENT(IN)          :: max_objs ! Maximum # of object IDs to retrieve
            INTEGER(HID_T), DIMENSION(*), INTENT(OUT) :: obj_ids
                                                     ! array of requested object identifiers
            INTEGER, INTENT(OUT)        :: hdferr    ! Error code 
diff --git a/fortran/src/H5Ff.c b/fortran/src/H5Ff.c
index 2d8e5ef..5d3af5c 100644
--- a/fortran/src/H5Ff.c
+++ b/fortran/src/H5Ff.c
@@ -417,12 +417,12 @@ nh5fget_obj_count_c ( hid_t_f *file_id , int_f *obj_type, int_f * obj_count)
   int ret_value = 0;
   hid_t c_file_id;
   unsigned c_obj_type;
-  unsigned c_obj_count;
+  int c_obj_count;
   
 
   c_file_id = (hid_t)*file_id;
   c_obj_type = (unsigned) *obj_type;
-  if ( H5Fget_obj_count(c_file_id, c_obj_type, &c_obj_count) < 0  ) ret_value = -1;
+  if ( (c_obj_count=H5Fget_obj_count(c_file_id, c_obj_type)) < 0  ) ret_value = -1;
   *obj_count = (int_f)c_obj_count;
   return ret_value;
 }
@@ -439,14 +439,16 @@ nh5fget_obj_count_c ( hid_t_f *file_id , int_f *obj_type, int_f * obj_count)
  *---------------------------------------------------------------------------*/
 
 int_f 
-nh5fget_obj_ids_c ( hid_t_f *file_id , int_f *obj_type, hid_t_f *obj_ids)
+nh5fget_obj_ids_c ( hid_t_f *file_id , int_f *obj_type, int_f *max_objs, hid_t_f *obj_ids)
 {
   int ret_value = 0;
   hid_t c_file_id;
   unsigned c_obj_type;
+  int c_max_objs;
 
   c_file_id = (hid_t)*file_id;
   c_obj_type = (unsigned) *obj_type;
-  if ( H5Fget_obj_ids(c_file_id, c_obj_type, (hid_t *)obj_ids) < 0  ) ret_value = -1;
+  c_max_objs = (int)*max_objs;
+  if ( H5Fget_obj_ids(c_file_id, c_obj_type, c_max_objs, (hid_t *)obj_ids) < 0  ) ret_value = -1;
   return ret_value;
 }
diff --git a/fortran/src/H5Fff.f90 b/fortran/src/H5Fff.f90
index af40d88..725c824 100644
--- a/fortran/src/H5Fff.f90
+++ b/fortran/src/H5Fff.f90
@@ -771,7 +771,7 @@
 ! Comment:		
 !----------------------------------------------------------------------
           
-          SUBROUTINE h5fget_obj_ids_f(file_id, obj_type, obj_ids, hdferr)
+          SUBROUTINE h5fget_obj_ids_f(file_id, obj_type, max_objs, obj_ids, hdferr)
 !
 !This definition is needed for Windows DLLs
 !DEC$if defined(BUILD_HDF5_DLL)
@@ -782,23 +782,25 @@
             IMPLICIT NONE
             INTEGER(HID_T), INTENT(IN) :: file_id ! File identifier
             INTEGER, INTENT(IN)  :: obj_type   ! Object type
+            INTEGER, INTENT(IN)  :: max_objs   ! Maximum # of objects to retrieve
             INTEGER(HID_T), DIMENSION(*), INTENT(INOUT) :: obj_ids
                                                ! Array of open objects iidentifiers
             INTEGER, INTENT(OUT) :: hdferr        ! Error code
 
             INTERFACE
-              INTEGER FUNCTION h5fget_obj_ids_c(file_id, obj_type, obj_ids)
+              INTEGER FUNCTION h5fget_obj_ids_c(file_id, obj_type, max_objs, obj_ids)
               USE H5GLOBAL
               !DEC$ IF DEFINED(HDF5F90_WINDOWS)
        !MS$ATTRIBUTES C,reference,alias:'_H5FGET_OBJ_IDS_C':: h5fget_obj_ids_c
               !DEC$ ENDIF
               INTEGER(HID_T), INTENT(IN) :: file_id
               INTEGER, INTENT(IN)  :: obj_type      
+              INTEGER, INTENT(IN)  :: max_objs
               INTEGER(HID_T), DIMENSION(*), INTENT(INOUT) :: obj_ids  
               END FUNCTION h5fget_obj_ids_c
             END INTERFACE
 
-            hdferr = h5fget_obj_ids_c(file_id, obj_type, obj_ids)
+            hdferr = h5fget_obj_ids_c(file_id, obj_type, max_objs, obj_ids)
 
           END SUBROUTINE h5fget_obj_ids_f
       END MODULE H5F
diff --git a/fortran/src/H5f90proto.h b/fortran/src/H5f90proto.h
index eb36088..a684644 100644
--- a/fortran/src/H5f90proto.h
+++ b/fortran/src/H5f90proto.h
@@ -77,7 +77,7 @@ H5_DLL int_f nh5fget_access_plist_c (hid_t_f *file_id, hid_t_f *access_id);
 
 H5_DLL int_f nh5fget_obj_count_c (hid_t_f *file_id, int_f *obj_type, int_f *obj_count);
 
-H5_DLL int_f nh5fget_obj_ids_c (hid_t_f *file_id, int_f *obj_type, int_f *obj_ids);
+H5_DLL int_f nh5fget_obj_ids_c (hid_t_f *file_id, int_f *obj_type, int_f *max_objs, int_f *obj_ids);
 H5_DLL int_f nh5fflush_c (hid_t_f *obj_id, int_f *scope);
 
 /*
diff --git a/fortran/test/tH5F.f90 b/fortran/test/tH5F.f90
index 6aa796d..e8f933a 100644
--- a/fortran/test/tH5F.f90
+++ b/fortran/test/tH5F.f90
@@ -638,7 +638,7 @@
                  write(*,*) "Wrong number of open objects reported, error"
                endif
           allocate(obj_ids(obj_countf), stat = error) 
-          CALL h5fget_obj_ids_f(fid, H5F_OBJ_FILE_F, obj_ids, error)
+          CALL h5fget_obj_ids_f(fid, H5F_OBJ_FILE_F, -1, obj_ids, error)
                CALL check("h5fget_obj_ids_f",error,total_error)
           if(error .eq. 0) then
              do i = 1, obj_countf
diff --git a/test/tfile.c b/test/tfile.c
index d9cd9bf..45d6ca7 100644
--- a/test/tfile.c
+++ b/test/tfile.c
@@ -713,7 +713,7 @@ static void
 create_objects(hid_t fid1, hid_t fid2, hid_t *ret_did, hid_t *ret_gid1, 
 		hid_t *ret_gid2, hid_t *ret_gid3)
 {
-    unsigned	oid_count;
+    int	oid_count;
     herr_t	ret;
 
     /* Check reference counts of file IDs and opened object IDs.
@@ -721,22 +721,20 @@ create_objects(hid_t fid1, hid_t fid2, hid_t *ret_did, hid_t *ret_gid1,
      * is changed, remember to check this part and update the macros.
      */
     {
-       ret = H5Fget_obj_count(fid1, H5F_OBJ_ALL, &oid_count);
-       CHECK(ret, FAIL, "H5Fget_obj_count");
+       oid_count = H5Fget_obj_count(fid1, H5F_OBJ_ALL);
+       CHECK(oid_count, FAIL, "H5Fget_obj_count");
        VERIFY(oid_count, OBJ_ID_COUNT_2, "H5Fget_obj_count");
 
-       ret = H5Fget_obj_count(fid1, H5F_OBJ_DATASET|H5F_OBJ_GROUP|
-				H5F_OBJ_DATATYPE, &oid_count);
-       CHECK(ret, FAIL, "H5Fget_obj_count");
+       oid_count = H5Fget_obj_count(fid1, H5F_OBJ_DATASET|H5F_OBJ_GROUP|H5F_OBJ_DATATYPE|H5F_OBJ_ATTR);
+       CHECK(oid_count, FAIL, "H5Fget_obj_count");
        VERIFY(oid_count, OBJ_ID_COUNT_0, "H5Fget_obj_count");
 
-       ret = H5Fget_obj_count(fid2, H5F_OBJ_ALL, &oid_count);
-       CHECK(ret, FAIL, "H5Fget_obj_count");
+       oid_count = H5Fget_obj_count(fid2, H5F_OBJ_ALL);
+       CHECK(oid_count, FAIL, "H5Fget_obj_count");
        VERIFY(oid_count, OBJ_ID_COUNT_2, "H5Fget_obj_count");
 
-       ret = H5Fget_obj_count(fid2, H5F_OBJ_DATASET|H5F_OBJ_GROUP|
-                                H5F_OBJ_DATATYPE, &oid_count);
-       CHECK(ret, FAIL, "H5Fget_obj_count");
+       oid_count = H5Fget_obj_count(fid2, H5F_OBJ_DATASET|H5F_OBJ_GROUP|H5F_OBJ_DATATYPE|H5F_OBJ_ATTR);
+       CHECK(oid_count, FAIL, "H5Fget_obj_count");
        VERIFY(oid_count, OBJ_ID_COUNT_0, "H5Fget_obj_count");
     }
 
@@ -779,14 +777,17 @@ create_objects(hid_t fid1, hid_t fid2, hid_t *ret_did, hid_t *ret_gid1,
     {
         hid_t   gid1, gid2, gid3;
         gid1 = H5Gcreate(fid2, "/group", 0);
+        CHECK(gid1, FAIL, "H5Gcreate");
         if(ret_gid1 != NULL)
             *ret_gid1 = gid1;
 
         gid2 = H5Gopen(fid2, "/group");
+        CHECK(gid2, FAIL, "H5Gopen");
         if(ret_gid2 != NULL)
             *ret_gid2 = gid2;
 
         gid3 = H5Gopen(fid2, "/group");
+        CHECK(gid3, FAIL, "H5Gopen");
         if(ret_gid3 != NULL)
             *ret_gid3 = gid3;
     }
@@ -796,22 +797,20 @@ create_objects(hid_t fid1, hid_t fid2, hid_t *ret_did, hid_t *ret_gid1,
      * is changed, remember to check this part and update the macros.
      */
     {
-       ret = H5Fget_obj_count(fid1, H5F_OBJ_ALL, &oid_count);
-       CHECK(ret, FAIL, "H5Fget_obj_count");
+       oid_count = H5Fget_obj_count(fid1, H5F_OBJ_ALL);
+       CHECK(oid_count, FAIL, "H5Fget_obj_count");
        VERIFY(oid_count, OBJ_ID_COUNT_6, "H5Fget_obj_count");
 
-       ret = H5Fget_obj_count(fid1, H5F_OBJ_DATASET|H5F_OBJ_GROUP|
-                                H5F_OBJ_DATATYPE, &oid_count);
-       CHECK(ret, FAIL, "H5Fget_obj_count");
+       oid_count = H5Fget_obj_count(fid1, H5F_OBJ_DATASET|H5F_OBJ_GROUP|H5F_OBJ_DATATYPE|H5F_OBJ_ATTR);
+       CHECK(oid_count, FAIL, "H5Fget_obj_count");
        VERIFY(oid_count, OBJ_ID_COUNT_4, "H5Fget_obj_count");
 
-       ret = H5Fget_obj_count(fid2, H5F_OBJ_ALL, &oid_count);
-       CHECK(ret, FAIL, "H5Fget_obj_count");
+       oid_count = H5Fget_obj_count(fid2, H5F_OBJ_ALL);
+       CHECK(oid_count, FAIL, "H5Fget_obj_count");
        VERIFY(oid_count, OBJ_ID_COUNT_6, "H5Fget_obj_count");
 
-       ret = H5Fget_obj_count(fid2, H5F_OBJ_DATASET|H5F_OBJ_GROUP|
-                                H5F_OBJ_DATATYPE, &oid_count);
-       CHECK(ret, FAIL, "H5Fget_obj_count");
+       oid_count = H5Fget_obj_count(fid2, H5F_OBJ_DATASET|H5F_OBJ_GROUP|H5F_OBJ_DATATYPE|H5F_OBJ_ATTR);
+       CHECK(oid_count, FAIL, "H5Fget_obj_count");
        VERIFY(oid_count, OBJ_ID_COUNT_4, "H5Fget_obj_count");
     }
 }
@@ -826,7 +825,7 @@ test_obj_count_and_id(hid_t fid1, hid_t fid2, hid_t did, hid_t gid1,
 			hid_t gid2, hid_t gid3)
 {
     hid_t    fid3, fid4;
-    unsigned oid_count;
+    int oid_count;
     herr_t   ret;
 
     /* Create two new files */
@@ -836,38 +835,43 @@ test_obj_count_and_id(hid_t fid1, hid_t fid2, hid_t did, hid_t gid1,
     CHECK(fid4, FAIL, "H5Fcreate");
 
     /* test object count of all files IDs open */
-    ret = H5Fget_obj_count(H5F_OBJ_ALL, H5F_OBJ_FILE, &oid_count);
-    CHECK(ret, FAIL, "H5Fget_obj_count");
+    oid_count = H5Fget_obj_count(H5F_OBJ_ALL, H5F_OBJ_FILE);
+    CHECK(oid_count, FAIL, "H5Fget_obj_count");
     VERIFY(oid_count, OBJ_ID_COUNT_4, "H5Fget_obj_count");
 
-    /* test object count of all dataset open */
-    ret = H5Fget_obj_count(H5F_OBJ_ALL, H5F_OBJ_DATASET, &oid_count);
-    CHECK(ret, FAIL, "H5Fget_obj_count");
+    /* test object count of all datasets open */
+    oid_count = H5Fget_obj_count(H5F_OBJ_ALL, H5F_OBJ_DATASET);
+    CHECK(oid_count, FAIL, "H5Fget_obj_count");
     VERIFY(oid_count, OBJ_ID_COUNT_1, "H5Fget_obj_count");
 
-    /* test object count of all group open */
-    ret = H5Fget_obj_count(H5F_OBJ_ALL, H5F_OBJ_GROUP, &oid_count);
-    CHECK(ret, FAIL, "H5Fget_obj_count");
+    /* test object count of all groups open */
+    oid_count = H5Fget_obj_count(H5F_OBJ_ALL, H5F_OBJ_GROUP);
+    CHECK(oid_count, FAIL, "H5Fget_obj_count");
     VERIFY(oid_count, OBJ_ID_COUNT_3, "H5Fget_obj_count");
 
-    /* test object count of all datatype open */
-    ret = H5Fget_obj_count(H5F_OBJ_ALL, H5F_OBJ_DATATYPE, &oid_count);
-    CHECK(ret, FAIL, "H5Fget_obj_count");
+    /* test object count of all named datatypes open */
+    oid_count = H5Fget_obj_count(H5F_OBJ_ALL, H5F_OBJ_DATATYPE);
+    CHECK(oid_count, FAIL, "H5Fget_obj_count");
+    VERIFY(oid_count, OBJ_ID_COUNT_0, "H5Fget_obj_count");
+
+    /* test object count of all attributes open */
+    oid_count = H5Fget_obj_count(H5F_OBJ_ALL, H5F_OBJ_ATTR);
+    CHECK(oid_count, FAIL, "H5Fget_obj_count");
     VERIFY(oid_count, OBJ_ID_COUNT_0, "H5Fget_obj_count");
 
     /* test object count of all objects currently open */
-    ret = H5Fget_obj_count(H5F_OBJ_ALL, H5F_OBJ_ALL, &oid_count);
-    CHECK(ret, FAIL, "H5Fget_obj_count");
+    oid_count = H5Fget_obj_count(H5F_OBJ_ALL, H5F_OBJ_ALL);
+    CHECK(oid_count, FAIL, "H5Fget_obj_count");
     VERIFY(oid_count, OBJ_ID_COUNT_8, "H5Fget_obj_count");
 
     {
         hid_t      *oid_list;
-        unsigned   i;
+        int   i;
         H5I_type_t id_type;
 
-        oid_list = (hid_t*)calloc(oid_count, sizeof(hid_t));
+        oid_list = (hid_t*)calloc((size_t)oid_count, sizeof(hid_t));
         if(oid_list != NULL) {
-	    ret = H5Fget_obj_ids(H5F_OBJ_ALL, H5F_OBJ_ALL, oid_list);
+	    ret = H5Fget_obj_ids(H5F_OBJ_ALL, H5F_OBJ_ALL, oid_count, oid_list);
 	    CHECK(ret, FAIL, "H5Fget_obj_ids");
         }
 
-- 
cgit v0.12