summaryrefslogtreecommitdiffstats
path: root/src/H5Sselect.c
diff options
context:
space:
mode:
authorJerome Soumagne <jsoumagne@hdfgroup.org>2015-10-02 20:24:29 (GMT)
committerJerome Soumagne <jsoumagne@hdfgroup.org>2015-10-02 20:24:29 (GMT)
commit87cc068ccbc761a473bbe8d211a40383c0933db0 (patch)
tree5ee6aebbe944f3460b0ca8acb3922cf01bad387b /src/H5Sselect.c
parentb991b71176e27f3d4ad0c9ddedfaadd9e232d831 (diff)
downloadhdf5-87cc068ccbc761a473bbe8d211a40383c0933db0.zip
hdf5-87cc068ccbc761a473bbe8d211a40383c0933db0.tar.gz
hdf5-87cc068ccbc761a473bbe8d211a40383c0933db0.tar.bz2
[svn-r27939] Remove H5D__iterate and use H5S_select_iterate directly
Add internal library callback to H5S_select_iterate to avoid having to pass hid_t objects internally
Diffstat (limited to 'src/H5Sselect.c')
-rw-r--r--src/H5Sselect.c30
1 files changed, 19 insertions, 11 deletions
diff --git a/src/H5Sselect.c b/src/H5Sselect.c
index 153c691..d7a2340 100644
--- a/src/H5Sselect.c
+++ b/src/H5Sselect.c
@@ -1238,9 +1238,9 @@ H5S_select_iter_release(H5S_sel_iter_t *sel_iter)
PURPOSE
Iterate over the selected elements in a memory buffer.
USAGE
- herr_t H5S_select_iterate(buf, type_id, space, operator, operator_data)
+ herr_t H5S_select_iterate(buf, type, space, operator, operator_data)
void *buf; IN/OUT: Buffer containing elements to iterate over
- hid_t type_id; IN: Datatype ID of BUF array.
+ H5T_t *type; IN: Datatype of BUF array.
H5S_t *space; IN: Dataspace object containing selection to iterate over
H5D_operator_t op; IN: Function pointer to the routine to be
called for each element in BUF iterated over.
@@ -1261,10 +1261,9 @@ H5S_select_iter_release(H5S_sel_iter_t *sel_iter)
the selection is not modified.
--------------------------------------------------------------------------*/
herr_t
-H5S_select_iterate(void *buf, hid_t type_id, const H5S_t *space, H5D_operator_t op,
- void *operator_data)
+H5S_select_iterate(void *buf, const H5T_t *type, const H5S_t *space,
+ const H5S_sel_iter_op_t *op, void *op_data)
{
- H5T_t *dt; /* Datatype structure */
H5S_sel_iter_t iter; /* Selection iteration info */
hbool_t iter_init = FALSE; /* Selection iteration info has been initialized */
hssize_t nelmts; /* Number of elements in selection */
@@ -1279,14 +1278,12 @@ H5S_select_iterate(void *buf, hid_t type_id, const H5S_t *space, H5D_operator_t
/* Check args */
HDassert(buf);
- HDassert(H5I_DATATYPE == H5I_get_type(type_id));
+ HDassert(type);
HDassert(space);
HDassert(op);
/* Get the datatype size */
- if(NULL == (dt = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE)))
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not an valid base datatype")
- if(0 == (elmt_size = H5T_get_size(dt)))
+ if(0 == (elmt_size = H5T_get_size(type)))
HGOTO_ERROR(H5E_DATATYPE, H5E_BADSIZE, FAIL, "datatype size invalid")
/* Initialize iterator */
@@ -1350,8 +1347,19 @@ H5S_select_iterate(void *buf, hid_t type_id, const H5S_t *space, H5D_operator_t
/* Get the location within the user's buffer */
loc = (unsigned char *)buf + curr_off;
- /* Call user's callback routine */
- user_ret = (*op)(loc, type_id, ndims, coords, operator_data);
+ /* Check which type of callback to make */
+ switch(op->op_type) {
+ case H5S_SEL_ITER_OP_APP:
+ /* Make the application callback */
+ user_ret = (op->u.app_op.op)(loc, op->u.app_op.type_id, ndims, coords, op_data);
+ break;
+ case H5S_SEL_ITER_OP_LIB:
+ /* Call the library's callback */
+ user_ret = (op->u.lib_op)(loc, type, ndims, coords, op_data);
+ break;
+ default:
+ HGOTO_ERROR(H5E_DATASPACE, H5E_UNSUPPORTED, FAIL, "unsupported op type")
+ } /* end switch */
/* Increment offset in dataspace */
curr_off += elmt_size;