diff options
author | Quincey Koziol <koziol@hdfgroup.org> | 2012-08-06 19:42:49 (GMT) |
---|---|---|
committer | Quincey Koziol <koziol@hdfgroup.org> | 2012-08-06 19:42:49 (GMT) |
commit | cd3f42096b9a957e37c9df48aa0d31d9ed4bc537 (patch) | |
tree | 86a1672d114762d3aea872e44104e65d1bc09254 /src/H5P.c | |
parent | 434643dd4d14a841abdcc73ad7b3a0a8e06e4438 (diff) | |
download | hdf5-cd3f42096b9a957e37c9df48aa0d31d9ed4bc537.zip hdf5-cd3f42096b9a957e37c9df48aa0d31d9ed4bc537.tar.gz hdf5-cd3f42096b9a957e37c9df48aa0d31d9ed4bc537.tar.bz2 |
[svn-r22636] Description:
Bring r22599:22634 from trunk to revise_chunks branch
Tested on:
Mac OSX/64 10.7.4 (amazon) w/gcc 4.7.x, C++ & FORTRAN
(No need for h5committest yet on this branch)
Diffstat (limited to 'src/H5P.c')
-rw-r--r-- | src/H5P.c | 63 |
1 files changed, 59 insertions, 4 deletions
@@ -45,6 +45,13 @@ /* Local Typedefs */ /******************/ +/* Typedef for property iterator callback */ +typedef struct { + H5P_iterate_t iter_func; /* Iterator callback */ + hid_t id; /* Property list or class ID */ + void *iter_data; /* Iterator callback pointer */ +} H5P_iter_ud_t; + /********************/ /* Local Prototypes */ @@ -111,7 +118,7 @@ H5P_init_pub_interface(void) hid_t H5Pcopy(hid_t id) { - void *obj; /* Property object to copy */ + void *obj; /* Property object to copy */ hid_t ret_value=FALSE; /* return value */ FUNC_ENTER_API(FAIL) @@ -217,7 +224,7 @@ H5Pcreate_class(hid_t parent, const char *name, HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "can't retrieve parent class") /* Create the new property list class */ - if(NULL == (pclass = H5P_create_class(par_class, name, FALSE, cls_create, create_data, cls_copy, copy_data, cls_close, close_data))) + if(NULL == (pclass = H5P_create_class(par_class, name, H5P_TYPE_USER, cls_create, create_data, cls_copy, copy_data, cls_close, close_data))) HGOTO_ERROR(H5E_PLIST, H5E_CANTCREATE, FAIL, "unable to create property list class") /* Get an atom for the class */ @@ -1045,6 +1052,45 @@ done: /*-------------------------------------------------------------------------- NAME + H5P__iterate_cb + PURPOSE + Internal callback routine when iterating over properties in property list + or class + USAGE + int H5P__iterate_cb(prop, udata) + H5P_genprop_t *prop; IN: Pointer to the property + void *udata; IN/OUT: Pointer to iteration data from user + RETURNS + Success: Returns the return value of the last call to ITER_FUNC + DESCRIPTION + This routine calls the actual callback routine for the property in the +property list or class. + GLOBAL VARIABLES + COMMENTS, BUGS, ASSUMPTIONS + EXAMPLES + REVISION LOG +--------------------------------------------------------------------------*/ +static int +H5P__iterate_cb(H5P_genprop_t *prop, void *_udata) +{ + H5P_iter_ud_t *udata = (H5P_iter_ud_t *)_udata; /* Pointer to user data */ + int ret_value = 0; /* Return value */ + + FUNC_ENTER_STATIC_NOERR + + /* Sanity check */ + HDassert(prop); + HDassert(udata); + + /* Call the user's callback routine */ + ret_value = (*udata->iter_func)(udata->id, prop->name, udata->iter_data); + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5P__iterate_cb() */ + + +/*-------------------------------------------------------------------------- + NAME H5Piterate PURPOSE Routine to iterate over the properties in a property list or class @@ -1099,7 +1145,9 @@ iteration, the function's behavior is undefined. int H5Piterate(hid_t id, int *idx, H5P_iterate_t iter_func, void *iter_data) { + H5P_iter_ud_t udata; /* User data for internal iterator callback */ int fake_idx = 0; /* Index when user doesn't provide one */ + void *obj; /* Property object to copy */ int ret_value; /* return value */ FUNC_ENTER_API(FAIL) @@ -1108,18 +1156,25 @@ H5Piterate(hid_t id, int *idx, H5P_iterate_t iter_func, void *iter_data) /* Check arguments. */ if(H5I_GENPROP_LST != H5I_get_type(id) && H5I_GENPROP_CLS != H5I_get_type(id)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property object"); + if(NULL == (obj = H5I_object(id))) + HGOTO_ERROR(H5E_PLIST, H5E_NOTFOUND, FAIL, "property object doesn't exist"); if(iter_func == NULL) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid iteration callback"); + /* Set up user data */ + udata.iter_func = iter_func; + udata.id = id; + udata.iter_data = iter_data; + if(H5I_GENPROP_LST == H5I_get_type(id)) { /* Iterate over a property list */ - if((ret_value = H5P_iterate_plist(id, (idx ? idx : &fake_idx), iter_func, iter_data)) < 0) + if((ret_value = H5P_iterate_plist((H5P_genplist_t *)obj, TRUE, (idx ? idx : &fake_idx), H5P__iterate_cb, &udata)) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTREGISTER, FAIL, "unable to iterate over list"); } /* end if */ else if(H5I_GENPROP_CLS == H5I_get_type(id)) { /* Iterate over a property class */ - if((ret_value = H5P_iterate_pclass(id, (idx ? idx : &fake_idx), iter_func, iter_data)) < 0) + if((ret_value = H5P_iterate_pclass((H5P_genclass_t *)obj, (idx ? idx : &fake_idx), H5P__iterate_cb, &udata)) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTREGISTER, FAIL, "unable to iterate over class"); } /* end if */ else |