From b94be74cbf9206b20d357154eb95da17185c474c Mon Sep 17 00:00:00 2001 From: Mohamad Chaarawi Date: Fri, 21 Jun 2013 08:54:45 -0500 Subject: [svn-r23803] Add VOL callback for H5Aiterate Add VOL callback for H5T get routines Update Native implementation --- src/H5A.c | 101 +++++++++++--------------------- src/H5Gprivate.h | 2 +- src/H5Tcommit.c | 17 +++--- src/H5VL.c | 77 +++++++++++++++++++++++++ src/H5VLint.c | 69 ++++++++++++++++++++++ src/H5VLnative.c | 168 +++++++++++++++++++++++++++++++++++++++++++++++++++++- src/H5VLprivate.h | 4 ++ src/H5VLpublic.h | 13 +++++ 8 files changed, 371 insertions(+), 80 deletions(-) diff --git a/src/H5A.c b/src/H5A.c index d7eb7d9..7674db8 100644 --- a/src/H5A.c +++ b/src/H5A.c @@ -1389,9 +1389,9 @@ herr_t H5Aiterate2(hid_t loc_id, H5_index_t idx_type, H5_iter_order_t order, hsize_t *idx, H5A_operator2_t op, void *op_data) { - H5A_attr_iter_op_t attr_op; /* Attribute operator */ - hsize_t start_idx; /* Index of attribute to start iterating at */ - hsize_t last_attr; /* Index of last attribute examined */ + void *obj = NULL; /* object token of loc_id */ + H5VL_t *vol_plugin; /* VOL plugin information */ + H5VL_loc_params_t loc_params; herr_t ret_value; /* Return value */ FUNC_ENTER_API(FAIL) @@ -1405,18 +1405,20 @@ H5Aiterate2(hid_t loc_id, H5_index_t idx_type, H5_iter_order_t order, if(order <= H5_ITER_UNKNOWN || order >= H5_ITER_N) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid iteration order specified") - /* Build attribute operator info */ - attr_op.op_type = H5A_ATTR_OP_APP2; - attr_op.u.app_op2 = op; + loc_params.type = H5VL_OBJECT_BY_SELF; + loc_params.obj_type = H5I_get_type(loc_id); - /* Call attribute iteration routine */ - last_attr = start_idx = (idx ? *idx : 0); - if((ret_value = H5O_attr_iterate(loc_id, H5AC_ind_dxpl_id, idx_type, order, start_idx, &last_attr, &attr_op, op_data)) < 0) - HERROR(H5E_ATTR, H5E_BADITER, "error iterating over attributes"); + /* get the file object */ + if(NULL == (obj = (void *)H5I_object(loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid file identifier") + /* get the plugin pointer */ + if (NULL == (vol_plugin = (H5VL_t *)H5I_get_aux(loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "ID does not contain VOL information") - /* Set the last attribute information */ - if(idx) - *idx = last_attr; + /* iterate over the links through the VOL */ + if((ret_value = H5VL_attr_iterate(obj, loc_params, vol_plugin, idx_type, order, idx, + op, op_data, H5AC_dxpl_id, H5_EVENT_QUEUE_NULL)) < 0) + HGOTO_ERROR(H5E_SYM, H5E_BADITER, FAIL, "link iteration failed") done: FUNC_LEAVE_API(ret_value) @@ -1471,15 +1473,9 @@ H5Aiterate_by_name(hid_t loc_id, const char *obj_name, H5_index_t idx_type, H5_iter_order_t order, hsize_t *idx, H5A_operator2_t op, void *op_data, hid_t lapl_id) { - H5G_loc_t loc; /* Object location */ - H5G_loc_t obj_loc; /* Location used to open group */ - H5G_name_t obj_path; /* Opened object group hier. path */ - H5O_loc_t obj_oloc; /* Opened object object location */ - hbool_t loc_found = FALSE; /* Entry at 'obj_name' found */ - hid_t obj_loc_id = (-1); /* ID for object located */ - H5A_attr_iter_op_t attr_op; /* Attribute operator */ - hsize_t start_idx; /* Index of attribute to start iterating at */ - hsize_t last_attr; /* Index of last attribute examined */ + void *obj = NULL; /* object token of loc_id */ + H5VL_t *vol_plugin; /* VOL plugin information */ + H5VL_loc_params_t loc_params; herr_t ret_value; /* Return value */ FUNC_ENTER_API(FAIL) @@ -1489,8 +1485,6 @@ H5Aiterate_by_name(hid_t loc_id, const char *obj_name, H5_index_t idx_type, /* check arguments */ if(H5I_ATTR == H5I_get_type(loc_id)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "location is not valid for an attribute") - if(H5G_loc(loc_id, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") if(!obj_name || !*obj_name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no object name") if(idx_type <= H5_INDEX_UNKNOWN || idx_type >= H5_INDEX_N) @@ -1503,55 +1497,24 @@ H5Aiterate_by_name(hid_t loc_id, const char *obj_name, H5_index_t idx_type, if(TRUE != H5P_isa_class(lapl_id, H5P_LINK_ACCESS)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not link access property list ID") - /* Set up opened group location to fill in */ - obj_loc.oloc = &obj_oloc; - obj_loc.path = &obj_path; - H5G_loc_reset(&obj_loc); - - /* Find the object's location */ - if(H5G_loc_find(&loc, obj_name, &obj_loc/*out*/, lapl_id, H5AC_ind_dxpl_id) < 0) - HGOTO_ERROR(H5E_ATTR, H5E_NOTFOUND, FAIL, "object not found") - loc_found = TRUE; - - /* Open the object */ - if((obj_loc_id = H5O_open_by_loc(&obj_loc, lapl_id, H5AC_ind_dxpl_id, TRUE)) < 0) - HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, FAIL, "unable to open object") - - /* get the native object from the ID created by the object header and create - a "VOL object" ID */ - { - void *temp_obj = NULL; - H5I_type_t obj_type; - obj_type = H5I_get_type(obj_loc_id); - if(NULL == (temp_obj = H5I_remove(obj_loc_id))) - HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to open object") - /* Get an atom for the datatype */ - if((obj_loc_id = H5VL_native_register(obj_type, temp_obj, TRUE)) < 0) - HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to register datatype") - } - - /* Build attribute operator info */ - attr_op.op_type = H5A_ATTR_OP_APP2; - attr_op.u.app_op2 = op; + loc_params.type = H5VL_OBJECT_BY_NAME; + loc_params.obj_type = H5I_get_type(loc_id); + loc_params.loc_data.loc_by_name.name = obj_name; + loc_params.loc_data.loc_by_name.plist_id = lapl_id; - /* Call attribute iteration routine */ - last_attr = start_idx = (idx ? *idx : 0); - if((ret_value = H5O_attr_iterate(obj_loc_id, H5AC_ind_dxpl_id, idx_type, order, start_idx, &last_attr, &attr_op, op_data)) < 0) - HERROR(H5E_ATTR, H5E_BADITER, "error iterating over attributes"); + /* get the file object */ + if(NULL == (obj = (void *)H5I_object(loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid file identifier") + /* get the plugin pointer */ + if (NULL == (vol_plugin = (H5VL_t *)H5I_get_aux(loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "ID does not contain VOL information") - /* Set the last attribute information */ - if(idx) - *idx = last_attr; + /* iterate over the links through the VOL */ + if((ret_value = H5VL_attr_iterate(obj, loc_params, vol_plugin, idx_type, order, idx, + op, op_data, H5AC_dxpl_id, H5_EVENT_QUEUE_NULL)) < 0) + HGOTO_ERROR(H5E_SYM, H5E_BADITER, FAIL, "attribute iteration failed") done: - /* Release resources */ - if(obj_loc_id > 0) { - if(H5I_dec_app_ref(obj_loc_id) < 0) - HDONE_ERROR(H5E_ATTR, H5E_CANTDEC, FAIL, "unable to close temporary object") - } /* end if */ - else if(loc_found && H5G_loc_free(&obj_loc) < 0) - HDONE_ERROR(H5E_ATTR, H5E_CANTRELEASE, FAIL, "can't free location") - FUNC_LEAVE_API(ret_value) } /* H5Aiterate_by_name() */ diff --git a/src/H5Gprivate.h b/src/H5Gprivate.h index e159695..52f895c 100644 --- a/src/H5Gprivate.h +++ b/src/H5Gprivate.h @@ -202,7 +202,7 @@ H5_DLL herr_t H5G_get_shared_count(H5G_t *grp); H5_DLL herr_t H5G_mount(H5G_t *grp); H5_DLL hbool_t H5G_mounted(H5G_t *grp); H5_DLL herr_t H5G_unmount(H5G_t *grp); -H5_DLL hid_t H5G_get_create_plist(H5G_t *grp); + #ifndef H5_NO_DEPRECATED_SYMBOLS H5_DLL H5G_obj_t H5G_map_obj_type(H5O_type_t obj_type); #endif /* H5_NO_DEPRECATED_SYMBOLS */ diff --git a/src/H5Tcommit.c b/src/H5Tcommit.c index 6c1dbb5..bb0a2ba 100644 --- a/src/H5Tcommit.c +++ b/src/H5Tcommit.c @@ -684,19 +684,20 @@ H5Tget_create_plist(hid_t dtype_id) /* Retrieve further information, if the datatype is committed */ if(status > 0) { - H5P_genplist_t *new_plist; /* New datatype creation property list */ + H5VL_t *vol_plugin; /* VOL plugin information */ + + /* get the plugin pointer */ + if (NULL == (vol_plugin = (H5VL_t *)H5I_get_aux(dtype_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "ID does not contain VOL information") /* get the named datatype object */ if(NULL == (type = (H5T_t *)H5VL_get_object(dtype_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid file identifier") - /* Get property list object for new TCPL */ - if(NULL == (new_plist = (H5P_genplist_t *)H5I_object(new_tcpl_id))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "can't get property list") - - /* Retrieve any object creation properties */ - if(H5O_get_create_plist(&type->oloc, H5AC_ind_dxpl_id, new_plist) < 0) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTGET, FAIL, "can't get object creation info") + /* get the rest of the plist through the VOL */ + if(H5VL_datatype_get(type, vol_plugin, H5VL_DATATYPE_GET_TCPL, + H5AC_dxpl_id, H5_EVENT_QUEUE_NULL, new_tcpl_id) < 0) + HGOTO_ERROR(H5E_INTERNAL, H5E_CANTGET, FAIL, "unable to get datatype") } /* end if */ /* Set the return value */ diff --git a/src/H5VL.c b/src/H5VL.c index 74760d4..20d6dd7 100644 --- a/src/H5VL.c +++ b/src/H5VL.c @@ -504,6 +504,38 @@ done: /*------------------------------------------------------------------------- + * Function: H5VLattr_iterate + * + * Purpose: Iterate over attrs in a group + * + * Return: Success: non negative + * Failure: negative + * + * Programmer: Mohamad Chaarawi + * June, 2013 + * + *------------------------------------------------------------------------- + */ +herr_t H5VLattr_iterate(void *obj, H5VL_loc_params_t loc_params, H5VL_t *vol_plugin, + H5_index_t idx_type, H5_iter_order_t order, hsize_t *n, + H5A_operator2_t op, void *op_data, hid_t dxpl_id, void UNUSED **req) +{ + herr_t ret_value = SUCCEED; + + FUNC_ENTER_API(FAIL) + + if(NULL == obj || NULL == vol_plugin || NULL == vol_plugin->cls) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid object/VOL class pointer") + if((ret_value = H5VL_attr_iterate(obj, loc_params, vol_plugin, idx_type, order, n, + op, op_data, dxpl_id, H5_EVENT_QUEUE_NULL)) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, FAIL, "Attr iteration failed") + +done: + FUNC_LEAVE_API(ret_value) +} /* end H5VLattr_iterate() */ + + +/*------------------------------------------------------------------------- * Function: H5VLattr_get * * Purpose: Get specific information about the attribute through the VOL @@ -781,6 +813,51 @@ done: /*------------------------------------------------------------------------- + * Function: H5VLdatatype_get + * + * Purpose: Get specific information about the datatype through the VOL + * + * Return: Success: non negative + * + * Failure: negative + * + * Programmer: Mohamad Chaarawi + * June, 2013 + * + *------------------------------------------------------------------------- + */ +herr_t +H5VLdatatype_get(void *obj, H5VL_t *vol_plugin, H5VL_datatype_get_t get_type, + hid_t dxpl_id, void UNUSED **req, va_list arguments) +{ + herr_t ret_value = SUCCEED; + + FUNC_ENTER_API(FAIL) + + if(NULL == obj || NULL == vol_plugin || NULL == vol_plugin->cls) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid object/VOL class pointer") + + switch (get_type) { + /* H5Tget_create_plist */ + case H5VL_DATATYPE_GET_TCPL: + { + hid_t *new_tcpl_id = va_arg (arguments, hid_t *); + + if((ret_value = H5VL_datatype_get(obj, vol_plugin, get_type, dxpl_id, + H5_EVENT_QUEUE_NULL, new_tcpl_id)) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, FAIL, "unable to get datatype information") + break; + } + default: + HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "can't get this type of information from datatype") + } + +done: + FUNC_LEAVE_API(ret_value) +} /* end H5VLdatatype_get() */ + + +/*------------------------------------------------------------------------- * Function: H5VLdatatype_close * * Purpose: Closes a datatype through the VOL diff --git a/src/H5VLint.c b/src/H5VLint.c index 90ed9d6..684daeb 100644 --- a/src/H5VLint.c +++ b/src/H5VLint.c @@ -586,6 +586,39 @@ done: /*------------------------------------------------------------------------- + * Function: H5VL_attr_iterate + * + * Purpose: Iterate over attrs in an object + * + * Return: Success: non negative + * Failure: negative + * + * Programmer: Mohamad Chaarawi + * June, 2013 + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL_attr_iterate(void *obj, H5VL_loc_params_t loc_params, H5VL_t *vol_plugin, + H5_index_t idx_type, H5_iter_order_t order, hsize_t *n, + H5A_operator2_t op, void *op_data, hid_t dxpl_id, hid_t UNUSED event_q) +{ + herr_t ret_value = SUCCEED; + + FUNC_ENTER_NOAPI(FAIL) + + if(NULL == vol_plugin->cls->attr_cls.iterate) + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "vol plugin has no `attr iterate' method") + if((ret_value = (vol_plugin->cls->attr_cls.iterate)(obj, loc_params, idx_type, order, n, op, + op_data, dxpl_id, H5_REQUEST_NULL)) < 0) + HGOTO_ERROR(H5E_VOL, H5E_BADITER, FAIL, "iteration failed") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_attr_iterate() */ + + +/*------------------------------------------------------------------------- * Function: H5VL_attr_get * * Purpose: Get specific information about the attribute through the VOL @@ -831,6 +864,42 @@ done: /*------------------------------------------------------------------------- + * Function: H5VL_datatype_get + * + * Purpose: Get specific information about the datatype through the VOL + * + * Return: Success: non negative + * + * Failure: negative + * + * Programmer: Mohamad Chaarawi + * June, 2013 + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL_datatype_get(void *obj, H5VL_t *vol_plugin, H5VL_datatype_get_t get_type, + hid_t dxpl_id, hid_t event_q, ...) +{ + va_list arguments; /* argument list passed from the API call */ + herr_t ret_value = SUCCEED; + + FUNC_ENTER_NOAPI(FAIL) + + if(NULL == vol_plugin->cls->datatype_cls.get) + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "vol plugin has no `datatype get' method") + va_start (arguments, event_q); + if((ret_value = (vol_plugin->cls->datatype_cls.get)(obj, get_type, dxpl_id, + H5_REQUEST_NULL, arguments)) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "get failed") + va_end (arguments); + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_datatype_get() */ + + +/*------------------------------------------------------------------------- * Function: H5VL_datatype_close * * Purpose: Closes a datatype through the VOL diff --git a/src/H5VLnative.c b/src/H5VLnative.c index 346adc7..d67b012 100644 --- a/src/H5VLnative.c +++ b/src/H5VLnative.c @@ -66,6 +66,9 @@ static void *H5VL_native_attr_create(void *obj, H5VL_loc_params_t loc_params, co static void *H5VL_native_attr_open(void *obj, H5VL_loc_params_t loc_params, const char *attr_name, hid_t aapl_id, hid_t dxpl_id, void **req); static herr_t H5VL_native_attr_read(void *attr, hid_t dtype_id, void *buf, hid_t dxpl_id, void **req); static herr_t H5VL_native_attr_write(void *attr, hid_t dtype_id, const void *buf, hid_t dxpl_id, void **req); +static herr_t H5VL_native_attr_iterate(void *obj, H5VL_loc_params_t loc_params, + H5_index_t idx_type, H5_iter_order_t order, hsize_t *n, + H5A_operator2_t op, void *op_data, hid_t dxpl_id, void **req); static herr_t H5VL_native_attr_get(void *obj, H5VL_attr_get_t get_type, hid_t dxpl_id, void **req, va_list arguments); static herr_t H5VL_native_attr_remove(void *obj, H5VL_loc_params_t loc_params, const char *attr_name, hid_t dxpl_id, void **req); static herr_t H5VL_native_attr_close(void *attr, hid_t dxpl_id, void **req); @@ -74,6 +77,7 @@ static herr_t H5VL_native_attr_close(void *attr, hid_t dxpl_id, void **req); static void *H5VL_native_datatype_commit(void *obj, H5VL_loc_params_t loc_params, const char *name, hid_t type_id, hid_t lcpl_id, hid_t tcpl_id, hid_t tapl_id, hid_t dxpl_id, void **req); static void *H5VL_native_datatype_open(void *obj, H5VL_loc_params_t loc_params, const char *name, hid_t tapl_id, hid_t dxpl_id, void **req); static ssize_t H5VL_native_datatype_get_binary(void *obj, unsigned char *buf, size_t size, hid_t dxpl_id, void **req); +static herr_t H5VL_native_datatype_get(void *dt, H5VL_datatype_get_t get_type, hid_t dxpl_id, void **req, va_list arguments); static herr_t H5VL_native_datatype_close(void *dt, hid_t dxpl_id, void **req); /* Dataset callbacks */ @@ -139,6 +143,7 @@ static H5VL_class_t H5VL_native_g = { H5VL_native_attr_open, /* open */ H5VL_native_attr_read, /* read */ H5VL_native_attr_write, /* write */ + H5VL_native_attr_iterate, /* iterate */ H5VL_native_attr_get, /* get */ H5VL_native_attr_remove, /* remove */ H5VL_native_attr_close /* close */ @@ -146,7 +151,8 @@ static H5VL_class_t H5VL_native_g = { { /* datatype_cls */ H5VL_native_datatype_commit, /* commit */ H5VL_native_datatype_open, /* open */ - H5VL_native_datatype_get_binary, /* get_size */ + H5VL_native_datatype_get_binary, /* get_binary */ + H5VL_native_datatype_get, /* get */ H5VL_native_datatype_close /* close */ }, { /* dataset_cls */ @@ -332,7 +338,7 @@ done: /*--------------------------------------------------------------------------- * Function: H5VL_native_register * - * Purpose: utility routine to register and ID with the native VOL plugin + * Purpose: utility routine to register an ID with the native VOL plugin * as an auxilary object * * Returns: Non-negative on success or negative on failure @@ -627,6 +633,116 @@ done: /*------------------------------------------------------------------------- + * Function: H5VL_native_attr_iterate + * + * Purpose: Iterates through attrs in an object + * + * Return: Success: 0 + * Failure: -1 + * + * Programmer: Mohamad Chaarawi + * June, 2013 + * + *------------------------------------------------------------------------- + */ +static herr_t H5VL_native_attr_iterate(void *obj, H5VL_loc_params_t loc_params, H5_index_t idx_type, + H5_iter_order_t order, hsize_t *idx, H5A_operator2_t op, + void *op_data, hid_t UNUSED dxpl_id, void UNUSED **req) +{ + H5G_loc_t loc; /* Object location */ + H5G_loc_t obj_loc; /* Location used to open group */ + H5G_name_t obj_path; /* Opened object group hier. path */ + H5O_loc_t obj_oloc; /* Opened object object location */ + hbool_t loc_found = FALSE; /* Entry at 'obj_name' found */ + hid_t obj_loc_id = (-1); /* ID for object located */ + H5A_attr_iter_op_t attr_op; /* Attribute operator */ + hsize_t start_idx; /* Index of attribute to start iterating at */ + hsize_t last_attr; /* Index of last attribute examined */ + void *temp_obj = NULL; + H5I_type_t obj_type; + herr_t ret_value; /* Return value */ + + FUNC_ENTER_NOAPI_NOINIT + + /* check arguments */ + if(H5G_loc_real(obj, loc_params.obj_type, &loc) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") + + /* Build attribute operator info */ + attr_op.op_type = H5A_ATTR_OP_APP2; + attr_op.u.app_op2 = op; + + /* Call attribute iteration routine */ + last_attr = start_idx = (idx ? *idx : 0); + + /* Iterate over the links */ + if(loc_params.type == H5VL_OBJECT_BY_SELF) { + /* Get an atom for the object */ + if((obj_loc_id = H5VL_native_register(loc_params.obj_type, obj, TRUE)) < 0) + HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to register object"); + } + else if(loc_params.type == H5VL_OBJECT_BY_NAME) { + /* Set up opened group location to fill in */ + obj_loc.oloc = &obj_oloc; + obj_loc.path = &obj_path; + H5G_loc_reset(&obj_loc); + + /* Find the object's location */ + if(H5G_loc_find(&loc, loc_params.loc_data.loc_by_name.name, &obj_loc/*out*/, + loc_params.loc_data.loc_by_name.plist_id, H5AC_ind_dxpl_id) < 0) + HGOTO_ERROR(H5E_ATTR, H5E_NOTFOUND, FAIL, "object not found"); + loc_found = TRUE; + + /* Open the object */ + if((obj_loc_id = H5O_open_by_loc(&obj_loc, loc_params.loc_data.loc_by_name.plist_id, + H5AC_ind_dxpl_id, TRUE)) < 0) + HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, FAIL, "unable to open object"); + + /* get the native object from the ID created by the object header and create + a "VOL object" ID */ + obj_type = H5I_get_type(obj_loc_id); + if(NULL == (temp_obj = H5I_remove(obj_loc_id))) + HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to open object"); + /* Get an atom for the object */ + if((obj_loc_id = H5VL_native_register(obj_type, temp_obj, TRUE)) < 0) + HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to register datatype"); + } + else { + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "unknown link iterate params"); + } + + /* Do the real iteration */ + if((ret_value = H5O_attr_iterate(obj_loc_id, H5AC_ind_dxpl_id, idx_type, order, + start_idx, &last_attr, &attr_op, op_data)) < 0) + HERROR(H5E_ATTR, H5E_BADITER, "error iterating over attributes"); + + /* Set the last attribute information */ + if(idx) + *idx = last_attr; + +done: + /* Release resources */ + if(loc_params.type == H5VL_OBJECT_BY_SELF) { + if(obj_loc_id >= 0 && NULL == H5I_remove(obj_loc_id)) + HDONE_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to open object"); + } + else if(loc_params.type == H5VL_OBJECT_BY_NAME) { + if(obj_loc_id >= 0) { + if(H5I_dec_app_ref(obj_loc_id) < 0) + HDONE_ERROR(H5E_ATTR, H5E_CANTDEC, FAIL, "unable to close temporary object"); + } /* end if */ + else if(loc_found && H5G_loc_free(&obj_loc) < 0) + HDONE_ERROR(H5E_ATTR, H5E_CANTRELEASE, FAIL, "can't free location"); + } + else { + HDONE_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "unknown link iterate params"); + } + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_native_attr_iterate() */ + + +/*------------------------------------------------------------------------- * Function: H5VL_native_attr_get * * Purpose: Gets certain information about an attribute @@ -1127,6 +1243,54 @@ done: /*------------------------------------------------------------------------- + * Function: H5VL_native_datatype_get + * + * Purpose: Gets certain information about a datatype + * + * Return: Success: 0 + * Failure: -1 + * + * Programmer: Mohamad Chaarawi + * June, 2013 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5VL_native_datatype_get(void *obj, H5VL_datatype_get_t get_type, + hid_t UNUSED dxpl_id, void UNUSED **req, va_list arguments) +{ + H5T_t *dt = (H5T_t *)obj; + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI_NOINIT + + switch (get_type) { + /* H5Tget_create_plist */ + case H5VL_DATATYPE_GET_TCPL: + { + H5P_genplist_t *new_plist; /* New datatype creation property list */ + hid_t tcpl_id = va_arg (arguments, hid_t); + + /* Get property list object for new TCPL */ + if(NULL == (new_plist = (H5P_genplist_t *)H5I_object(tcpl_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "can't get property list"); + + /* Retrieve any object creation properties */ + if(H5O_get_create_plist(&dt->oloc, H5AC_ind_dxpl_id, new_plist) < 0) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTGET, FAIL, "can't get object creation info"); + + break; + } + default: + HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "can't get this type of information from datatype") + } + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_native_datatype_get() */ + + +/*------------------------------------------------------------------------- * Function: H5VL_native_datatype_close * * Purpose: Closes an datatype. diff --git a/src/H5VLprivate.h b/src/H5VLprivate.h index b42ebb1..0e1b596 100644 --- a/src/H5VLprivate.h +++ b/src/H5VLprivate.h @@ -56,6 +56,9 @@ H5_DLL void *H5VL_attr_create(void *obj, H5VL_loc_params_t loc_params, H5VL_t *v H5_DLL void *H5VL_attr_open(void *obj, H5VL_loc_params_t loc_params, H5VL_t *vol_plugin, const char *name, hid_t aapl_id, hid_t dxpl_id, hid_t event_q); H5_DLL herr_t H5VL_attr_read(void *attr, H5VL_t *vol_plugin, hid_t dtype_id, void *buf, hid_t dxpl_id, hid_t event_q); H5_DLL herr_t H5VL_attr_write(void *attr, H5VL_t *vol_plugin, hid_t dtype_id, const void *buf, hid_t dxpl_id, hid_t event_q); +H5_DLL herr_t H5VL_attr_iterate(void *obj, H5VL_loc_params_t loc_params, H5VL_t *vol_plugin, + H5_index_t idx_type, H5_iter_order_t order, hsize_t *n, + H5A_operator2_t op, void *op_data, hid_t dxpl_id, hid_t event_q); H5_DLL herr_t H5VL_attr_get(void *attr, H5VL_t *vol_plugin, H5VL_attr_get_t get_type, hid_t dxpl_id, hid_t event_q, ...); H5_DLL herr_t H5VL_attr_remove(void *obj, H5VL_loc_params_t loc_params, H5VL_t *vol_plugin, const char *attr_name, hid_t dxpl_id, hid_t event_q); H5_DLL herr_t H5VL_attr_close(void *attr, H5VL_t *vol_plugin, hid_t dxpl_id, hid_t event_q); @@ -71,6 +74,7 @@ H5_DLL herr_t H5VL_dataset_close(void *dset, H5VL_t *vol_plugin, hid_t dxpl_id, H5_DLL void *H5VL_datatype_commit(void *obj, H5VL_loc_params_t loc_params, H5VL_t *vol_plugin, const char *name, hid_t type_id, hid_t lcpl_id, hid_t tcpl_id, hid_t tapl_id, hid_t dxpl_id, hid_t event_q); H5_DLL void *H5VL_datatype_open(void *obj, H5VL_loc_params_t loc_params, H5VL_t *vol_plugin, const char *name, hid_t tapl_id, hid_t dxpl_id, hid_t event_q); H5_DLL ssize_t H5VL_datatype_get_binary(void *obj, H5VL_t *vol_plugin, unsigned char *buf, size_t size, hid_t dxpl_id, hid_t event_q); +H5_DLL herr_t H5VL_datatype_get(void *dt, H5VL_t *vol_plugin, H5VL_datatype_get_t get_type, hid_t dxpl_id, hid_t event_q, ...); H5_DLL herr_t H5VL_datatype_close(void *dt, H5VL_t *vol_plugin, hid_t dxpl_id, hid_t event_q); H5_DLL void *H5VL_file_create(H5VL_t **vol_plugin, const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id, hid_t dxpl_id, hid_t event_q); diff --git a/src/H5VLpublic.h b/src/H5VLpublic.h index 854c21f..2428dd3 100644 --- a/src/H5VLpublic.h +++ b/src/H5VLpublic.h @@ -23,6 +23,7 @@ #include "stdarg.h" #include "H5public.h" +#include "H5Apublic.h" /* Attributes */ #include "H5Fpublic.h" #include "H5Lpublic.h" #include "H5Opublic.h" @@ -120,6 +121,11 @@ typedef enum H5VL_group_get_t { H5VL_GROUP_GET_INFO = 1 /*group info */ } H5VL_group_get_t; +/* types for all datatype get API routines */ +typedef enum H5VL_datatype_get_t { + H5VL_DATATYPE_GET_TCPL = 0 /*datatype creation property list */ +} H5VL_datatype_get_t; + /* link create types for VOL */ typedef enum H5VL_link_create_type_t { H5VL_LINK_CREATE_HARD = 0, @@ -214,6 +220,9 @@ typedef struct H5VL_attr_class_t { void *(*open) (void *obj, H5VL_loc_params_t loc_params, const char *attr_name, hid_t aapl_id, hid_t dxpl_id, void **req); herr_t (*read) (void *attr, hid_t mem_type_id, void *buf, hid_t dxpl_id, void **req); herr_t (*write) (void *attr, hid_t mem_type_id, const void *buf, hid_t dxpl_id, void **req); + herr_t (*iterate) (void *obj, H5VL_loc_params_t loc_params, + H5_index_t idx_type, H5_iter_order_t order, hsize_t *n, + H5A_operator2_t op, void *op_data, hid_t dxpl_id, void **req); herr_t (*get) (void *attr, H5VL_attr_get_t get_type, hid_t dxpl_id, void **req, va_list arguments); herr_t (*remove)(void *obj, H5VL_loc_params_t loc_params, const char *attr_name, hid_t dxpl_id, void **req); herr_t (*close) (void *attr, hid_t dxpl_id, void **req); @@ -225,6 +234,7 @@ typedef struct H5VL_datatype_class_t { hid_t lcpl_id, hid_t tcpl_id, hid_t tapl_id, hid_t dxpl_id, void **req); void *(*open) (void *obj, H5VL_loc_params_t loc_params, const char * name, hid_t tapl_id, hid_t dxpl_id, void **req); ssize_t (*get_binary) (void *obj, unsigned char *buf, size_t size, hid_t dxpl_id, void **req); + herr_t (*get) (void *obj, H5VL_datatype_get_t get_type, hid_t dxpl_id, void **req, va_list arguments); herr_t (*close) (void *dt, hid_t dxpl_id, void **req); } H5VL_datatype_class_t; @@ -344,6 +354,8 @@ H5_DLL void *H5VLattr_create(void *obj, H5VL_loc_params_t loc_params, H5VL_t *vo H5_DLL void *H5VLattr_open(void *obj, H5VL_loc_params_t loc_params, H5VL_t *vol_plugin, const char *name, hid_t aapl_id, hid_t dxpl_id, void **req); H5_DLL herr_t H5VLattr_read(void *attr, H5VL_t *vol_plugin, hid_t dtype_id, void *buf, hid_t dxpl_id, void **req); H5_DLL herr_t H5VLattr_write(void *attr, H5VL_t *vol_plugin, hid_t dtype_id, const void *buf, hid_t dxpl_id, void **req); +H5_DLL herr_t H5VLattr_iterate(void *obj, H5VL_loc_params_t loc_params, H5VL_t *vol_plugin, + H5_index_t idx_type, H5_iter_order_t order, hsize_t *n, H5A_operator2_t op, void *op_data, hid_t dxpl_id, void **req); H5_DLL herr_t H5VLattr_get(void *attr, H5VL_t *vol_plugin, H5VL_attr_get_t get_type, hid_t dxpl_id, void **req, va_list arguments); H5_DLL herr_t H5VLattr_remove(void *obj, H5VL_loc_params_t loc_params, H5VL_t *vol_plugin, const char *attr_name, hid_t dxpl_id, void **req); H5_DLL herr_t H5VLattr_close(void *attr, H5VL_t *vol_plugin, hid_t dxpl_id, void **req); @@ -361,6 +373,7 @@ H5_DLL herr_t H5VLdataset_close(void *dset, H5VL_t *vol_plugin, hid_t dxpl_id, v H5_DLL void *H5VLdatatype_commit(void *obj, H5VL_loc_params_t loc_params, H5VL_t *vol_plugin, const char *name, hid_t type_id, hid_t lcpl_id, hid_t tcpl_id, hid_t tapl_id, hid_t dxpl_id, void **req); H5_DLL void *H5VLdatatype_open(void *obj, H5VL_loc_params_t loc_params, H5VL_t *vol_plugin, const char *name, hid_t tapl_id, hid_t dxpl_id, void **req); H5_DLL ssize_t H5VLdatatype_get_binary(void *obj, H5VL_t *vol_plugin, unsigned char *buf, size_t size, hid_t dxpl_id, void **req); +H5_DLL herr_t H5VLdatatype_get(void *obj, H5VL_t *vol_plugin, H5VL_datatype_get_t get_type, hid_t dxpl_id, void **req, va_list arguments); H5_DLL herr_t H5VLdatatype_close(void *dt, H5VL_t *vol_plugin, hid_t dxpl_id, void **req); /* FILE OBJECT ROUTINES */ -- cgit v0.12