diff options
author | Quincey Koziol <koziol@hdfgroup.org> | 2019-01-11 00:00:13 (GMT) |
---|---|---|
committer | Quincey Koziol <koziol@hdfgroup.org> | 2019-01-11 00:00:13 (GMT) |
commit | 6d897f3c10241cbc50a728870d58269d15e36984 (patch) | |
tree | 64372b94782ec9808adcf459efafe21e8c94aa8b /src/H5VL.c | |
parent | a7e0ef996a63b87cc0295b58f37f037c848a6929 (diff) | |
download | hdf5-6d897f3c10241cbc50a728870d58269d15e36984.zip hdf5-6d897f3c10241cbc50a728870d58269d15e36984.tar.gz hdf5-6d897f3c10241cbc50a728870d58269d15e36984.tar.bz2 |
Add API routines to wrap and retrieve objects
Diffstat (limited to 'src/H5VL.c')
-rw-r--r-- | src/H5VL.c | 70 |
1 files changed, 70 insertions, 0 deletions
@@ -517,3 +517,73 @@ done: FUNC_LEAVE_API(ret_value) } /* H5VLcmp_connector_cls() */ + +/*--------------------------------------------------------------------------- + * Function: H5VLwrap_register + * + * Purpose: Wrap an internal object with a "wrap context" and register an + * hid_t for the resulting object. + * + * Note: This routine is mainly targeted toward wrapping objects for + * iteration routine callbacks (i.e. the callbacks from H5Aiterate*, + * H5Literate* / H5Lvisit*, and H5Ovisit* ). + * + * Return: Success: Non-negative hid_t for the object. + * Failure: Negative (H5I_INVALID_HID) + * + *--------------------------------------------------------------------------- + */ +hid_t +H5VLwrap_register(void *obj, H5I_type_t type) +{ + hid_t ret_value; /* Return value */ + + /* Use FUNC_ENTER_API_NOINIT here, so the API context doesn't get reset */ + FUNC_ENTER_API_NOINIT + H5TRACE2("i", "*xIt", obj, type); + + /* Check args */ + if(type <= H5I_BADID || type >= H5I_NTYPES) + HGOTO_ERROR(H5E_VOL, H5E_BADRANGE, H5I_INVALID_HID, "invalid type number") + if(NULL == obj) + HGOTO_ERROR(H5E_VOL, H5E_BADVALUE, H5I_INVALID_HID, "obj is NULL") + + /* Wrap the object and register an ID for it */ + if((ret_value = H5VL_wrap_register(type, obj, TRUE)) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to wrap object") + +done: + FUNC_LEAVE_API_NOINIT(ret_value) +} /* H5VLwrap_register() */ + + +/*--------------------------------------------------------------------------- + * Function: H5VLobject + * + * Purpose: Retrieve the object pointer associated with an hid_t for a. + * VOL object. + * + * Note: This routine is mainly targeted toward unwrapping objects for + * testing. + * + * Return: Success: Object pointer + * Failure: NULL + * + *--------------------------------------------------------------------------- + */ +void * +H5VLobject(hid_t id) +{ + void *ret_value; /* Return value */ + + FUNC_ENTER_API(NULL) + H5TRACE1("*x", "i", id); + + /* Retrieve the object pointer for the ID */ + if(NULL == (ret_value = H5VL_object(id))) + HGOTO_ERROR(H5E_VOL, H5E_CANTGET, NULL, "unable to retrieve object") + +done: + FUNC_LEAVE_API(ret_value) +} /* H5VLobject() */ + |