diff options
author | Quincey Koziol <koziol@hdfgroup.org> | 2007-10-30 22:56:15 (GMT) |
---|---|---|
committer | Quincey Koziol <koziol@hdfgroup.org> | 2007-10-30 22:56:15 (GMT) |
commit | b969dce6e5625dd9d9f9cc42717a1b2027fdeeb1 (patch) | |
tree | ae2f2b4b6b417831b35f14c4e12e4bcc7971b636 /src | |
parent | c136b81140106231e471b334bc5248611cec04e6 (diff) | |
download | hdf5-b969dce6e5625dd9d9f9cc42717a1b2027fdeeb1.zip hdf5-b969dce6e5625dd9d9f9cc42717a1b2027fdeeb1.tar.gz hdf5-b969dce6e5625dd9d9f9cc42717a1b2027fdeeb1.tar.bz2 |
[svn-r14224] Description:
Change H5Literate -> H5Literate_by_name and add simpler form of
H5Literate, to bring this routine into alignment with the other new API
routines.
Tested on:
FreeBSD/32 6.2 (duty) in debug mode
FreeBSD/64 6.2 (liberty) w/C++ & FORTRAN, in debug mode
Linux/32 2.6 (kagiso) w/PGI compilers, w/C++ & FORTRAN, w/threadsafe,
in debug mode
Linux/64-amd64 2.6 (smirom) w/default API=1.6.x, w/C++ & FORTRAN,
in production mode
Linux/64-ia64 2.6 (cobalt) w/Intel compilers, w/C++ & FORTRAN,
in production mode
Solaris/32 2.10 (linew) w/deprecated symbols disabled, w/C++ & FORTRAN,
w/szip filter, in production mode
Mac OS X/32 10.4.10 (amazon) in debug mode
Diffstat (limited to 'src')
-rw-r--r-- | src/H5Gdeprec.c | 2 | ||||
-rw-r--r-- | src/H5Gname.c | 11 | ||||
-rw-r--r-- | src/H5Gobj.c | 4 | ||||
-rw-r--r-- | src/H5Gpkg.h | 2 | ||||
-rw-r--r-- | src/H5Gprivate.h | 5 | ||||
-rw-r--r-- | src/H5I.c | 2 | ||||
-rw-r--r-- | src/H5L.c | 76 | ||||
-rw-r--r-- | src/H5Lpublic.h | 6 | ||||
-rw-r--r-- | src/H5R.c | 9 |
9 files changed, 96 insertions, 21 deletions
diff --git a/src/H5Gdeprec.c b/src/H5Gdeprec.c index b71c509..76542dd 100644 --- a/src/H5Gdeprec.c +++ b/src/H5Gdeprec.c @@ -773,7 +773,7 @@ H5Giterate(hid_t loc_id, const char *name, int *idx_p, H5G_iterate_t op, lnk_op.u.old_op = op; /* Call private function. */ - if((ret_value = H5G_obj_iterate(loc_id, name, H5_INDEX_NAME, H5_ITER_INC, idx, &last_obj, &lnk_op, op_data, H5AC_ind_dxpl_id)) < 0) + if((ret_value = H5G_obj_iterate(loc_id, name, H5_INDEX_NAME, H5_ITER_INC, idx, &last_obj, &lnk_op, op_data, H5P_DEFAULT, H5AC_ind_dxpl_id)) < 0) HGOTO_ERROR(H5E_SYM, H5E_BADITER, FAIL, "group iteration failed") /* Set the index we stopped at */ diff --git a/src/H5Gname.c b/src/H5Gname.c index 2bc0174..e341ee7 100644 --- a/src/H5Gname.c +++ b/src/H5Gname.c @@ -53,6 +53,7 @@ typedef struct H5G_names_t { typedef struct H5G_ref_path_iter_t { /* In */ hid_t file; /* File id where it came from */ + hid_t lapl_id; /* LAPL for operations */ hid_t dxpl_id; /* DXPL for operations */ hbool_t is_root_group; /* Flag to indicate that the root group is being looked at */ const H5O_loc_t *loc; /* The location of the object we're looking for */ @@ -437,7 +438,8 @@ H5G_name_copy(H5G_name_t *dst, const H5G_name_t *src, H5_copy_depth_t depth) *------------------------------------------------------------------------- */ ssize_t -H5G_get_name(hid_t id, char *name/*out*/, size_t size, hid_t dxpl_id) +H5G_get_name(hid_t id, char *name/*out*/, size_t size, hid_t lapl_id, + hid_t dxpl_id) { H5G_loc_t loc; /* Object location */ ssize_t ret_value = FAIL; @@ -466,7 +468,7 @@ H5G_get_name(hid_t id, char *name/*out*/, size_t size, hid_t dxpl_id) HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't retrieve file ID") /* Search for name of object */ - if((len = H5G_get_refobj_name(file, dxpl_id, loc.oloc, name, size)) < 0) { + if((len = H5G_get_refobj_name(file, lapl_id, dxpl_id, loc.oloc, name, size)) < 0) { H5I_dec_ref(file); HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't determine name") } /* end if */ @@ -1149,7 +1151,7 @@ H5G_refname_iterator(hid_t group, const char *name, const H5L_info_t *link_info, lnk_op.op_type = H5G_LINK_OP_APP; lnk_op.u.app_op = H5G_refname_iterator; - ret_value = H5G_obj_iterate(udata->file, udata->container, H5_INDEX_NAME, H5_ITER_NATIVE, (hsize_t)0, &last_obj, &lnk_op, udata, udata->dxpl_id); + ret_value = H5G_obj_iterate(udata->file, udata->container, H5_INDEX_NAME, H5_ITER_NATIVE, (hsize_t)0, &last_obj, &lnk_op, udata, udata->lapl_id, udata->dxpl_id); /* If we didn't find the object, truncate the name to not include group name anymore */ if(!ret_value) @@ -1211,7 +1213,7 @@ H5G_free_ref_path_node(void *item, void UNUSED *key, void UNUSED *operator_data/ *------------------------------------------------------------------------- */ ssize_t -H5G_get_refobj_name(hid_t file, hid_t dxpl_id, const H5O_loc_t *loc, +H5G_get_refobj_name(hid_t file, hid_t lapl_id, hid_t dxpl_id, const H5O_loc_t *loc, char *name, size_t size) { H5G_ref_path_iter_t udata; /* User data for iteration */ @@ -1231,6 +1233,7 @@ H5G_get_refobj_name(hid_t file, hid_t dxpl_id, const H5O_loc_t *loc, /* Set up user data for iterator */ udata.file = file; + udata.lapl_id = lapl_id; udata.dxpl_id = dxpl_id; udata.is_root_group = TRUE; if(NULL == (udata.container = H5MM_strdup(""))) diff --git a/src/H5Gobj.c b/src/H5Gobj.c index a626514..00bac73 100644 --- a/src/H5Gobj.c +++ b/src/H5Gobj.c @@ -638,7 +638,7 @@ done: herr_t H5G_obj_iterate(hid_t loc_id, const char *group_name, H5_index_t idx_type, H5_iter_order_t order, hsize_t skip, hsize_t *last_lnk, - H5G_link_iterate_t *lnk_op, void *op_data, hid_t dxpl_id) + H5G_link_iterate_t *lnk_op, void *op_data, hid_t lapl_id, hid_t dxpl_id) { H5G_loc_t loc; /* Location of parent for group */ H5O_linfo_t linfo; /* Link info message */ @@ -659,7 +659,7 @@ H5G_obj_iterate(hid_t loc_id, const char *group_name, */ if(H5G_loc(loc_id, &loc) < 0) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") - if(NULL == (grp = H5G_open_name(&loc, group_name, H5P_DEFAULT, dxpl_id))) + if(NULL == (grp = H5G_open_name(&loc, group_name, lapl_id, dxpl_id))) HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to open group") if((gid = H5I_register(H5I_GROUP, grp)) < 0) HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to register group") diff --git a/src/H5Gpkg.h b/src/H5Gpkg.h index 1200c52..f5b2582 100644 --- a/src/H5Gpkg.h +++ b/src/H5Gpkg.h @@ -512,7 +512,7 @@ H5_DLL herr_t H5G_obj_insert(const H5O_loc_t *grp_oloc, const char *name, H5O_link_t *obj_lnk, hbool_t adj_link, hid_t dxpl_id); H5_DLL herr_t H5G_obj_iterate(hid_t loc_id, const char *group_name, H5_index_t idx_type, H5_iter_order_t order, hsize_t skip, hsize_t *last_obj, - H5G_link_iterate_t *lnk_op, void *op_data, hid_t dxpl_id); + H5G_link_iterate_t *lnk_op, void *op_data, hid_t lapl_id, hid_t dxpl_id); H5_DLL herr_t H5G_obj_info(H5O_loc_t *oloc, H5G_info_t *grp_info, hid_t dxpl_id); H5_DLL ssize_t H5G_obj_get_name_by_idx(H5O_loc_t *oloc, H5_index_t idx_type, H5_iter_order_t order, hsize_t n, char* name, size_t size, hid_t dxpl_id); diff --git a/src/H5Gprivate.h b/src/H5Gprivate.h index ccbb66e..9717b77 100644 --- a/src/H5Gprivate.h +++ b/src/H5Gprivate.h @@ -187,8 +187,9 @@ H5_DLL herr_t H5G_name_replace(const struct H5O_link_t *lnk, H5G_names_op_t op, H5_DLL herr_t H5G_name_reset(H5G_name_t *name); H5_DLL herr_t H5G_name_copy(H5G_name_t *dst, const H5G_name_t *src, H5_copy_depth_t depth); H5_DLL herr_t H5G_name_free(H5G_name_t *name); -H5_DLL ssize_t H5G_get_name(hid_t id, char *name/*out*/, size_t size, hid_t dxpl_id); -H5_DLL ssize_t H5G_get_refobj_name(hid_t fid, hid_t dxpl_id, +H5_DLL ssize_t H5G_get_name(hid_t id, char *name/*out*/, size_t size, + hid_t lapl_id, hid_t dxpl_id); +H5_DLL ssize_t H5G_get_refobj_name(hid_t fid, hid_t lapl_id, hid_t dxpl_id, const struct H5O_loc_t *loc, char* name, size_t size); /* @@ -2003,7 +2003,7 @@ H5Iget_name(hid_t id, char *name/*out*/, size_t size) H5TRACE3("Zs", "ixz", id, name, size); /* Call internal group routine to retrieve object's name */ - if((ret_value = H5G_get_name(id, name, size, H5AC_ind_dxpl_id)) < 0) + if((ret_value = H5G_get_name(id, name, size, H5P_DEFAULT, H5AC_ind_dxpl_id)) < 0) HGOTO_ERROR(H5E_ATOM, H5E_CANTGET, FAIL, "can't retrieve object name") done: @@ -1197,7 +1197,75 @@ done: *------------------------------------------------------------------------- */ herr_t -H5Literate(hid_t loc_id, const char *group_name, +H5Literate(hid_t grp_id, H5_index_t idx_type, H5_iter_order_t order, + hsize_t *idx_p, H5L_iterate_t op, void *op_data) +{ + H5I_type_t id_type; /* Type of ID */ + H5G_link_iterate_t lnk_op; /* Link operator */ + hsize_t last_lnk; /* Index of last object looked at */ + hsize_t idx; /* Internal location to hold index */ + herr_t ret_value; /* Return value */ + + FUNC_ENTER_API(H5Literate, FAIL) + H5TRACE6("e", "iIiIo*hx*x", grp_id, idx_type, order, idx_p, op, + op_data); + + /* Check arguments */ + id_type = H5I_get_type(grp_id); + if(!(H5I_GROUP == id_type || H5I_FILE == id_type)) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid argument") + if(idx_type <= H5_INDEX_UNKNOWN || idx_type >= H5_INDEX_N) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid index type specified") + if(order <= H5_ITER_UNKNOWN || order >= H5_ITER_N) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid iteration order specified") + if(!op) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no operator specified") + + /* Set up iteration beginning/end info */ + idx = (idx_p == NULL ? 0 : *idx_p); + last_lnk = 0; + + /* Build link operator info */ + lnk_op.op_type = H5G_LINK_OP_APP; + lnk_op.u.app_op = op; + + /* Iterate over the links */ + if((ret_value = H5G_obj_iterate(grp_id, ".", idx_type, order, idx, &last_lnk, &lnk_op, op_data, H5P_DEFAULT, H5AC_ind_dxpl_id)) < 0) + HGOTO_ERROR(H5E_SYM, H5E_BADITER, FAIL, "link iteration failed") + + /* Set the index we stopped at */ + if(idx_p) + *idx_p = last_lnk; + +done: + FUNC_LEAVE_API(ret_value) +} /* end H5Literate() */ + + +/*------------------------------------------------------------------------- + * Function: H5Literate_by_name + * + * Purpose: Iterates over links in a group, with user callback routine, + * according to the order within an index. + * + * Same pattern of behavior as H5Giterate. + * + * Return: Success: The return value of the first operator that + * returns non-zero, or zero if all members were + * processed with no operator returning non-zero. + * + * Failure: Negative if something goes wrong within the + * library, or the negative value returned by one + * of the operators. + * + * + * Programmer: Quincey Koziol + * Thursday, November 16, 2006 + * + *------------------------------------------------------------------------- + */ +herr_t +H5Literate_by_name(hid_t loc_id, const char *group_name, H5_index_t idx_type, H5_iter_order_t order, hsize_t *idx_p, H5L_iterate_t op, void *op_data, hid_t lapl_id) { @@ -1206,7 +1274,7 @@ H5Literate(hid_t loc_id, const char *group_name, hsize_t idx; /* Internal location to hold index */ herr_t ret_value; /* Return value */ - FUNC_ENTER_API(H5Literate, FAIL) + FUNC_ENTER_API(H5Literate_by_name, FAIL) H5TRACE8("e", "i*sIiIo*hx*xi", loc_id, group_name, idx_type, order, idx_p, op, op_data, lapl_id); @@ -1234,7 +1302,7 @@ H5Literate(hid_t loc_id, const char *group_name, lnk_op.u.app_op = op; /* Iterate over the links */ - if((ret_value = H5G_obj_iterate(loc_id, group_name, idx_type, order, idx, &last_lnk, &lnk_op, op_data, H5AC_ind_dxpl_id)) < 0) + if((ret_value = H5G_obj_iterate(loc_id, group_name, idx_type, order, idx, &last_lnk, &lnk_op, op_data, lapl_id, H5AC_ind_dxpl_id)) < 0) HGOTO_ERROR(H5E_SYM, H5E_BADITER, FAIL, "link iteration failed") /* Set the index we stopped at */ @@ -1243,7 +1311,7 @@ H5Literate(hid_t loc_id, const char *group_name, done: FUNC_LEAVE_API(ret_value) -} /* end H5Literate() */ +} /* end H5Literate_by_name() */ /* *------------------------------------------------------------------------- diff --git a/src/H5Lpublic.h b/src/H5Lpublic.h index 863155e..9a85900 100644 --- a/src/H5Lpublic.h +++ b/src/H5Lpublic.h @@ -127,7 +127,7 @@ typedef struct { H5L_query_func_t query_func; /* Callback for queries */ } H5L_class_t; -/* Prototype for H5Literate() operator */ +/* Prototype for H5Literate/H5Literate_by_name() operator */ typedef herr_t (*H5L_iterate_t)(hid_t group, const char *name, const H5L_info_t *info, void *op_data); @@ -167,7 +167,9 @@ H5_DLL herr_t H5Lget_info_by_idx(hid_t loc_id, const char *group_name, H5_DLL ssize_t H5Lget_name_by_idx(hid_t loc_id, const char *group_name, H5_index_t idx_type, H5_iter_order_t order, hsize_t n, char *name /*out*/, size_t size, hid_t lapl_id); -H5_DLL herr_t H5Literate(hid_t loc_id, const char *group_name, +H5_DLL herr_t H5Literate(hid_t grp_id, H5_index_t idx_type, + H5_iter_order_t order, hsize_t *idx, H5L_iterate_t op, void *op_data); +H5_DLL herr_t H5Literate_by_name(hid_t loc_id, const char *group_name, H5_index_t idx_type, H5_iter_order_t order, hsize_t *idx, H5L_iterate_t op, void *op_data, hid_t lapl_id); @@ -39,7 +39,7 @@ static herr_t H5R_create(void *ref, H5G_loc_t *loc, const char *name, H5R_type_t ref_type, H5S_t *space, hid_t dxpl_id); static hid_t H5R_dereference(H5F_t *file, hid_t dxpl_id, H5R_type_t ref_type, const void *_ref); static H5S_t * H5R_get_region(H5F_t *file, hid_t dxpl_id, const void *_ref); -static ssize_t H5R_get_name(H5F_t *file, hid_t dxpl_id, hid_t id, +static ssize_t H5R_get_name(H5F_t *file, hid_t lapl_id, hid_t dxpl_id, hid_t id, H5R_type_t ref_type, const void *_ref, char *name, size_t size); @@ -805,6 +805,7 @@ done: ssize_t H5R_get_name(f, dxpl_id, ref_type, ref, name, size) H5F_t *f; IN: Pointer to the file that the reference is pointing into + hid_t lapl_id; IN: LAPL to use for operation hid_t dxpl_id; IN: DXPL to use for operation hid_t id; IN: Location ID given for reference H5R_type_t ref_type; IN: Type of reference @@ -824,7 +825,7 @@ done: REVISION LOG --------------------------------------------------------------------------*/ ssize_t -H5R_get_name(H5F_t *f, hid_t dxpl_id, hid_t id, H5R_type_t ref_type, +H5R_get_name(H5F_t *f, hid_t lapl_id, hid_t dxpl_id, hid_t id, H5R_type_t ref_type, const void *_ref, char *name, size_t size) { hid_t file_id = (-1); /* ID for file that the reference is in */ @@ -884,7 +885,7 @@ H5R_get_name(H5F_t *f, hid_t dxpl_id, hid_t id, H5R_type_t ref_type, HGOTO_ERROR(H5E_REFERENCE, H5E_CANTGET, FAIL, "can't retrieve file ID") /* Get name, length, etc. */ - if((ret_value = H5G_get_refobj_name(file_id, dxpl_id, &oloc, name, size)) < 0) + if((ret_value = H5G_get_refobj_name(file_id, lapl_id, dxpl_id, &oloc, name, size)) < 0) HGOTO_ERROR(H5E_REFERENCE, H5E_CANTGET, FAIL, "can't determine name") done: @@ -945,7 +946,7 @@ H5Rget_name(hid_t id, H5R_type_t ref_type, const void *_ref, char *name, file = loc.oloc->file; /* Get name */ - if((ret_value = H5R_get_name(file, H5AC_dxpl_id, id, ref_type, _ref, name, size)) < 0) + if((ret_value = H5R_get_name(file, H5P_DEFAULT, H5AC_dxpl_id, id, ref_type, _ref, name, size)) < 0) HGOTO_ERROR(H5E_REFERENCE, H5E_CANTINIT, FAIL, "unable to determine object path") done: |