summaryrefslogtreecommitdiffstats
path: root/src/H5VL.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/H5VL.c')
-rw-r--r--src/H5VL.c79
1 files changed, 70 insertions, 9 deletions
diff --git a/src/H5VL.c b/src/H5VL.c
index 6790465..0e36bcd 100644
--- a/src/H5VL.c
+++ b/src/H5VL.c
@@ -107,7 +107,7 @@ H5VLregister_connector(const H5VL_class_t *cls, hid_t vipl_id)
if (cls->wrap_cls.get_wrap_ctx && !cls->wrap_cls.free_wrap_ctx)
HGOTO_ERROR(H5E_VOL, H5E_CANTREGISTER, H5I_INVALID_HID, "VOL connector must provide free callback for object wrapping contexts when a get callback is provided")
- /* Check VOL initialization property list */
+ /* Check VOL initialization property list */
if(H5P_DEFAULT == vipl_id)
vipl_id = H5P_VOL_INITIALIZE_DEFAULT;
else
@@ -154,7 +154,7 @@ H5VLregister_connector_by_name(const char *name, hid_t vipl_id)
if (0 == HDstrlen(name))
HGOTO_ERROR(H5E_ARGS, H5E_UNINITIALIZED, H5I_INVALID_HID, "zero-length VOL connector name is disallowed")
- /* Check VOL initialization property list */
+ /* Check VOL initialization property list */
if(H5P_DEFAULT == vipl_id)
vipl_id = H5P_VOL_INITIALIZE_DEFAULT;
else
@@ -199,7 +199,7 @@ H5VLregister_connector_by_value(H5VL_class_value_t value, hid_t vipl_id)
if(value < 0)
HGOTO_ERROR(H5E_ARGS, H5E_UNINITIALIZED, H5I_INVALID_HID, "negative VOL connector value is disallowed")
- /* Check VOL initialization property list */
+ /* Check VOL initialization property list */
if(H5P_DEFAULT == vipl_id)
vipl_id = H5P_VOL_INITIALIZE_DEFAULT;
else
@@ -249,6 +249,38 @@ done:
/*-------------------------------------------------------------------------
* Function: H5VLget_connector_id
*
+ * Purpose: Retrieves the VOL connector ID for a given object ID.
+ *
+ * Return: A valid VOL connector ID. This ID will need to be closed
+ * using H5VLclose().
+ *
+ * H5I_INVALID_HID on error.
+ *
+ * Programmer: Dana Robinson
+ * June 17, 2017
+ *
+ *-------------------------------------------------------------------------
+ */
+hid_t
+H5VLget_connector_id(hid_t obj_id)
+{
+ hid_t ret_value = H5I_INVALID_HID; /* Return value */
+
+ FUNC_ENTER_API(H5I_INVALID_HID)
+ H5TRACE1("i", "i", obj_id);
+
+ /* Get connector ID */
+ if((ret_value = H5VL__get_connector_id(obj_id, TRUE)) < 0)
+ HGOTO_ERROR(H5E_VOL, H5E_CANTGET, H5I_INVALID_HID, "can't get VOL id")
+
+done:
+ FUNC_LEAVE_API(ret_value)
+} /* end H5VLget_connector_id() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5VLget_connector_id_by_name
+ *
* Purpose: Retrieves the ID for a registered VOL connector.
*
* Return: A valid VOL connector ID if a connector by that name has
@@ -264,7 +296,7 @@ done:
*-------------------------------------------------------------------------
*/
hid_t
-H5VLget_connector_id(const char *name)
+H5VLget_connector_id_by_name(const char *name)
{
hid_t ret_value = H5I_INVALID_HID; /* Return value */
@@ -272,12 +304,12 @@ H5VLget_connector_id(const char *name)
H5TRACE1("i", "*s", name);
/* Get connector ID with this name */
- if((ret_value = H5VL__get_connector_id(name, TRUE)) < 0)
+ if((ret_value = H5VL__get_connector_id_by_name(name, TRUE)) < 0)
HGOTO_ERROR(H5E_VOL, H5E_CANTGET, H5I_INVALID_HID, "can't get VOL id")
done:
FUNC_LEAVE_API(ret_value)
-} /* end H5VLget_connector_id() */
+} /* end H5VLget_connector_id_by_name() */
/*-------------------------------------------------------------------------
@@ -411,7 +443,7 @@ H5VLunregister_connector(hid_t vol_id)
HGOTO_ERROR(H5E_VOL, H5E_BADTYPE, FAIL, "not a VOL connector ID")
/* For the time being, we disallow unregistering the native VOL connector */
- if(H5I_INVALID_HID == (native_id = H5VL__get_connector_id(H5VL_NATIVE_NAME, FALSE)))
+ if(H5I_INVALID_HID == (native_id = H5VL__get_connector_id_by_name(H5VL_NATIVE_NAME, FALSE)))
HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "unable to find the native VOL connector ID")
if(vol_id == native_id)
HGOTO_ERROR(H5E_VOL, H5E_BADVALUE, FAIL, "unregistering the native VOL connector is not allowed")
@@ -477,6 +509,9 @@ done:
* iteration routine callbacks (i.e. the callbacks from H5Aiterate*,
* H5Literate* / H5Lvisit*, and H5Ovisit* ).
*
+ * type must be a VOL-managed object class (H5I_FILE,
+ * H5I_GROUP, H5I_DATATYPE, H5I_DATASET, H5I_MAP, or H5I_ATTR).
+ *
* Return: Success: Non-negative hid_t for the object.
* Failure: Negative (H5I_INVALID_HID)
*
@@ -492,8 +527,34 @@ H5VLwrap_register(void *obj, H5I_type_t type)
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")
+ /* Use a switch here for (hopefully) better performance than a series of
+ * equality checks. We could also group these types together in H5I_type_t,
+ * make some assertions here to guarantee that, then just check the range.
+ */
+ switch(type) {
+ case H5I_FILE:
+ case H5I_GROUP:
+ case H5I_DATATYPE:
+ case H5I_DATASET:
+ case H5I_MAP:
+ case H5I_ATTR:
+ /* VOL-managed objects, call is valid */
+ break;
+ case H5I_UNINIT:
+ case H5I_BADID:
+ case H5I_DATASPACE:
+ case H5I_VFL:
+ case H5I_VOL:
+ case H5I_GENPROP_CLS:
+ case H5I_GENPROP_LST:
+ case H5I_ERROR_CLASS:
+ case H5I_ERROR_MSG:
+ case H5I_ERROR_STACK:
+ case H5I_SPACE_SEL_ITER:
+ case H5I_NTYPES:
+ default:
+ HGOTO_ERROR(H5E_VOL, H5E_BADRANGE, H5I_INVALID_HID, "invalid type number")
+ } /* end switch */
if(NULL == obj)
HGOTO_ERROR(H5E_VOL, H5E_BADVALUE, H5I_INVALID_HID, "obj is NULL")