diff options
Diffstat (limited to 'src/H5VLint.c')
-rw-r--r-- | src/H5VLint.c | 293 |
1 files changed, 282 insertions, 11 deletions
diff --git a/src/H5VLint.c b/src/H5VLint.c index 289dfef..7b3da7a 100644 --- a/src/H5VLint.c +++ b/src/H5VLint.c @@ -453,7 +453,7 @@ H5VL__set_def_conn(void) /* Get default file access pclass */ if (NULL == (def_fapclass = (H5P_genclass_t *)H5I_object(H5P_FILE_ACCESS))) - HGOTO_ERROR(H5E_VOL, H5E_BADATOM, FAIL, "can't find object for default file access property class ID") + HGOTO_ERROR(H5E_VOL, H5E_BADID, FAIL, "can't find object for default file access property class ID") /* Change the default VOL for the default file access pclass */ if (H5P_reset_vol_class(def_fapclass, &H5VL_def_conn_s) < 0) @@ -462,7 +462,7 @@ H5VL__set_def_conn(void) /* Get default file access plist */ if (NULL == (def_fapl = (H5P_genplist_t *)H5I_object(H5P_FILE_ACCESS_DEFAULT))) - HGOTO_ERROR(H5E_VOL, H5E_BADATOM, FAIL, "can't find object for default fapl ID") + HGOTO_ERROR(H5E_VOL, H5E_BADID, FAIL, "can't find object for default fapl ID") /* Change the default VOL for the default FAPL */ if (H5P_set_vol(def_fapl, H5VL_def_conn_s.connector_id, H5VL_def_conn_s.connector_info) < 0) @@ -2315,24 +2315,25 @@ H5VL_wrap_register(H5I_type_t type, void *obj, hbool_t app_ref) /* Sanity check */ HDassert(obj); + /* Retrieve the VOL object wrapping context */ + if (H5CX_get_vol_wrap_ctx((void **)&vol_wrap_ctx) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTGET, H5I_INVALID_HID, "can't get VOL object wrap context") + if (NULL == vol_wrap_ctx || NULL == vol_wrap_ctx->connector) + HGOTO_ERROR(H5E_VOL, H5E_BADVALUE, H5I_INVALID_HID, + "VOL object wrap context or its connector is NULL???") + /* If the datatype is already VOL-managed, the datatype's vol_obj * field will get clobbered later, so disallow this. */ if (type == H5I_DATATYPE) - if (TRUE == H5T_already_vol_managed((const H5T_t *)obj)) - HGOTO_ERROR(H5E_VOL, H5E_BADTYPE, H5I_INVALID_HID, "can't wrap an uncommitted datatype") + if (vol_wrap_ctx->connector->id == H5VL_NATIVE) + if (TRUE == H5T_already_vol_managed((const H5T_t *)obj)) + HGOTO_ERROR(H5E_VOL, H5E_BADTYPE, H5I_INVALID_HID, "can't wrap an uncommitted datatype") /* Wrap the object with VOL connector info */ if (NULL == (new_obj = H5VL__wrap_obj(obj, type))) HGOTO_ERROR(H5E_VOL, H5E_CANTCREATE, H5I_INVALID_HID, "can't wrap library object") - /* Retrieve the VOL object wrapping context */ - if (H5CX_get_vol_wrap_ctx((void **)&vol_wrap_ctx) < 0) - HGOTO_ERROR(H5E_VOL, H5E_CANTGET, H5I_INVALID_HID, "can't get VOL object wrap context") - if (NULL == vol_wrap_ctx || NULL == vol_wrap_ctx->connector) - HGOTO_ERROR(H5E_VOL, H5E_BADVALUE, H5I_INVALID_HID, - "VOL object wrap context or its connector is NULL???") - /* Get an ID for the object */ if ((ret_value = H5VL_register_using_vol_id(type, new_obj, vol_wrap_ctx->connector->id, app_ref)) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to get an ID for the object") @@ -2340,3 +2341,273 @@ H5VL_wrap_register(H5I_type_t type, void *obj, hbool_t app_ref) done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL_wrap_register() */ + +/*------------------------------------------------------------------------- + * Function: H5VL_setup_args + * + * Purpose: Set up arguments to access an object + * + * Return: SUCCEED / FAIL + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL_setup_args(hid_t loc_id, H5I_type_t id_type, H5VL_object_t **vol_obj) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + /* Sanity check */ + HDassert(vol_obj); + + /* Get attribute pointer */ + if (NULL == (*vol_obj = (H5VL_object_t *)H5I_object_verify(loc_id, id_type))) + HGOTO_ERROR(H5E_VOL, H5E_BADTYPE, FAIL, "not the correct type of ID") + + /* Set up collective metadata (if appropriate */ + if (H5CX_set_loc(loc_id) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTSET, FAIL, "can't set collective metadata read") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_setup_args() */ + +/*------------------------------------------------------------------------- + * Function: H5VL_setup_loc_args + * + * Purpose: Set up arguments to access an object + * + * Return: SUCCEED / FAIL + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL_setup_loc_args(hid_t loc_id, H5VL_object_t **vol_obj, H5VL_loc_params_t *loc_params) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + /* Sanity check */ + HDassert(vol_obj); + HDassert(loc_params); + + /* Get the location object */ + if (NULL == (*vol_obj = (H5VL_object_t *)H5VL_vol_object(loc_id))) + HGOTO_ERROR(H5E_VOL, H5E_BADTYPE, FAIL, "not the correct type of ID") + + /* Set up collective metadata (if appropriate */ + if (H5CX_set_loc(loc_id) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTSET, FAIL, "can't set collective metadata read") + + /* Set location parameters */ + loc_params->type = H5VL_OBJECT_BY_SELF; + loc_params->obj_type = H5I_get_type(loc_id); + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_setup_loc_args() */ + +/*------------------------------------------------------------------------- + * Function: H5VL_setup_acc_args + * + * Purpose: Set up arguments to access an object + * + * Return: SUCCEED / FAIL + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL_setup_acc_args(hid_t loc_id, const H5P_libclass_t *libclass, hbool_t is_collective, hid_t *acspl_id, + H5VL_object_t **vol_obj, H5VL_loc_params_t *loc_params) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + /* Sanity check */ + HDassert(libclass); + HDassert(acspl_id); + HDassert(vol_obj); + HDassert(loc_params); + + /* Verify access property list and set up collective metadata if appropriate */ + if (H5CX_set_apl(acspl_id, libclass, loc_id, is_collective) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTSET, FAIL, "can't set access property list info") + + /* Get the location object */ + if (NULL == (*vol_obj = (H5VL_object_t *)H5VL_vol_object(loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") + + /* Set location parameters */ + loc_params->type = H5VL_OBJECT_BY_SELF; + loc_params->obj_type = H5I_get_type(loc_id); + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_setup_acc_args() */ + +/*------------------------------------------------------------------------- + * Function: H5VL_setup_self_args + * + * Purpose: Set up arguments to access an object "by self" + * + * Return: SUCCEED / FAIL + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL_setup_self_args(hid_t loc_id, H5VL_object_t **vol_obj, H5VL_loc_params_t *loc_params) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + /* Sanity check */ + HDassert(vol_obj); + HDassert(loc_params); + + /* Get the location object */ + if (NULL == (*vol_obj = (H5VL_object_t *)H5VL_vol_object(loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") + + /* Set location parameters */ + loc_params->type = H5VL_OBJECT_BY_SELF; + loc_params->obj_type = H5I_get_type(loc_id); + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_setup_self_args() */ + +/*------------------------------------------------------------------------- + * Function: H5VL_setup_name_args + * + * Purpose: Set up arguments to access an object "by name" + * + * Return: SUCCEED / FAIL + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL_setup_name_args(hid_t loc_id, const char *name, const H5P_libclass_t *libclass, hbool_t is_collective, + hid_t acspl_id, H5VL_object_t **vol_obj, H5VL_loc_params_t *loc_params) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + /* Sanity check */ + HDassert(vol_obj); + HDassert(loc_params); + + /* Check args */ + if (!name) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "name parameter cannot be NULL") + if (!*name) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "name parameter cannot be an empty string") + + /* Verify access property list and set up collective metadata if appropriate */ + if (H5CX_set_apl(&acspl_id, libclass, loc_id, is_collective) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTSET, FAIL, "can't set access property list info") + + /* Get the location object */ + if (NULL == (*vol_obj = (H5VL_object_t *)H5VL_vol_object(loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") + + /* Set up location parameters */ + loc_params->type = H5VL_OBJECT_BY_NAME; + loc_params->loc_data.loc_by_name.name = name; + loc_params->loc_data.loc_by_name.lapl_id = acspl_id; + loc_params->obj_type = H5I_get_type(loc_id); + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_setup_name_args() */ + +/*------------------------------------------------------------------------- + * Function: H5VL_setup_idx_args + * + * Purpose: Set up arguments to access an object "by idx" + * + * Return: SUCCEED / FAIL + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL_setup_idx_args(hid_t loc_id, const char *name, H5_index_t idx_type, H5_iter_order_t order, hsize_t n, + const H5P_libclass_t *libclass, hbool_t is_collective, hid_t acspl_id, + H5VL_object_t **vol_obj, H5VL_loc_params_t *loc_params) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + /* Sanity check */ + HDassert(vol_obj); + HDassert(loc_params); + + /* Check args */ + if (!name) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "name parameter cannot be NULL") + if (!*name) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "name parameter cannot be an empty string") + if (idx_type <= H5_INDEX_UNKNOWN || idx_type >= H5_INDEX_N) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid index type specified") + if (order <= H5_ITER_UNKNOWN || order >= H5_ITER_N) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid iteration order specified") + + /* Verify access property list and set up collective metadata if appropriate */ + if (H5CX_set_apl(&acspl_id, libclass, loc_id, is_collective) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTSET, FAIL, "can't set access property list info") + + /* Get the location object */ + if (NULL == (*vol_obj = (H5VL_object_t *)H5VL_vol_object(loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") + + /* Set location parameters */ + loc_params->type = H5VL_OBJECT_BY_IDX; + loc_params->loc_data.loc_by_idx.name = name; + loc_params->loc_data.loc_by_idx.idx_type = idx_type; + loc_params->loc_data.loc_by_idx.order = order; + loc_params->loc_data.loc_by_idx.n = n; + loc_params->loc_data.loc_by_idx.lapl_id = acspl_id; + loc_params->obj_type = H5I_get_type(loc_id); + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_setup_idx_args() */ + +/*------------------------------------------------------------------------- + * Function: H5VL_setup_token_args + * + * Purpose: Set up arguments to access an object by token + * + * Return: SUCCEED / FAIL + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL_setup_token_args(hid_t loc_id, H5O_token_t *obj_token, H5VL_object_t **vol_obj, + H5VL_loc_params_t *loc_params) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + /* Sanity check */ + HDassert(vol_obj); + HDassert(loc_params); + + /* Get the location object */ + if (NULL == (*vol_obj = (H5VL_object_t *)H5VL_vol_object(loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") + + /* Set location parameters */ + loc_params->type = H5VL_OBJECT_BY_TOKEN; + loc_params->loc_data.loc_by_token.token = obj_token; + loc_params->obj_type = H5I_get_type(loc_id); + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_setup_token_args() */ |