From b27392e36a73889448500eced4f37e59c06b2a02 Mon Sep 17 00:00:00 2001 From: Mohamad Chaarawi Date: Tue, 16 Jul 2013 13:46:57 -0500 Subject: [svn-r23907] - add a new routine: herr_t H5VLget_object(hid_t obj_id, void **obj, H5VL_t **vol_plugin) to retrieve object pointer from given ID. This also optionally returns a pointer to a vol_plugin if it is not NULL. - remove the previously added routine to retrieve the VOL datatype object since the new one does that. - add a MAX_LIB_VOL_VALUE that reserves 128 value for internal VOL plugins, not that we need that many. --- src/H5Tcommit.c | 33 --------------------------------- src/H5Tpublic.h | 3 --- src/H5VL.c | 52 +++++++++++++++++++++++++++++++++++++++++++++++++++- src/H5VLpublic.h | 7 ++++--- 4 files changed, 55 insertions(+), 40 deletions(-) diff --git a/src/H5Tcommit.c b/src/H5Tcommit.c index 912fab5..e55a498 100644 --- a/src/H5Tcommit.c +++ b/src/H5Tcommit.c @@ -915,39 +915,6 @@ H5T_update_shared(H5T_t *dt) /*------------------------------------------------------------------------- - * Function: H5Tget_named_type - * - * Purpose: returns the VOL object or the named datatype structure - * if it exists. This is the public wrapper for H5T_get_named_type. - * - * Return: Non-negative on success/Negative on failure - * - * Programmer: Mohamad Chaarawi - * June 2013 - * - *------------------------------------------------------------------------- - */ -herr_t -H5Tget_vol_named_type(hid_t type_id, void **dt_obj) -{ - H5T_t *type; /* datatype for operation */ - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_API(FAIL) - H5TRACE2("e", "i**x", type_id, dt_obj); - - /* Check arguments */ - if(NULL == (type = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") - - *dt_obj = H5T_get_named_type(type); - -done: - FUNC_LEAVE_API(ret_value) -} /* end H5Tget_named_type() */ - - -/*------------------------------------------------------------------------- * Function: H5T_get_named_type * * Purpose: returns the VOL object or the named datatype structure diff --git a/src/H5Tpublic.h b/src/H5Tpublic.h index 046d454..d646ef1 100644 --- a/src/H5Tpublic.h +++ b/src/H5Tpublic.h @@ -592,9 +592,6 @@ H5_DLL htri_t H5Tcompiler_conv(hid_t src_id, hid_t dst_id); H5_DLL herr_t H5Tconvert(hid_t src_id, hid_t dst_id, size_t nelmts, void *buf, void *background, hid_t plist_id); -/* VOL named datatype rouines */ -H5_DLL herr_t H5Tget_vol_named_type(hid_t type_id, void **dt_obj); - /* Symbols defined for compatibility with previous versions of the HDF5 API. * * Use of these symbols is deprecated. diff --git a/src/H5VL.c b/src/H5VL.c index 72a4480..0f33ba2 100644 --- a/src/H5VL.c +++ b/src/H5VL.c @@ -235,7 +235,12 @@ H5VLregister(const H5VL_class_t *cls) /* Check arguments */ if(!cls) HGOTO_ERROR(H5E_ARGS, H5E_UNINITIALIZED, FAIL, "null class pointer is disallowed") - /* MSC - check if required callback are defined */ + + if(cls->value < MAX_VOL_LIB_VALUE) + HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, + "registered class value must not be smaller than %d", MAX_VOL_LIB_VALUE) + + /* MSC - check if required callback are defined?? */ /* Create the new class ID */ if((ret_value=H5VL_register(cls, sizeof(H5VL_class_t), TRUE)) < 0) @@ -379,6 +384,51 @@ done: } /* H5VLregister_object */ +/*--------------------------------------------------------------------------- + * Function: H5VLget_object + * + * Purpose: Retrieve the object pointer associated with the ID. This + * also optionally returns the H5VL_t struct that this ID + * belongs to, if the user passes a valid pointer value. + * + * Returns: Non-negative on success or negative on failure + * + * Programmer: Mohamad Chaarawi + * July, 2013 + * + *--------------------------------------------------------------------------- + */ +herr_t +H5VLget_object(hid_t obj_id, void **obj, H5VL_t **vol_plugin) +{ + H5VL_t *temp_vol; + hid_t ret_value = SUCCEED; + + FUNC_ENTER_API(FAIL) + + /* Check args */ + if(!obj) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid object pointer") + + /* get the plugin pointer */ + if (NULL == (temp_vol = (H5VL_t *)H5I_get_aux(obj_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "ID does not contain VOL information") + + if(NATIVE == temp_vol->cls->value) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "cannot call public function on library type") + + /* if the user requested the plugin pointer, return it */ + if(vol_plugin) + *vol_plugin = temp_vol; + + if(NULL == (*obj = H5VL_get_object(obj_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "ID does not contain a valid object") + +done: + FUNC_LEAVE_API(ret_value) +} /* H5VLget_object */ + + /*------------------------------------------------------------------------- * Function: H5VLattr_create * diff --git a/src/H5VLpublic.h b/src/H5VLpublic.h index 2428dd3..fa23ce9 100644 --- a/src/H5VLpublic.h +++ b/src/H5VLpublic.h @@ -308,10 +308,10 @@ typedef struct H5VL_async_class_t { herr_t (*wait) (void **, H5_status_t *); } H5VL_async_class_t; -/* enum value to identify the class of a VOL plugin (mostly for comparison purposes */ +/* enum value to identify the class of a VOL plugin (mostly for comparison purposes) */ typedef enum H5VL_class_value_t { - NATIVE = 0, - DUMMY = 1 + NATIVE = 0, /* This should be first */ + MAX_VOL_LIB_VALUE = 128 /* This should be last */ } H5VL_class_value_t; /* Class information for each VOL driver */ @@ -423,6 +423,7 @@ H5_DLL herr_t H5VLunregister(hid_t plugin_id); H5_DLL htri_t H5VLis_registered(hid_t id); H5_DLL ssize_t H5VLget_plugin_name(hid_t id, char *name/*out*/, size_t size); H5_DLL hid_t H5VLobject_register(void *obj, H5I_type_t obj_type, const H5VL_class_t *cls); +H5_DLL herr_t H5VLget_object(hid_t obj_id, void **obj, H5VL_t **vol_plugin); #ifdef __cplusplus } -- cgit v0.12