summaryrefslogtreecommitdiffstats
path: root/src/H5VLcallback.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/H5VLcallback.c')
-rw-r--r--src/H5VLcallback.c165
1 files changed, 117 insertions, 48 deletions
diff --git a/src/H5VLcallback.c b/src/H5VLcallback.c
index 03828fa..b785747 100644
--- a/src/H5VLcallback.c
+++ b/src/H5VLcallback.c
@@ -740,84 +740,89 @@ done:
/*-------------------------------------------------------------------------
- * Function: H5VL_free_wrap_ctx
+ * Function: H5VL_wrap_object
*
- * Purpose: Free object wrapping context for a connector
+ * Purpose: Wrap an object with connector
*
- * Return: Success: Non-negative
- * Failure: Negative
+ * Return: Success: Non-NULL
+ * Failure: NULL
*
*-------------------------------------------------------------------------
*/
-herr_t
-H5VL_free_wrap_ctx(const H5VL_class_t *connector, void *wrap_ctx)
+void *
+H5VL_wrap_object(const H5VL_class_t *connector, void *wrap_ctx, void *obj,
+ H5I_type_t obj_type)
{
- herr_t ret_value = SUCCEED; /* Return value */
+ void *ret_value; /* Return value */
- FUNC_ENTER_NOAPI(FAIL)
+ FUNC_ENTER_NOAPI(NULL)
/* Sanity checks */
HDassert(connector);
+ HDassert(obj);
- /* Only free wrap context, if it's non-NULL */
+ /* Only wrap object if there's a wrap context */
if(wrap_ctx) {
- /* Free the connector's object wrapping context */
- if((connector->wrap_cls.free_wrap_ctx)(wrap_ctx) < 0)
- HGOTO_ERROR(H5E_VOL, H5E_CANTRELEASE, FAIL, "connector wrap context free request failed")
+ /* Ask the connector to wrap the object */
+ if(NULL == (ret_value = (connector->wrap_cls.wrap_object)(obj, obj_type, wrap_ctx)))
+ HGOTO_ERROR(H5E_VOL, H5E_CANTGET, NULL, "can't wrap object")
} /* end if */
+ else
+ ret_value = obj;
done:
FUNC_LEAVE_NOAPI(ret_value)
-} /* end H5VL_free_wrap_ctx() */
+} /* end H5VL_wrap_object() */
/*---------------------------------------------------------------------------
- * Function: H5VLfree_wrap_ctx
+ * Function: H5VLwrap_object
*
- * Purpose: Release a VOL connector's object wrapping context
+ * Purpose: Asks a connector to wrap an underlying object.
*
- * Return: Success: Non-negative
- * Failure: Negative
+ * Return: Success: Non-NULL
+ * Failure: NULL
*
*---------------------------------------------------------------------------
*/
-herr_t
-H5VLfree_wrap_ctx(void *wrap_ctx, hid_t connector_id)
+void *
+H5VLwrap_object(void *obj, H5I_type_t obj_type, hid_t connector_id, void *wrap_ctx)
{
- H5VL_class_t *cls; /* VOL connector's class struct */
- herr_t ret_value = SUCCEED; /* Return value */
+ H5VL_class_t *cls; /* VOL connector's class struct */
+ void *ret_value = NULL; /* Return value */
FUNC_ENTER_API_NOINIT
- H5TRACE2("e", "*xi", wrap_ctx, connector_id);
+ H5TRACE4("*x", "*xIti*x", obj, obj_type, connector_id, wrap_ctx);
/* Check args and get class pointer */
+ if(NULL == obj)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "invalid object")
if(NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL)))
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL connector ID")
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a VOL connector ID")
- /* Release the VOL connector's object wrapper */
- if(H5VL_free_wrap_ctx(cls, wrap_ctx) < 0)
- HGOTO_ERROR(H5E_VOL, H5E_CANTRELEASE, FAIL, "unable to release VOL connector object wrap context")
+ /* Wrap the object */
+ if(NULL == (ret_value = H5VL_wrap_object(cls, wrap_ctx, obj, obj_type)))
+ HGOTO_ERROR(H5E_VOL, H5E_CANTGET, NULL, "unable to wrap object")
done:
FUNC_LEAVE_API_NOINIT(ret_value)
-} /* H5VLfree_wrap_ctx() */
+} /* H5VLwrap_object */
/*-------------------------------------------------------------------------
- * Function: H5VL_wrap_object
+ * Function: H5VL_unwrap_object
*
- * Purpose: Wrap an object with connector
+ * Purpose: Unwrap an object from connector
*
- * Return: Success: Non-negative
- * Failure: Negative
+ * Return: Success: Non-NULL
+ * Failure: NULL
*
*-------------------------------------------------------------------------
*/
void *
-H5VL_wrap_object(const H5VL_class_t *connector, void *wrap_ctx, void *obj,
- H5I_type_t obj_type)
+H5VL_unwrap_object(const H5VL_class_t *connector, void *obj)
{
- void *ret_value = SUCCEED; /* Return value */
+ void *ret_value; /* Return value */
FUNC_ENTER_NOAPI(NULL)
@@ -825,24 +830,24 @@ H5VL_wrap_object(const H5VL_class_t *connector, void *wrap_ctx, void *obj,
HDassert(connector);
HDassert(obj);
- /* Only wrap object if there's a wrap context */
- if(wrap_ctx) {
- /* Ask the connector to wrap the object */
- if(NULL == (ret_value = (connector->wrap_cls.wrap_object)(obj, obj_type, wrap_ctx)))
- HGOTO_ERROR(H5E_VOL, H5E_CANTGET, NULL, "can't wrap object")
+ /* Only unwrap object if there's an unwrap callback */
+ if(connector->wrap_cls.wrap_object) {
+ /* Ask the connector to unwrap the object */
+ if(NULL == (ret_value = (connector->wrap_cls.unwrap_object)(obj)))
+ HGOTO_ERROR(H5E_VOL, H5E_CANTGET, NULL, "can't unwrap object")
} /* end if */
else
ret_value = obj;
done:
FUNC_LEAVE_NOAPI(ret_value)
-} /* end H5VL_wrap_object() */
+} /* end H5VL_unwrap_object() */
/*---------------------------------------------------------------------------
- * Function: H5VLwrap_object
+ * Function: H5VLunwrap_object
*
- * Purpose: Asks a connector to wrap an underlying object.
+ * Purpose: Unwrap an object from connector
*
* Return: Success: Non-NULL
* Failure: NULL
@@ -850,13 +855,13 @@ done:
*---------------------------------------------------------------------------
*/
void *
-H5VLwrap_object(void *obj, H5I_type_t obj_type, hid_t connector_id, void *wrap_ctx)
+H5VLunwrap_object(void *obj, hid_t connector_id)
{
H5VL_class_t *cls; /* VOL connector's class struct */
void *ret_value = NULL; /* Return value */
FUNC_ENTER_API_NOINIT
- H5TRACE4("*x", "*xIti*x", obj, obj_type, connector_id, wrap_ctx);
+ H5TRACE2("*x", "*xi", obj, connector_id);
/* Check args and get class pointer */
if(NULL == obj)
@@ -864,13 +869,77 @@ H5VLwrap_object(void *obj, H5I_type_t obj_type, hid_t connector_id, void *wrap_c
if(NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a VOL connector ID")
- /* Wrap the object */
- if(NULL == (ret_value = H5VL_wrap_object(cls, wrap_ctx, obj, obj_type)))
- HGOTO_ERROR(H5E_VOL, H5E_CANTGET, NULL, "unable to wrap object")
+ /* Unwrap the object */
+ if(NULL == (ret_value = H5VL_unwrap_object(cls, obj)))
+ HGOTO_ERROR(H5E_VOL, H5E_CANTGET, NULL, "unable to unwrap object")
done:
FUNC_LEAVE_API_NOINIT(ret_value)
-} /* H5VLwrap_object */
+} /* H5VLunwrap_object */
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5VL_free_wrap_ctx
+ *
+ * Purpose: Free object wrapping context for a connector
+ *
+ * Return: Success: Non-negative
+ * Failure: Negative
+ *
+ *-------------------------------------------------------------------------
+ */
+herr_t
+H5VL_free_wrap_ctx(const H5VL_class_t *connector, void *wrap_ctx)
+{
+ herr_t ret_value = SUCCEED; /* Return value */
+
+ FUNC_ENTER_NOAPI(FAIL)
+
+ /* Sanity checks */
+ HDassert(connector);
+
+ /* Only free wrap context, if it's non-NULL */
+ if(wrap_ctx) {
+ /* Free the connector's object wrapping context */
+ if((connector->wrap_cls.free_wrap_ctx)(wrap_ctx) < 0)
+ HGOTO_ERROR(H5E_VOL, H5E_CANTRELEASE, FAIL, "connector wrap context free request failed")
+ } /* end if */
+
+done:
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5VL_free_wrap_ctx() */
+
+
+/*---------------------------------------------------------------------------
+ * Function: H5VLfree_wrap_ctx
+ *
+ * Purpose: Release a VOL connector's object wrapping context
+ *
+ * Return: Success: Non-negative
+ * Failure: Negative
+ *
+ *---------------------------------------------------------------------------
+ */
+herr_t
+H5VLfree_wrap_ctx(void *wrap_ctx, hid_t connector_id)
+{
+ H5VL_class_t *cls; /* VOL connector's class struct */
+ herr_t ret_value = SUCCEED; /* Return value */
+
+ FUNC_ENTER_API_NOINIT
+ H5TRACE2("e", "*xi", wrap_ctx, connector_id);
+
+ /* Check args and get class pointer */
+ if(NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL connector ID")
+
+ /* Release the VOL connector's object wrapper */
+ if(H5VL_free_wrap_ctx(cls, wrap_ctx) < 0)
+ HGOTO_ERROR(H5E_VOL, H5E_CANTRELEASE, FAIL, "unable to release VOL connector object wrap context")
+
+done:
+ FUNC_LEAVE_API_NOINIT(ret_value)
+} /* H5VLfree_wrap_ctx() */
/*-------------------------------------------------------------------------