diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/H5VL.c | 109 | ||||
-rw-r--r-- | src/H5VLconnector.h | 3 | ||||
-rw-r--r-- | src/H5VLint.c | 124 | ||||
-rw-r--r-- | src/H5VLpkg.h | 7 | ||||
-rw-r--r-- | src/H5VLpublic.h | 9 |
5 files changed, 227 insertions, 25 deletions
@@ -216,9 +216,10 @@ done: /*------------------------------------------------------------------------- - * Function: H5VLis_connector_registered + * Function: H5VLis_connector_registered_by_name * * Purpose: Tests whether a VOL class has been registered or not + * according to a supplied connector name. * * Return: >0 if a VOL connector with that name has been registered * 0 if a VOL connector with that name has NOT been registered @@ -230,7 +231,7 @@ done: *------------------------------------------------------------------------- */ htri_t -H5VLis_connector_registered(const char *name) +H5VLis_connector_registered_by_name(const char *name) { htri_t ret_value = FALSE; /* Return value */ @@ -238,12 +239,41 @@ H5VLis_connector_registered(const char *name) H5TRACE1("t", "*s", name); /* Check if connector with this name is registered */ - if((ret_value = H5VL__is_connector_registered(name)) < 0) + if((ret_value = H5VL__is_connector_registered_by_name(name)) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "can't check for VOL") done: FUNC_LEAVE_API(ret_value) -} /* end H5VLis_connector_registered() */ +} /* end H5VLis_connector_registered_by_name() */ + + +/*------------------------------------------------------------------------- + * Function: H5VLis_connector_registered_by_value + * + * Purpose: Tests whether a VOL class has been registered or not + * according to a supplied connector value (ID). + * + * Return: >0 if a VOL connector with that value has been registered + * 0 if a VOL connector with that value hasn't been registered + * <0 on errors + * + *------------------------------------------------------------------------- + */ +htri_t +H5VLis_connector_registered_by_value(H5VL_class_value_t connector_value) +{ + htri_t ret_value = FALSE; + + FUNC_ENTER_API(FAIL) + H5TRACE1("t", "VC", connector_value); + + /* Check if connector with this value is registered */ + if((ret_value = H5VL__is_connector_registered_by_value(connector_value)) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "can't check for VOL") + +done: + FUNC_LEAVE_API(ret_value) +} /* end H5VLis_connector_registered_by_value() */ /*------------------------------------------------------------------------- @@ -313,7 +343,38 @@ done: /*------------------------------------------------------------------------- - * Function: H5VLpeek_connector_id + * Function: H5VLget_connector_id_by_value + * + * Purpose: Retrieves the ID for a registered VOL connector. + * + * Return: A valid VOL connector ID if a connector with that value has + * been registered. This ID will need to be closed using + * H5VLclose(). + * + * H5I_INVALID_HID on error or if a VOL connector with that + * value has not been registered. + * + *------------------------------------------------------------------------- + */ +hid_t +H5VLget_connector_id_by_value(H5VL_class_value_t connector_value) +{ + hid_t ret_value = H5I_INVALID_HID; /* Return value */ + + FUNC_ENTER_API(H5I_INVALID_HID) + H5TRACE1("i", "VC", connector_value); + + /* Get connector ID with this value */ + if((ret_value = H5VL__get_connector_id_by_value(connector_value, 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_by_value() */ + + +/*------------------------------------------------------------------------- + * Function: H5VLpeek_connector_id_by_name * * Purpose: Retrieves the ID for a registered VOL connector. * @@ -328,7 +389,7 @@ done: *------------------------------------------------------------------------- */ hid_t -H5VLpeek_connector_id(const char *name) +H5VLpeek_connector_id_by_name(const char *name) { hid_t ret_value = H5I_INVALID_HID; /* Return value */ @@ -336,12 +397,44 @@ H5VLpeek_connector_id(const char *name) H5TRACE1("i", "*s", name); /* Get connector ID with this name */ - if((ret_value = H5VL__peek_connector_id(name)) < 0) + if((ret_value = H5VL__peek_connector_id_by_name(name)) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTGET, H5I_INVALID_HID, "can't get VOL id") + +done: + FUNC_LEAVE_API(ret_value) +} /* end H5VLpeek_connector_id_by_name() */ + + +/*------------------------------------------------------------------------- + * Function: H5VLpeek_connector_id_by_value + * + * Purpose: Retrieves the ID for a registered VOL connector. + * + * Return: A valid VOL connector ID if a connector with that value + * has been registered. This ID is *not* owned by the caller + * and H5VLclose() should not be called. Intended for use by + * VOL connectors to find their own ID. + * + * H5I_INVALID_HID on error or if a VOL connector with that + * value has not been registered. + * + *------------------------------------------------------------------------- + */ +hid_t +H5VLpeek_connector_id_by_value(H5VL_class_value_t value) +{ + hid_t ret_value = H5I_INVALID_HID; /* Return value */ + + FUNC_ENTER_API(H5I_INVALID_HID) + H5TRACE1("i", "VC", value); + + /* Get connector ID with this value */ + if((ret_value = H5VL__peek_connector_id_by_value(value)) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTGET, H5I_INVALID_HID, "can't get VOL id") done: FUNC_LEAVE_API(ret_value) -} /* end H5VLpeek_connector_id() */ +} /* end H5VLpeek_connector_id_by_value() */ /*------------------------------------------------------------------------- diff --git a/src/H5VLconnector.h b/src/H5VLconnector.h index 9bc3a7b..baa4cca 100644 --- a/src/H5VLconnector.h +++ b/src/H5VLconnector.h @@ -512,7 +512,8 @@ H5_DLL hid_t H5VLregister_connector(const H5VL_class_t *cls, hid_t vipl_id); H5_DLL void *H5VLobject(hid_t obj_id); H5_DLL hid_t H5VLget_file_type(void *file_obj, hid_t connector_id, hid_t dtype_id); -H5_DLL hid_t H5VLpeek_connector_id(const char *name); +H5_DLL hid_t H5VLpeek_connector_id_by_name(const char *name); +H5_DLL hid_t H5VLpeek_connector_id_by_value(H5VL_class_value_t value); #ifdef __cplusplus } diff --git a/src/H5VLint.c b/src/H5VLint.c index 9038d38..39b0f53 100644 --- a/src/H5VLint.c +++ b/src/H5VLint.c @@ -421,7 +421,7 @@ H5VL__set_def_conn(void) HGOTO_ERROR(H5E_VOL, H5E_BADVALUE, FAIL, "VOL connector environment variable set empty?") /* First, check to see if the connector is already registered */ - if((connector_is_registered = H5VL__is_connector_registered(tok)) < 0) + if((connector_is_registered = H5VL__is_connector_registered_by_name(tok)) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "can't check if VOL connector already registered") else if(connector_is_registered) { /* Retrieve the ID of the already-registered VOL connector */ @@ -1325,7 +1325,7 @@ done: /*------------------------------------------------------------------------- - * Function: H5VL__is_connector_registered + * Function: H5VL__is_connector_registered_by_name * * Purpose: Checks if a connector with a particular name is registered. * @@ -1338,7 +1338,7 @@ done: *------------------------------------------------------------------------- */ htri_t -H5VL__is_connector_registered(const char *name) +H5VL__is_connector_registered_by_name(const char *name) { H5VL_get_connector_ud_t op_data; /* Callback info for connector search */ htri_t ret_value = FALSE; /* Return value */ @@ -1360,7 +1360,44 @@ H5VL__is_connector_registered(const char *name) done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5VL__is_connector_registered() */ +} /* end H5VL__is_connector_registered_by_name() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL__is_connector_registered_by_value + * + * Purpose: Checks if a connector with a particular value (ID) is + * registered. + * + * Return: Success: 0 + * Failure: -1 + * + *------------------------------------------------------------------------- + */ +htri_t +H5VL__is_connector_registered_by_value(H5VL_class_value_t value) +{ + H5VL_get_connector_ud_t op_data; /* Callback info for connector search */ + htri_t ret_value = FALSE; /* Return value */ + + FUNC_ENTER_PACKAGE + + /* Set up op data for iteration */ + op_data.kind = H5VL_GET_CONNECTOR_BY_VALUE; + op_data.u.value = value; + op_data.found_id = H5I_INVALID_HID; + + /* Find connector with value */ + if(H5I_iterate(H5I_VOL, H5VL__get_connector_cb, &op_data, TRUE) < 0) + HGOTO_ERROR(H5E_VOL, H5E_BADITER, FAIL, "can't iterate over VOL connectors") + + /* Found a connector with that name */ + if(op_data.found_id != H5I_INVALID_HID) + ret_value = TRUE; + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__is_connector_registered_by_value() */ /*------------------------------------------------------------------------- @@ -1419,7 +1456,7 @@ H5VL__get_connector_id_by_name(const char *name, hbool_t is_api) FUNC_ENTER_PACKAGE /* Find connector with name */ - if((ret_value = H5VL__peek_connector_id(name)) < 0) + if((ret_value = H5VL__peek_connector_id_by_name(name)) < 0) HGOTO_ERROR(H5E_VOL, H5E_BADITER, H5I_INVALID_HID, "can't find VOL connector") /* Found a connector with that name */ @@ -1432,18 +1469,50 @@ done: /*------------------------------------------------------------------------- - * Function: H5VL__peek_connector_id + * Function: H5VL__get_connector_id_by_value + * + * Purpose: Retrieves the ID for a registered VOL connector. + * + * Return: Positive if the VOL class has been registered + * Negative on error (if the class is not a valid class or + * not registered) + * + *------------------------------------------------------------------------- + */ +hid_t +H5VL__get_connector_id_by_value(H5VL_class_value_t value, hbool_t is_api) +{ + hid_t ret_value = H5I_INVALID_HID; /* Return value */ + + FUNC_ENTER_PACKAGE + + /* Find connector with value */ + if((ret_value = H5VL__peek_connector_id_by_value(value)) < 0) + HGOTO_ERROR(H5E_VOL, H5E_BADITER, H5I_INVALID_HID, "can't find VOL connector") + + /* Found a connector with that value */ + if(H5I_inc_ref(ret_value, is_api) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTINC, H5I_INVALID_HID, "unable to increment ref count on VOL connector") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__get_connector_id_by_value() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL__peek_connector_id_by_name * * Purpose: Retrieves the ID for a registered VOL connector. Does not * increment the ref count * * Return: Positive if the VOL class has been registered - * Negative on error (if the class is not a valid class or not registered) + * Negative on error (if the class is not a valid class or + * not registered) * *------------------------------------------------------------------------- */ hid_t -H5VL__peek_connector_id(const char *name) +H5VL__peek_connector_id_by_name(const char *name) { H5VL_get_connector_ud_t op_data; /* Callback info for connector search */ hid_t ret_value = H5I_INVALID_HID; /* Return value */ @@ -1464,7 +1533,44 @@ H5VL__peek_connector_id(const char *name) done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5VL__peek_connector_id() */ +} /* end H5VL__peek_connector_id_by_name() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL__peek_connector_id_by_value + * + * Purpose: Retrieves the ID for a registered VOL connector. Does not + * increment the ref count + * + * Return: Positive if the VOL class has been registered + * Negative on error (if the class is not a valid class or + * not registered) + * + *------------------------------------------------------------------------- + */ +hid_t +H5VL__peek_connector_id_by_value(H5VL_class_value_t value) +{ + H5VL_get_connector_ud_t op_data; /* Callback info for connector search */ + hid_t ret_value = H5I_INVALID_HID; /* Return value */ + + FUNC_ENTER_PACKAGE + + /* Set up op data for iteration */ + op_data.kind = H5VL_GET_CONNECTOR_BY_VALUE; + op_data.u.value = value; + op_data.found_id = H5I_INVALID_HID; + + /* Find connector with value */ + if(H5I_iterate(H5I_VOL, H5VL__get_connector_cb, &op_data, TRUE) < 0) + HGOTO_ERROR(H5E_VOL, H5E_BADITER, H5I_INVALID_HID, "can't iterate over VOL connectors") + + /* Set return value */ + ret_value = op_data.found_id; + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__peek_connector_id_by_value() */ /*------------------------------------------------------------------------- diff --git a/src/H5VLpkg.h b/src/H5VLpkg.h index 5965adc..4174732 100644 --- a/src/H5VLpkg.h +++ b/src/H5VLpkg.h @@ -53,10 +53,13 @@ H5_DLL hid_t H5VL__register_connector_by_name(const char *name, hbool_t app_ref, hid_t vipl_id); H5_DLL hid_t H5VL__register_connector_by_value(H5VL_class_value_t value, hbool_t app_ref, hid_t vipl_id); -H5_DLL htri_t H5VL__is_connector_registered(const char *name); +H5_DLL htri_t H5VL__is_connector_registered_by_name(const char *name); +H5_DLL htri_t H5VL__is_connector_registered_by_value(H5VL_class_value_t value); H5_DLL hid_t H5VL__get_connector_id(hid_t obj_id, hbool_t is_api); H5_DLL hid_t H5VL__get_connector_id_by_name(const char *name, hbool_t is_api); -H5_DLL hid_t H5VL__peek_connector_id(const char *name); +H5_DLL hid_t H5VL__get_connector_id_by_value(H5VL_class_value_t value, hbool_t is_api); +H5_DLL hid_t H5VL__peek_connector_id_by_name(const char *name); +H5_DLL hid_t H5VL__peek_connector_id_by_value(H5VL_class_value_t value); H5_DLL herr_t H5VL__connector_str_to_info(const char *str, hid_t connector_id, void **info); H5_DLL ssize_t H5VL__get_connector_name(hid_t id, char *name/*out*/, size_t size); diff --git a/src/H5VLpublic.h b/src/H5VLpublic.h index 883aac8..006c3ea 100644 --- a/src/H5VLpublic.h +++ b/src/H5VLpublic.h @@ -42,7 +42,7 @@ /* * VOL connector identifiers. Values 0 through 255 are for connectors defined * by the HDF5 library. Values 256 through 511 are available for testing new - * filters. Subsequent values should be obtained from the HDF5 development + * connectors. Subsequent values should be obtained from the HDF5 development * team at help@hdfgroup.org. */ typedef int H5VL_class_value_t; @@ -60,14 +60,13 @@ typedef int H5VL_class_value_t; extern "C" { #endif -/* The H5VL types uses in the API calls are not opaque - they are defined in - * H5VLconnector.h, which is included at the top of this file. - */ H5_DLL hid_t H5VLregister_connector_by_name(const char *connector_name, hid_t vipl_id); H5_DLL hid_t H5VLregister_connector_by_value(H5VL_class_value_t connector_value, hid_t vipl_id); -H5_DLL htri_t H5VLis_connector_registered(const char *name); +H5_DLL htri_t H5VLis_connector_registered_by_name(const char *name); +H5_DLL htri_t H5VLis_connector_registered_by_value(H5VL_class_value_t connector_value); H5_DLL hid_t H5VLget_connector_id(hid_t obj_id); H5_DLL hid_t H5VLget_connector_id_by_name(const char *name); +H5_DLL hid_t H5VLget_connector_id_by_value(H5VL_class_value_t connector_value); H5_DLL ssize_t H5VLget_connector_name(hid_t id, char *name/*out*/, size_t size); H5_DLL herr_t H5VLclose(hid_t connector_id); H5_DLL herr_t H5VLunregister_connector(hid_t connector_id); |