summaryrefslogtreecommitdiffstats
path: root/src/H5VL.c
diff options
context:
space:
mode:
authorMohamad Chaarawi <chaarawi@hdfgroup.org>2014-09-09 21:35:35 (GMT)
committerMohamad Chaarawi <chaarawi@hdfgroup.org>2014-09-09 21:35:35 (GMT)
commit7fed33ae490989642156aae633d2139058e55429 (patch)
treea2021c5e787b478c0d518cc50262ce095c2176f4 /src/H5VL.c
parent3b9e143ea32517797f0c50c89cbeedeceb200757 (diff)
downloadhdf5-7fed33ae490989642156aae633d2139058e55429.zip
hdf5-7fed33ae490989642156aae633d2139058e55429.tar.gz
hdf5-7fed33ae490989642156aae633d2139058e55429.tar.bz2
[svn-r25582] Dynamic VOL plugin loading:
- add support for searching for plugins by name in the H5PL interface - add support for searching for VOL plugins and returning the plugin structure - implement H5VLregister_by_name - add tests similar to the filter plugin tests - still needs some refactoring and better test framework and cmake support.
Diffstat (limited to 'src/H5VL.c')
-rw-r--r--src/H5VL.c129
1 files changed, 95 insertions, 34 deletions
diff --git a/src/H5VL.c b/src/H5VL.c
index 65a8a8f..f1a39ee 100644
--- a/src/H5VL.c
+++ b/src/H5VL.c
@@ -40,6 +40,7 @@
#include "H5Eprivate.h" /* Error handling */
#include "H5Iprivate.h" /* IDs */
#include "H5MMprivate.h" /* Memory management */
+#include "H5PLprivate.h" /* Plugins */
#include "H5VLpkg.h" /* VOL package header */
#include "H5VLprivate.h" /* VOL */
@@ -205,6 +206,39 @@ H5VL_free_cls(H5VL_class_t *cls)
/*-------------------------------------------------------------------------
+ * Function: H5VL__get_plugin_cb
+ *
+ * Purpose: Callback routine to search through registered VLs
+ *
+ * Return: Success: The first object in the type for which FUNC
+ * returns non-zero. NULL if FUNC returned zero
+ * for every object in the type.
+ * Failure: NULL
+ *
+ * Programmer: Quincey Koziol
+ * Friday, March 30, 2012
+ *
+ *-------------------------------------------------------------------------
+ */
+static int
+H5VL__get_plugin_cb(void *obj, hid_t id, void *_op_data)
+{
+ H5VL_get_plugin_ud_t *op_data = (H5VL_get_plugin_ud_t *)_op_data; /* User data for callback */
+ H5VL_class_t *cls = (H5VL_class_t *)obj;
+ int ret_value = H5_ITER_CONT; /* Callback return value */
+
+ FUNC_ENTER_STATIC_NOERR
+
+ if(0 == strcmp(cls->name, op_data->name)) {
+ op_data->ret_id = id;
+ ret_value = H5_ITER_STOP;
+ }
+
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5VL__get_plugin_cb() */
+
+
+/*-------------------------------------------------------------------------
* Function: H5VLregister
*
* Purpose: Registers a new vol plugin as a member of the virtual object
@@ -240,7 +274,7 @@ H5VLregister(const H5VL_class_t *cls)
/* MSC - check if required callback are defined?? */
/* Create the new class ID */
- if((ret_value=H5VL_register(cls, sizeof(H5VL_class_t), TRUE)) < 0)
+ if((ret_value = H5VL_register(cls, sizeof(H5VL_class_t), TRUE)) < 0)
HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to register vol plugin ID")
done:
@@ -249,6 +283,66 @@ done:
/*-------------------------------------------------------------------------
+ * Function: H5VLregister_by_name
+ *
+ * Purpose: Registers a new vol plugin as a member of the virtual object
+ * layer class.
+ *
+ * Return: Success: A vol plugin ID which is good until the
+ * library is closed or the plugin is
+ * unregistered.
+ *
+ * Failure: A negative value.
+ *
+ * Programmer: Mohamad Chaarawi
+ * September, 2014
+ *
+ *-------------------------------------------------------------------------
+ */
+hid_t
+H5VLregister_by_name(const char *name)
+{
+ H5VL_get_plugin_ud_t op_data;
+ hid_t ret_value;
+
+ FUNC_ENTER_API(FAIL)
+ H5TRACE1("i", "*s", name);
+
+ /* Check arguments */
+ if(!name)
+ HGOTO_ERROR(H5E_ARGS, H5E_UNINITIALIZED, FAIL, "null plugin name is disallowed")
+
+ op_data.ret_id = FAIL;
+ op_data.name = name;
+
+ /* check if plugin is already registered */
+ if(H5I_iterate(H5I_VOL, H5VL__get_plugin_cb, &op_data, TRUE) < 0)
+ HGOTO_ERROR(H5E_VOL, H5E_BADITER,FAIL, "can't iterate over VOL ids")
+
+ if(op_data.ret_id != FAIL) {
+ /* If plugin alread registered, increment ref count on ID and return ID */
+ if(H5I_inc_ref(op_data.ret_id, TRUE) < 0)
+ HGOTO_ERROR(H5E_VOL, H5E_CANTINC, FAIL, "unable to increment ref count on VOL plugin")
+ ret_value = op_data.ret_id;
+ }
+ else {
+ const H5VL_class_t *cls;
+
+ /* Try loading the plugin */
+ if(NULL == (cls = (const H5VL_class_t *)H5PL_load(H5PL_TYPE_VOL, -1, name)))
+ HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, FAIL, "unable to load VOL plugin")
+
+ /* Register the plugin we loaded */
+ if((ret_value = H5VL_register(cls, sizeof(H5VL_class_t), TRUE)) < 0)
+ HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to register vol plugin ID")
+ }
+
+done:
+ FUNC_LEAVE_API(ret_value)
+} /* end H5VLregister() */
+
+
+/*-------------------------------------------------------------------------
* Function: H5VLunregister
*
* Purpose: Removes a vol plugin ID from the library. This in no way affects
@@ -353,39 +447,6 @@ done:
/*-------------------------------------------------------------------------
- * Function: H5VL__is_registered_cb
- *
- * Purpose: Callback routine to search through registered VLs
- *
- * Return: Success: The first object in the type for which FUNC
- * returns non-zero. NULL if FUNC returned zero
- * for every object in the type.
- * Failure: NULL
- *
- * Programmer: Quincey Koziol
- * Friday, March 30, 2012
- *
- *-------------------------------------------------------------------------
- */
-static int
-H5VL__get_plugin_cb(void *obj, hid_t id, void *_op_data)
-{
- H5VL_get_plugin_ud_t *op_data = (H5VL_get_plugin_ud_t *)_op_data; /* User data for callback */
- H5VL_class_t *cls = (H5VL_class_t *)obj;
- int ret_value = H5_ITER_CONT; /* Callback return value */
-
- FUNC_ENTER_STATIC_NOERR
-
- if(0 == strcmp(cls->name, op_data->name)) {
- op_data->ret_id = id;
- ret_value = H5_ITER_STOP;
- }
-
- FUNC_LEAVE_NOAPI(ret_value)
-} /* end H5VL__get_plugin_cb() */
-
-
-/*-------------------------------------------------------------------------
* Function: H5VLis_registered
*
* Purpose: Tests whether a VOL class has been registered or not