diff options
author | Mohamad Chaarawi <chaarawi@hdfgroup.org> | 2014-09-05 21:36:55 (GMT) |
---|---|---|
committer | Mohamad Chaarawi <chaarawi@hdfgroup.org> | 2014-09-05 21:36:55 (GMT) |
commit | 05d51c036140f94a07efb75aab9675b3b4bd5ef0 (patch) | |
tree | 5fe046db1c355df5c771077164ba6d6c1f272866 /src/H5G.c | |
parent | f2e6cec0728a75f5982e3b6d91f0ce823d1206a6 (diff) | |
download | hdf5-05d51c036140f94a07efb75aab9675b3b4bd5ef0.zip hdf5-05d51c036140f94a07efb75aab9675b3b4bd5ef0.tar.gz hdf5-05d51c036140f94a07efb75aab9675b3b4bd5ef0.tar.bz2 |
[svn-r25575] cleanup H5I usage in VOL by removing the use of the aux pointer and
make a higher level wrapper object around all VOL objects that
includes the VOL information.
Diffstat (limited to 'src/H5G.c')
-rw-r--r-- | src/H5G.c | 162 |
1 files changed, 64 insertions, 98 deletions
@@ -136,8 +136,7 @@ static const H5I_class_t H5I_GROUP_CLS[1] = {{ H5I_GROUP, /* ID class value */ 0, /* Class flags */ 0, /* # of reserved IDs for class */ - NULL, /* Callback routine for closing objects of this class */ - (H5I_free2_t)H5G_close_group /* Callback routine for closing auxilary objects of this class */ + (H5I_free_t)H5G_close_group /* Callback routine for closing objects of this class */ }}; @@ -276,12 +275,11 @@ H5G_term_interface(void) hid_t H5Gcreate2(hid_t loc_id, const char *name, hid_t lcpl_id, hid_t gcpl_id, hid_t gapl_id) { - void *grp = NULL; /* dset token from VOL plugin */ - void *obj = NULL; /* object token of loc_id */ - H5VL_t *vol_plugin; /* VOL plugin information */ + void *grp = NULL; /* group token from VOL plugin */ + H5VL_object_t *obj = NULL; /* object token of loc_id */ H5VL_loc_params_t loc_params; - H5P_genplist_t *plist; /* Property list pointer */ - hid_t ret_value; /* Return value */ + H5P_genplist_t *plist; /* Property list pointer */ + hid_t ret_value; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE5("i", "i*siii", loc_id, name, lcpl_id, gcpl_id, gapl_id); @@ -321,25 +319,22 @@ H5Gcreate2(hid_t loc_id, const char *name, hid_t lcpl_id, hid_t gcpl_id, hid_t g loc_params.type = H5VL_OBJECT_BY_SELF; loc_params.obj_type = H5I_get_type(loc_id); - /* get the file object */ - if(NULL == (obj = (void *)H5I_object(loc_id))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid file identifier") - /* get the plugin pointer */ - if (NULL == (vol_plugin = (H5VL_t *)H5I_get_aux(loc_id))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "ID does not contain VOL information") + /* get the location object */ + if(NULL == (obj = (H5VL_object_t *)H5I_object(loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") /* Create the group through the VOL */ - if(NULL == (grp = H5VL_group_create(obj, loc_params, vol_plugin->cls, name, gcpl_id, gapl_id, - H5AC_dxpl_id, H5_REQUEST_NULL))) + if(NULL == (grp = H5VL_group_create(obj->vol_obj, loc_params, obj->vol_info->vol_cls, name, + gcpl_id, gapl_id, H5AC_dxpl_id, H5_REQUEST_NULL))) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to create group") - /* Get an atom for the group with the VOL information as the auxilary struct*/ - if((ret_value = H5VL_register_id(H5I_GROUP, grp, vol_plugin, TRUE)) < 0) + /* Get an atom for the group */ + if((ret_value = H5VL_register_id(H5I_GROUP, grp, obj->vol_info, TRUE)) < 0) HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to atomize group handle") done: if (ret_value < 0 && grp) - if(H5VL_group_close (grp, vol_plugin->cls, H5AC_dxpl_id, H5_REQUEST_NULL) < 0) + if(H5VL_group_close (grp, obj->vol_info->vol_cls, H5AC_dxpl_id, H5_REQUEST_NULL) < 0) HDONE_ERROR(H5E_SYM, H5E_CLOSEERROR, FAIL, "unable to release group") FUNC_LEAVE_API(ret_value) } /* end H5Gcreate2() */ @@ -383,11 +378,10 @@ done: hid_t H5Gcreate_anon(hid_t loc_id, hid_t gcpl_id, hid_t gapl_id) { - void *grp = NULL; /* dset token from VOL plugin */ - void *obj = NULL; /* object token of loc_id */ - H5VL_t *vol_plugin; /* VOL plugin information */ + void *grp = NULL; /* group token from VOL plugin */ + H5VL_object_t *obj = NULL; /* object token of loc_id */ H5VL_loc_params_t loc_params; - hid_t ret_value; + hid_t ret_value; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE3("i", "iii", loc_id, gcpl_id, gapl_id); @@ -409,26 +403,22 @@ H5Gcreate_anon(hid_t loc_id, hid_t gcpl_id, hid_t gapl_id) loc_params.type = H5VL_OBJECT_BY_SELF; loc_params.obj_type = H5I_get_type(loc_id); - /* get the file object */ - if(NULL == (obj = (void *)H5I_object(loc_id))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid file identifier") - - /* get the plugin pointer */ - if (NULL == (vol_plugin = (H5VL_t *)H5I_get_aux(loc_id))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "ID does not contain VOL information") + /* get the location object */ + if(NULL == (obj = (H5VL_object_t *)H5I_object(loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") /* Create the group through the VOL */ - if(NULL == (grp = H5VL_group_create(obj, loc_params, vol_plugin->cls, NULL, gcpl_id, gapl_id, - H5AC_dxpl_id, H5_REQUEST_NULL))) + if(NULL == (grp = H5VL_group_create(obj->vol_obj, loc_params, obj->vol_info->vol_cls, NULL, + gcpl_id, gapl_id, H5AC_dxpl_id, H5_REQUEST_NULL))) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to create group") - /* Get an atom for the group with the VOL information as the auxilary struct*/ - if((ret_value = H5VL_register_id(H5I_GROUP, grp, vol_plugin, TRUE)) < 0) + /* Get an atom for the group */ + if((ret_value = H5VL_register_id(H5I_GROUP, grp, obj->vol_info, TRUE)) < 0) HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to atomize group handle") done: if (ret_value < 0 && grp) - if(H5VL_group_close (grp, vol_plugin->cls, H5AC_dxpl_id, H5_REQUEST_NULL) < 0) + if(H5VL_group_close (grp, obj->vol_info->vol_cls, H5AC_dxpl_id, H5_REQUEST_NULL) < 0) HDONE_ERROR(H5E_SYM, H5E_CLOSEERROR, FAIL, "unable to release group") FUNC_LEAVE_API(ret_value) } /* end H5Gcreate_anon() */ @@ -454,11 +444,10 @@ done: hid_t H5Gopen2(hid_t loc_id, const char *name, hid_t gapl_id) { - void *grp = NULL; /* dset token from VOL plugin */ - void *obj = NULL; /* object token of loc_id */ - H5VL_t *vol_plugin; /* VOL plugin information */ + void *grp = NULL; /* group token from VOL plugin */ + H5VL_object_t *obj = NULL; /* object token of loc_id */ H5VL_loc_params_t loc_params; - hid_t ret_value; /* Return value */ + hid_t ret_value; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE3("i", "i*si", loc_id, name, gapl_id); @@ -477,26 +466,22 @@ H5Gopen2(hid_t loc_id, const char *name, hid_t gapl_id) loc_params.type = H5VL_OBJECT_BY_SELF; loc_params.obj_type = H5I_get_type(loc_id); - /* get the file object */ - if(NULL == (obj = (void *)H5I_object(loc_id))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid file identifier") - - /* get the plugin pointer */ - if (NULL == (vol_plugin = (H5VL_t *)H5I_get_aux(loc_id))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "ID does not contain VOL information") + /* get the location object */ + if(NULL == (obj = (H5VL_object_t *)H5I_object(loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") /* Create the group through the VOL */ - if(NULL == (grp = H5VL_group_open(obj, loc_params, vol_plugin->cls, name, gapl_id, - H5AC_dxpl_id, H5_REQUEST_NULL))) + if(NULL == (grp = H5VL_group_open(obj->vol_obj, loc_params, obj->vol_info->vol_cls, + name, gapl_id, H5AC_dxpl_id, H5_REQUEST_NULL))) HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to open group") - /* Get an atom for the group with the VOL information as the auxilary struct*/ - if((ret_value = H5VL_register_id(H5I_GROUP, grp, vol_plugin, TRUE)) < 0) + /* Get an atom for the group */ + if((ret_value = H5VL_register_id(H5I_GROUP, grp, obj->vol_info, TRUE)) < 0) HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to atomize group handle") done: if (ret_value < 0 && grp) - if(H5VL_group_close (grp, vol_plugin->cls, H5AC_dxpl_id, H5_REQUEST_NULL) < 0) + if(H5VL_group_close (grp, obj->vol_info->vol_cls, H5AC_dxpl_id, H5_REQUEST_NULL) < 0) HDONE_ERROR(H5E_SYM, H5E_CLOSEERROR, FAIL, "unable to release group") FUNC_LEAVE_API(ret_value) } /* end H5Gopen2() */ @@ -521,23 +506,18 @@ done: hid_t H5Gget_create_plist(hid_t grp_id) { - H5VL_t *vol_plugin; - void *grp; + H5VL_object_t *grp; hid_t ret_value = FAIL; FUNC_ENTER_API(FAIL) H5TRACE1("i", "i", grp_id); /* Check args */ - if(NULL == (grp = (void *)H5I_object_verify(grp_id, H5I_GROUP))) + if(NULL == (grp = (H5VL_object_t *)H5I_object_verify(grp_id, H5I_GROUP))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a group") - /* get the plugin pointer */ - if (NULL == (vol_plugin = (H5VL_t *)H5I_get_aux(grp_id))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "ID does not contain VOL information") - - if(H5VL_group_get(grp, vol_plugin->cls, H5VL_GROUP_GET_GCPL, H5AC_dxpl_id, H5_REQUEST_NULL, - &ret_value) < 0) + if(H5VL_group_get(grp->vol_obj, grp->vol_info->vol_cls, H5VL_GROUP_GET_GCPL, + H5AC_dxpl_id, H5_REQUEST_NULL, &ret_value) < 0) HGOTO_ERROR(H5E_INTERNAL, H5E_CANTGET, FAIL, "unable to get group creation properties") done: @@ -561,8 +541,7 @@ done: herr_t H5Gget_info(hid_t loc_id, H5G_info_t *grp_info) { - H5VL_t *vol_plugin; - void *obj; + H5VL_object_t *obj; H5I_type_t id_type; /* Type of ID */ H5VL_loc_params_t loc_params; herr_t ret_value = SUCCEED; /* Return value */ @@ -577,19 +556,16 @@ H5Gget_info(hid_t loc_id, H5G_info_t *grp_info) if(!grp_info) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no info struct") - /* get the plugin pointer */ - if (NULL == (vol_plugin = (H5VL_t *)H5I_get_aux(loc_id))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "ID does not contain VOL information") - /* get the dataset object */ - if(NULL == (obj = (void *)H5I_object(loc_id))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid group identifier") + /* get the location object */ + if(NULL == (obj = (H5VL_object_t *)H5I_object(loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") loc_params.type = H5VL_OBJECT_BY_SELF; loc_params.obj_type = id_type; /* Get the group info through the VOL using the location token */ - if((ret_value = H5VL_group_get(obj, vol_plugin->cls, H5VL_GROUP_GET_INFO, H5AC_ind_dxpl_id, - H5_REQUEST_NULL, loc_params, grp_info)) < 0) + if((ret_value = H5VL_group_get(obj->vol_obj, obj->vol_info->vol_cls, H5VL_GROUP_GET_INFO, + H5AC_ind_dxpl_id, H5_REQUEST_NULL, loc_params, grp_info)) < 0) HGOTO_ERROR(H5E_INTERNAL, H5E_CANTGET, FAIL, "unable to get group info") done: @@ -614,8 +590,7 @@ herr_t H5Gget_info_by_name(hid_t loc_id, const char *name, H5G_info_t *grp_info, hid_t lapl_id) { - H5VL_t *vol_plugin; - void *obj; + H5VL_object_t *obj; H5VL_loc_params_t loc_params; herr_t ret_value = SUCCEED; /* Return value */ @@ -638,16 +613,13 @@ H5Gget_info_by_name(hid_t loc_id, const char *name, H5G_info_t *grp_info, loc_params.loc_data.loc_by_name.lapl_id = lapl_id; loc_params.obj_type = H5I_get_type(loc_id); - /* get the plugin pointer */ - if (NULL == (vol_plugin = (H5VL_t *)H5I_get_aux(loc_id))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "ID does not contain VOL information") - /* get the dataset object */ - if(NULL == (obj = (void *)H5I_object(loc_id))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid group identifier") + /* get the location object */ + if(NULL == (obj = (H5VL_object_t *)H5I_object(loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") /* Get the group info through the VOL using the location token */ - if((ret_value = H5VL_group_get(obj, vol_plugin->cls, H5VL_GROUP_GET_INFO, H5AC_ind_dxpl_id, - H5_REQUEST_NULL, loc_params, grp_info)) < 0) + if((ret_value = H5VL_group_get(obj->vol_obj, obj->vol_info->vol_cls, H5VL_GROUP_GET_INFO, + H5AC_ind_dxpl_id, H5_REQUEST_NULL, loc_params, grp_info)) < 0) HGOTO_ERROR(H5E_INTERNAL, H5E_CANTGET, FAIL, "unable to get group info") done: @@ -673,8 +645,7 @@ herr_t H5Gget_info_by_idx(hid_t loc_id, const char *group_name, H5_index_t idx_type, H5_iter_order_t order, hsize_t n, H5G_info_t *grp_info, hid_t lapl_id) { - H5VL_t *vol_plugin; - void *obj; + H5VL_object_t *obj; H5VL_loc_params_t loc_params; herr_t ret_value = SUCCEED; /* Return value */ @@ -705,15 +676,13 @@ H5Gget_info_by_idx(hid_t loc_id, const char *group_name, H5_index_t idx_type, loc_params.loc_data.loc_by_idx.lapl_id = lapl_id; loc_params.obj_type = H5I_get_type(loc_id); - /* get the plugin pointer */ - if (NULL == (vol_plugin = (H5VL_t *)H5I_get_aux(loc_id))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "ID does not contain VOL information") - /* get the dataset object */ - if(NULL == (obj = (void *)H5I_object(loc_id))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid group identifier") + /* get the location object */ + if(NULL == (obj = (H5VL_object_t *)H5I_object(loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") /* Get the group info through the VOL using the location token */ - if((ret_value = H5VL_group_get(obj, vol_plugin->cls, H5VL_GROUP_GET_INFO, H5AC_ind_dxpl_id, + if((ret_value = H5VL_group_get(obj->vol_obj, obj->vol_info->vol_cls, + H5VL_GROUP_GET_INFO, H5AC_ind_dxpl_id, H5_REQUEST_NULL, loc_params, grp_info)) < 0) HGOTO_ERROR(H5E_INTERNAL, H5E_CANTGET, FAIL, "unable to get group info") @@ -753,11 +722,6 @@ H5Gclose(hid_t group_id) */ if(H5I_dec_app_ref(group_id) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTRELEASE, FAIL, "unable to close group") -#if 0 - /* Close the group through the VOL */ - if(H5VL_group_close(group_id, H5AC_dxpl_id, H5_REQUEST_NULL) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTRELEASE, FAIL, "unable to close group") -#endif done: FUNC_LEAVE_API(ret_value) @@ -779,19 +743,21 @@ done: *------------------------------------------------------------------------- */ herr_t -H5G_close_group(void *grp, H5VL_t *vol_plugin) +H5G_close_group(void *_grp) { + H5VL_object_t *grp = (H5VL_object_t *)_grp; herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT /* Close the group through the VOL*/ - if((ret_value = H5VL_group_close(grp, vol_plugin->cls, H5AC_dxpl_id, H5_REQUEST_NULL)) < 0) + if((ret_value = H5VL_group_close(grp->vol_obj, grp->vol_info->vol_cls, + H5AC_dxpl_id, H5_REQUEST_NULL)) < 0) HGOTO_ERROR(H5E_SYM, H5E_CLOSEERROR, FAIL, "unable to close group") - /* decrement ref count on VOL ID */ - if(H5VL_free_id(vol_plugin) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTDEC, FAIL, "unable to decrement ref count on VOL plugin") + /* free group */ + if(H5VL_free_object(grp) < 0) + HGOTO_ERROR(H5E_ATTR, H5E_CANTDEC, FAIL, "unable to free VOL object") done: FUNC_LEAVE_NOAPI(ret_value) |