diff options
author | Mohamad Chaarawi <chaarawi@hdfgroup.org> | 2013-07-16 18:46:57 (GMT) |
---|---|---|
committer | Mohamad Chaarawi <chaarawi@hdfgroup.org> | 2013-07-16 18:46:57 (GMT) |
commit | b27392e36a73889448500eced4f37e59c06b2a02 (patch) | |
tree | e686b711b51107b73ea090106e72b4857bbd84f6 /src/H5VL.c | |
parent | f772c1110e4cc158be91bdc1a5ef13e5ed596d15 (diff) | |
download | hdf5-b27392e36a73889448500eced4f37e59c06b2a02.zip hdf5-b27392e36a73889448500eced4f37e59c06b2a02.tar.gz hdf5-b27392e36a73889448500eced4f37e59c06b2a02.tar.bz2 |
[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.
Diffstat (limited to 'src/H5VL.c')
-rw-r--r-- | src/H5VL.c | 52 |
1 files changed, 51 insertions, 1 deletions
@@ -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 * |