diff options
author | Quincey Koziol <koziol@hdfgroup.org> | 2007-02-20 19:58:09 (GMT) |
---|---|---|
committer | Quincey Koziol <koziol@hdfgroup.org> | 2007-02-20 19:58:09 (GMT) |
commit | d08fabd66d4625bf387bb2edc9c19432332aed16 (patch) | |
tree | 421b336267de887763aa82c820a6fe05c3d9611b /src | |
parent | 8eecc944d7f741afcfd445a6c0f9906df759cdad (diff) | |
download | hdf5-d08fabd66d4625bf387bb2edc9c19432332aed16.zip hdf5-d08fabd66d4625bf387bb2edc9c19432332aed16.tar.gz hdf5-d08fabd66d4625bf387bb2edc9c19432332aed16.tar.bz2 |
[svn-r13353] Description:
Checkpoint progress on H5Aiterate2().
Mark H5Aiterate() as deprecated.
Various code cleanups.
Tested on:
Linux/32 2.6 (chicago)
Linux/64 2.6 (chicago2)
Diffstat (limited to 'src')
-rw-r--r-- | src/H5A.c | 119 | ||||
-rw-r--r-- | src/H5Adense.c | 17 | ||||
-rw-r--r-- | src/H5Adeprec.c | 68 | ||||
-rw-r--r-- | src/H5Aint.c | 14 | ||||
-rw-r--r-- | src/H5Apkg.h | 11 | ||||
-rw-r--r-- | src/H5Apublic.h | 13 | ||||
-rw-r--r-- | src/H5Doh.c | 4 | ||||
-rw-r--r-- | src/H5G.c | 2 | ||||
-rw-r--r-- | src/H5Goh.c | 4 | ||||
-rw-r--r-- | src/H5Gprivate.h | 2 | ||||
-rw-r--r-- | src/H5O.c | 11 | ||||
-rw-r--r-- | src/H5Oattribute.c | 59 | ||||
-rw-r--r-- | src/H5Opkg.h | 3 | ||||
-rw-r--r-- | src/H5Tcommit.c | 6 | ||||
-rw-r--r-- | src/H5Toh.c | 4 | ||||
-rw-r--r-- | src/H5Tprivate.h | 2 |
16 files changed, 268 insertions, 71 deletions
@@ -76,7 +76,6 @@ static H5A_t *H5A_open_by_name(const H5G_loc_t *loc, const char *obj_name, static herr_t H5A_write(H5A_t *attr, const H5T_t *mem_type, const void *buf, hid_t dxpl_id); static herr_t H5A_read(const H5A_t *attr, const H5T_t *mem_type, void *buf, hid_t dxpl_id); static hsize_t H5A_get_storage_size(const H5A_t *attr); -static herr_t H5A_get_info(const H5A_t *attr, H5A_info_t *ainfo); /*********************/ @@ -1503,10 +1502,12 @@ done: * *------------------------------------------------------------------------- */ -static herr_t +herr_t H5A_get_info(const H5A_t *attr, H5A_info_t *ainfo) { - FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5A_get_info) + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(H5A_get_info, FAIL) /* Check args */ HDassert(attr); @@ -1524,7 +1525,8 @@ H5A_get_info(const H5A_t *attr, H5A_info_t *ainfo) ainfo->corder = attr->crt_idx; } /* end else */ - FUNC_LEAVE_NOAPI(SUCCEED) +done: + FUNC_LEAVE_NOAPI(ret_value) } /* end H5A_get_info() */ @@ -1571,30 +1573,38 @@ done: /*-------------------------------------------------------------------------- NAME - H5Aiterate + H5Aiterate2 PURPOSE Calls a user's function for each attribute on an object USAGE - herr_t H5Aiterate (loc_id, attr_num, op, data) - hid_t loc_id; IN: Object (dataset or group) to be iterated over - unsigned *attr_num; IN/OUT: Starting (IN) & Ending (OUT) attribute number - H5A_operator_t op; IN: User's function to pass each attribute to - void *op_data; IN/OUT: User's data to pass through to iterator operator function + herr_t H5Aiterate2(loc_id, obj_name, idx_type, order, idx, op, op_data, lapl_id) + hid_t loc_id; IN: Base location for object + const char *obj_name; IN: Name of object relative to location + H5_index_t idx_type; IN: Type of index to use + H5_iter_order_t order; IN: Order to iterate over index + hsize_t *idx; IN/OUT: Starting (IN) & Ending (OUT) attribute + in index & order + H5A_operator2_t op; IN: User's function to pass each attribute to + void *op_data; IN/OUT: User's data to pass through to iterator + operator function + hid_t lapl_id; IN: Link access property list RETURNS - Returns a negative value if something is wrong, the return value of the - last operator if it was non-zero, or zero if all attributes were processed. + Returns a negative value if an error occurs, the return value of the + last operator if it was non-zero (which can be a negative value), or zero + if all attributes were processed. DESCRIPTION This function interates over the attributes of dataset or group - specified with 'loc_id'. For each attribute of the object, the - 'op_data' and some additional information (specified below) are passed - to the 'op' function. The iteration begins with the '*attr_number' + specified with 'loc_id' & 'obj_name'. For each attribute of the object, + the 'op_data' and some additional information (specified below) are passed + to the 'op' function. The iteration begins with the '*idx' object in the group and the next attribute to be processed by the operator - is returned in '*attr_number'. + is returned in '*idx'. The operation receives the ID for the group or dataset being iterated over ('loc_id'), the name of the current attribute about the object - ('attr_name') and the pointer to the operator data passed in to H5Aiterate - ('op_data'). The return values from an operator are: + ('attr_name'), the attribute's "info" struct ('ainfo') and the pointer to + the operator data passed in to H5Aiterate2 ('op_data'). The return values + from an operator are: A. Zero causes the iterator to continue, returning zero when all attributes have been processed. B. Positive causes the iterator to immediately return that positive @@ -1605,39 +1615,78 @@ done: attribute. --------------------------------------------------------------------------*/ herr_t -H5Aiterate(hid_t loc_id, unsigned *attr_num, H5A_operator_t op, void *op_data) +H5Aiterate2(hid_t loc_id, const char *obj_name, H5_index_t idx_type, + H5_iter_order_t order, hsize_t *idx, H5A_operator2_t op, void *op_data, + hid_t lapl_id) { - H5G_loc_t loc; /* Object location */ - H5A_attr_iter_op_t attr_op; /* Attribute operator */ - hsize_t start_idx; /* Index of attribute to start iterating at */ - hsize_t last_attr; /* Index of last attribute examined */ - herr_t ret_value; /* Return value */ + H5G_loc_t loc; /* Object location */ + H5G_loc_t obj_loc; /* Location used to open group */ + H5G_name_t obj_path; /* Opened object group hier. path */ + H5O_loc_t obj_oloc; /* Opened object object location */ + hbool_t loc_found = FALSE; /* Entry at 'obj_name' found */ + hid_t obj_loc_id = (-1); /* ID for object located */ + H5A_attr_iter_op_t attr_op; /* Attribute operator */ + hsize_t start_idx; /* Index of attribute to start iterating at */ + hsize_t last_attr; /* Index of last attribute examined */ + herr_t ret_value; /* Return value */ - FUNC_ENTER_API(H5Aiterate, FAIL) - H5TRACE4("e", "i*Iuxx", loc_id, attr_num, op, op_data); + FUNC_ENTER_API(H5Aiterate2, FAIL) /* check arguments */ if(H5I_ATTR == H5I_get_type(loc_id)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "location is not valid for an attribute") if(H5G_loc(loc_id, &loc) < 0) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") + if(!obj_name || !*obj_name) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no object name") + 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") + if(H5P_DEFAULT == lapl_id) + lapl_id = H5P_LINK_ACCESS_DEFAULT; + else + if(TRUE != H5P_isa_class(lapl_id, H5P_LINK_ACCESS)) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not link access property list ID") + + /* Set up opened group location to fill in */ + obj_loc.oloc = &obj_oloc; + obj_loc.path = &obj_path; + H5G_loc_reset(&obj_loc); + + /* Find the object's location */ + if(H5G_loc_find(&loc, obj_name, &obj_loc/*out*/, lapl_id, H5AC_ind_dxpl_id) < 0) + HGOTO_ERROR(H5E_ATTR, H5E_NOTFOUND, FAIL, "object not found") + loc_found = TRUE; + + /* Open the object */ + if((obj_loc_id = H5O_open_by_loc(&obj_loc, H5AC_ind_dxpl_id)) < 0) + HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, FAIL, "unable to open object") /* Build attribute operator info */ - attr_op.op_type = H5A_ATTR_OP_APP; - attr_op.u.app_op = op; + attr_op.op_type = H5A_ATTR_OP_APP2; + attr_op.u.app_op2 = op; /* Call attribute iteration routine */ - last_attr = start_idx = (hsize_t)(attr_num ? *attr_num : 0); - if((ret_value = H5O_attr_iterate(loc_id, loc.oloc, H5AC_ind_dxpl_id, H5_INDEX_CRT_ORDER, H5_ITER_INC, start_idx, &last_attr, &attr_op, op_data)) < 0) + last_attr = start_idx = (idx ? *idx : 0); + if((ret_value = H5O_attr_iterate(obj_loc_id, H5AC_ind_dxpl_id, idx_type, order, start_idx, &last_attr, &attr_op, op_data)) < 0) HERROR(H5E_ATTR, H5E_BADITER, "error iterating over attributes"); /* Set the last attribute information */ - if(attr_num) - *attr_num = (unsigned)last_attr; + if(idx) + *idx = last_attr; done: + /* Release resources */ + if(obj_loc_id > 0) { + if(H5I_dec_ref(obj_loc_id) < 0) + HDONE_ERROR(H5E_ATTR, H5E_CANTRELEASE, FAIL, "unable to close temporary object") + } /* end if */ + else if(loc_found && H5G_loc_free(&obj_loc) < 0) + HDONE_ERROR(H5E_ATTR, H5E_CANTRELEASE, FAIL, "can't free location") + FUNC_LEAVE_API(ret_value) -} /* H5Aiterate() */ +} /* H5Aiterate2() */ /*-------------------------------------------------------------------------- @@ -1646,7 +1695,7 @@ done: PURPOSE Deletes an attribute from a location USAGE - herr_t H5Adelete (loc_id, name) + herr_t H5Adelete2(loc_id, obj_name, attr_name, lapl_id) hid_t loc_id; IN: Base location for object const char *obj_name; IN: Name of object relative to location const char *attr_name; IN: Name of attribute to delete @@ -1704,7 +1753,7 @@ done: HDONE_ERROR(H5E_ATTR, H5E_CANTRELEASE, FAIL, "can't free location") FUNC_LEAVE_API(ret_value) -} /* H5Adelete() */ +} /* H5Adelete2() */ /*-------------------------------------------------------------------------- diff --git a/src/H5Adense.c b/src/H5Adense.c index d83c3e5..1dc7ad9 100644 --- a/src/H5Adense.c +++ b/src/H5Adense.c @@ -986,8 +986,8 @@ H5A_dense_iterate_bt2_cb(const void *_record, void *_bt2_udata) if(bt2_udata->skip > 0) --bt2_udata->skip; else { - H5A_fh_ud_cp_t fh_udata; /* User data for fractal heap 'op' callback */ - H5HF_t *fheap; /* Fractal heap handle for attribute storage */ + H5A_fh_ud_cp_t fh_udata; /* User data for fractal heap 'op' callback */ + H5HF_t *fheap; /* Fractal heap handle for attribute storage */ /* Check for iterating over shared attribute */ if(record->flags & H5O_MSG_FLAG_SHARED) @@ -1008,6 +1008,19 @@ H5A_dense_iterate_bt2_cb(const void *_record, void *_bt2_udata) /* Check which type of callback to make */ switch(bt2_udata->attr_op->op_type) { + case H5A_ATTR_OP_APP2: + { + H5A_info_t ainfo; /* Info for attribute */ + + /* Get the attribute information */ + if(H5A_get_info(fh_udata.attr, &ainfo) < 0) + HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, H5_ITER_ERROR, "unable to get attribute info") + + /* Make the application callback */ + ret_value = (bt2_udata->attr_op->u.app_op2)(bt2_udata->loc_id, fh_udata.attr->name, &ainfo, bt2_udata->op_data); + break; + } + case H5A_ATTR_OP_APP: /* Make the application callback */ ret_value = (bt2_udata->attr_op->u.app_op)(bt2_udata->loc_id, fh_udata.attr->name, bt2_udata->op_data); diff --git a/src/H5Adeprec.c b/src/H5Adeprec.c index 0e1d264..3baca88 100644 --- a/src/H5Adeprec.c +++ b/src/H5Adeprec.c @@ -168,6 +168,74 @@ done: /*-------------------------------------------------------------------------- NAME + H5Aiterate + PURPOSE + Calls a user's function for each attribute on an object + USAGE + herr_t H5Aiterate (loc_id, attr_num, op, data) + hid_t loc_id; IN: Object (dataset or group) to be iterated over + unsigned *attr_num; IN/OUT: Starting (IN) & Ending (OUT) attribute number + H5A_operator_t op; IN: User's function to pass each attribute to + void *op_data; IN/OUT: User's data to pass through to iterator operator function + RETURNS + Returns a negative value if something is wrong, the return value of the + last operator if it was non-zero, or zero if all attributes were processed. + + DESCRIPTION + This function interates over the attributes of dataset or group + specified with 'loc_id'. For each attribute of the object, the + 'op_data' and some additional information (specified below) are passed + to the 'op' function. The iteration begins with the '*attr_number' + object in the group and the next attribute to be processed by the operator + is returned in '*attr_number'. + The operation receives the ID for the group or dataset being iterated + over ('loc_id'), the name of the current attribute about the object + ('attr_name') and the pointer to the operator data passed in to H5Aiterate + ('op_data'). The return values from an operator are: + A. Zero causes the iterator to continue, returning zero when all + attributes have been processed. + B. Positive causes the iterator to immediately return that positive + value, indicating short-circuit success. The iterator can be + restarted at the next attribute. + C. Negative causes the iterator to immediately return that value, + indicating failure. The iterator can be restarted at the next + attribute. +--------------------------------------------------------------------------*/ +herr_t +H5Aiterate(hid_t loc_id, unsigned *attr_num, H5A_operator_t op, void *op_data) +{ + H5A_attr_iter_op_t attr_op; /* Attribute operator */ + hsize_t start_idx; /* Index of attribute to start iterating at */ + hsize_t last_attr; /* Index of last attribute examined */ + herr_t ret_value; /* Return value */ + + FUNC_ENTER_API(H5Aiterate, FAIL) + H5TRACE4("e", "i*Iuxx", loc_id, attr_num, op, op_data); + + /* check arguments */ + if(H5I_ATTR == H5I_get_type(loc_id)) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "location is not valid for an attribute") + + /* Build attribute operator info */ + attr_op.op_type = H5A_ATTR_OP_APP; + attr_op.u.app_op = op; + + /* Call attribute iteration routine */ + last_attr = start_idx = (hsize_t)(attr_num ? *attr_num : 0); + if((ret_value = H5O_attr_iterate(loc_id, H5AC_ind_dxpl_id, H5_INDEX_CRT_ORDER, H5_ITER_INC, start_idx, &last_attr, &attr_op, op_data)) < 0) + HERROR(H5E_ATTR, H5E_BADITER, "error iterating over attributes"); + + /* Set the last attribute information */ + if(attr_num) + *attr_num = (unsigned)last_attr; + +done: + FUNC_LEAVE_API(ret_value) +} /* H5Aiterate() */ + + +/*-------------------------------------------------------------------------- + NAME H5Adelete PURPOSE Deletes an attribute from a location diff --git a/src/H5Aint.c b/src/H5Aint.c index 8b4f92a..9d1b5c9 100644 --- a/src/H5Aint.c +++ b/src/H5Aint.c @@ -537,6 +537,19 @@ H5A_attr_iterate_table(const H5A_attr_table_t *atable, hsize_t skip, for(; u < atable->nattrs && !ret_value; u++) { /* Check which type of callback to make */ switch(attr_op->op_type) { + case H5A_ATTR_OP_APP2: + { + H5A_info_t ainfo; /* Info for attribute */ + + /* Get the attribute information */ + if(H5A_get_info(&atable->attrs[u], &ainfo) < 0) + HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, H5_ITER_ERROR, "unable to get attribute info") + + /* Make the application callback */ + ret_value = (attr_op->u.app_op2)(loc_id, atable->attrs[u].name, &ainfo, op_data); + break; + } + case H5A_ATTR_OP_APP: /* Make the application callback */ ret_value = (attr_op->u.app_op)(loc_id, atable->attrs[u].name, op_data); @@ -556,6 +569,7 @@ H5A_attr_iterate_table(const H5A_attr_table_t *atable, hsize_t skip, if(ret_value < 0) HERROR(H5E_ATTR, H5E_CANTNEXT, "iteration operator failed"); +done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5A_attr_iterate_table() */ diff --git a/src/H5Apkg.h b/src/H5Apkg.h index c8d1938..261f7be 100644 --- a/src/H5Apkg.h +++ b/src/H5Apkg.h @@ -137,10 +137,12 @@ typedef herr_t (*H5A_lib_iterate_t)(const H5A_t *attr, void *op_data); struct H5A_attr_iter_op_t { enum { H5A_ATTR_OP_APP, /* Application callback */ + H5A_ATTR_OP_APP2, /* Revised application callback */ H5A_ATTR_OP_LIB /* Library internal callback */ } op_type; union { - H5A_operator_t app_op; /* Application callback for each attribute */ + H5A_operator_t app_op; /* Application callback for each attribute */ + H5A_operator2_t app_op2; /* Revised application callback for each attribute */ H5A_lib_iterate_t lib_op; /* Library internal callback for each attribute */ } u; }; @@ -170,6 +172,7 @@ H5_DLLVAR const H5B2_class_t H5A_BT2_CORDER[1]; /* Function prototypes for H5A package scope */ H5_DLL herr_t H5A_init(void); H5_DLL H5A_t *H5A_copy(H5A_t *new_attr, const H5A_t *old_attr); +H5_DLL herr_t H5A_get_info(const H5A_t *attr, H5A_info_t *ainfo); H5_DLL herr_t H5A_free(H5A_t *attr); H5_DLL herr_t H5A_close(H5A_t *attr); @@ -218,9 +221,9 @@ H5_DLL herr_t H5O_attr_write(const H5O_loc_t *loc, hid_t dxpl_id, H5A_t *attr); H5_DLL herr_t H5O_attr_rename(const H5O_loc_t *loc, hid_t dxpl_id, const char *old_name, const char *new_name); -H5_DLL herr_t H5O_attr_iterate(hid_t loc_id, const H5O_loc_t *loc, hid_t dxpl_id, - H5_index_t idx_type, H5_iter_order_t order, hsize_t skip, - hsize_t *last_attr, const H5A_attr_iter_op_t *op, void *op_data); +H5_DLL herr_t H5O_attr_iterate(hid_t loc_id, hid_t dxpl_id, H5_index_t idx_type, + H5_iter_order_t order, hsize_t skip, hsize_t *last_attr, + const H5A_attr_iter_op_t *op, void *op_data); H5_DLL herr_t H5O_attr_remove(const H5O_loc_t *loc, const char *name, hid_t dxpl_id); H5_DLL herr_t H5O_attr_remove_by_idx(const H5O_loc_t *loc, H5_index_t idx_type, diff --git a/src/H5Apublic.h b/src/H5Apublic.h index 7268c73..8c97e46 100644 --- a/src/H5Apublic.h +++ b/src/H5Apublic.h @@ -36,10 +36,14 @@ typedef struct { hsize_t data_size; /* Size of raw data */ } H5A_info_t; -/* Typedef for H5Aiterate() callback */ +/* Typedef for H5Aiterate() callbacks */ typedef herr_t (*H5A_operator_t)(hid_t location_id/*in*/, const char *attr_name/*in*/, void *operator_data/*in,out*/); +/* Typedef for H5Aiterate2() callbacks */ +typedef herr_t (*H5A_operator2_t)(hid_t location_id/*in*/, + const char *attr_name/*in*/, const H5A_info_t *ainfo/*in*/, void *op_data/*in,out*/); + /* Public function prototypes */ H5_DLL hid_t H5Acreate(hid_t loc_id, const char *name, hid_t type_id, hid_t space_id, hid_t plist_id); @@ -62,8 +66,9 @@ H5_DLL ssize_t H5Aget_name_by_idx(hid_t loc_id, const char *obj_name, H5_index_t idx_type, H5_iter_order_t order, hsize_t n, char *name /*out*/, size_t size, hid_t lapl_id); H5_DLL herr_t H5Arename(hid_t loc_id, const char *old_name, const char *new_name); -H5_DLL herr_t H5Aiterate(hid_t loc_id, unsigned *attr_num, H5A_operator_t op, - void *op_data); +H5_DLL herr_t H5Aiterate2(hid_t loc_id, const char *obj_name, H5_index_t idx_type, + H5_iter_order_t order, hsize_t *idx, H5A_operator2_t op, void *op_data, + hid_t lapd_id); H5_DLL herr_t H5Adelete2(hid_t loc_id, const char *obj_name, const char *attr_name, hid_t lapl_id); H5_DLL herr_t H5Adelete_by_idx(hid_t loc_id, const char *obj_name, @@ -75,6 +80,8 @@ H5_DLL herr_t H5Adelete_by_idx(hid_t loc_id, const char *obj_name, * Use of these functions and variables is deprecated. */ H5_DLL int H5Aget_num_attrs(hid_t loc_id); +H5_DLL herr_t H5Aiterate(hid_t loc_id, unsigned *attr_num, H5A_operator_t op, + void *op_data); H5_DLL herr_t H5Adelete(hid_t loc_id, const char *name); #ifdef __cplusplus diff --git a/src/H5Doh.c b/src/H5Doh.c index 93a49c5..56cb565 100644 --- a/src/H5Doh.c +++ b/src/H5Doh.c @@ -43,7 +43,7 @@ static void *H5O_dset_get_copy_file_udata(void); static void H5O_dset_free_copy_file_udata(void *); static htri_t H5O_dset_isa(H5O_t *loc); -static hid_t H5O_dset_open(H5G_loc_t *obj_loc, hid_t dxpl_id); +static hid_t H5O_dset_open(const H5G_loc_t *obj_loc, hid_t dxpl_id); static H5O_loc_t *H5O_dset_get_oloc(hid_t obj_id); /*********************/ @@ -208,7 +208,7 @@ done: *------------------------------------------------------------------------- */ static hid_t -H5O_dset_open(H5G_loc_t *obj_loc, hid_t dxpl_id) +H5O_dset_open(const H5G_loc_t *obj_loc, hid_t dxpl_id) { H5D_t *dset = NULL; /* Dataset opened */ hid_t ret_value; /* Return value */ @@ -1177,7 +1177,7 @@ done: *------------------------------------------------------------------------- */ H5G_t * -H5G_open(H5G_loc_t *loc, hid_t dxpl_id) +H5G_open(const H5G_loc_t *loc, hid_t dxpl_id) { H5G_t *grp = NULL; H5G_shared_t *shared_fo = NULL; diff --git a/src/H5Goh.c b/src/H5Goh.c index 49dae84..6ea3a00 100644 --- a/src/H5Goh.c +++ b/src/H5Goh.c @@ -42,7 +42,7 @@ /********************/ static htri_t H5O_group_isa(H5O_t *loc); -static hid_t H5O_group_open(H5G_loc_t *obj_loc, hid_t dxpl_id); +static hid_t H5O_group_open(const H5G_loc_t *obj_loc, hid_t dxpl_id); static H5O_loc_t *H5O_group_get_oloc(hid_t obj_id); /*********************/ @@ -126,7 +126,7 @@ done: *------------------------------------------------------------------------- */ static hid_t -H5O_group_open(H5G_loc_t *obj_loc, hid_t dxpl_id) +H5O_group_open(const H5G_loc_t *obj_loc, hid_t dxpl_id) { H5G_t *grp = NULL; /* Group opened */ hid_t ret_value; /* Return value */ diff --git a/src/H5Gprivate.h b/src/H5Gprivate.h index a432c4e..934933e 100644 --- a/src/H5Gprivate.h +++ b/src/H5Gprivate.h @@ -150,7 +150,7 @@ H5_DLL H5G_t *H5G_rootof(H5F_t *f); H5_DLL H5G_name_t * H5G_nameof(H5G_t *grp); H5_DLL H5F_t *H5G_fileof(H5G_t *grp); H5_DLL herr_t H5G_free(H5G_t *grp); -H5_DLL H5G_t *H5G_open(H5G_loc_t *loc, hid_t dxpl_id); +H5_DLL H5G_t *H5G_open(const H5G_loc_t *loc, hid_t dxpl_id); H5_DLL herr_t H5G_close(H5G_t *grp); H5_DLL herr_t H5G_insertion_loc(H5G_loc_t *src_loc, const char *name, H5G_loc_t *insertion_loc/*out*/, hid_t dxpl_id); @@ -67,9 +67,8 @@ /* Local Prototypes */ /********************/ -static hid_t H5O_open_by_loc(H5G_loc_t *obj_loc, hid_t dxpl_id); static herr_t H5O_delete_oh(H5F_t *f, hid_t dxpl_id, H5O_t *oh); -static const H5O_obj_class_t *H5O_obj_class(H5O_loc_t *loc, hid_t dxpl_id); +static const H5O_obj_class_t *H5O_obj_class(const H5O_loc_t *loc, hid_t dxpl_id); static herr_t H5O_obj_type_real(H5O_t *oh, H5O_type_t *obj_type); @@ -823,13 +822,13 @@ done: * *------------------------------------------------------------------------- */ -static hid_t -H5O_open_by_loc(H5G_loc_t *obj_loc, hid_t dxpl_id) +hid_t +H5O_open_by_loc(const H5G_loc_t *obj_loc, hid_t dxpl_id) { const H5O_obj_class_t *obj_class; /* Class of object for location */ hid_t ret_value; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT(H5O_open_by_loc) + FUNC_ENTER_NOAPI(H5O_open_by_loc, FAIL) HDassert(obj_loc); @@ -1496,7 +1495,7 @@ done: *------------------------------------------------------------------------- */ static const H5O_obj_class_t * -H5O_obj_class(H5O_loc_t *loc, hid_t dxpl_id) +H5O_obj_class(const H5O_loc_t *loc, hid_t dxpl_id) { H5O_t *oh = NULL; /* Object header for location */ const H5O_obj_class_t *ret_value; /* Return value */ diff --git a/src/H5Oattribute.c b/src/H5Oattribute.c index e3140cd..ea0f073 100644 --- a/src/H5Oattribute.c +++ b/src/H5Oattribute.c @@ -125,6 +125,9 @@ typedef struct { /********************/ /* Local Prototypes */ /********************/ +static herr_t H5O_attr_iterate_real(hid_t loc_id, const H5O_loc_t *loc, + hid_t dxpl_id, H5_index_t idx_type, H5_iter_order_t order, hsize_t skip, + hsize_t *last_attr, const H5A_attr_iter_op_t *attr_op, void *op_data); /*********************/ @@ -494,7 +497,7 @@ H5O_attr_open_by_idx(const H5O_loc_t *loc, H5_index_t idx_type, attr_op.u.lib_op = H5O_attr_open_by_idx_cb; /* Iterate over attributes to locate correct one */ - if(H5O_attr_iterate((hid_t)-1, loc, dxpl_id, idx_type, order, n, NULL, &attr_op, &ret_value) < 0) + if(H5O_attr_iterate_real((hid_t)-1, loc, dxpl_id, idx_type, order, n, NULL, &attr_op, &ret_value) < 0) HGOTO_ERROR(H5E_ATTR, H5E_BADITER, NULL, "can't locate attribute") done: @@ -940,9 +943,9 @@ done: /*------------------------------------------------------------------------- - * Function: H5O_attr_iterate + * Function: H5O_attr_iterate_real * - * Purpose: Iterate over attributes for an object. + * Purpose: Internal routine to iterate over attributes for an object. * * Return: Non-negative on success/Negative on failure * @@ -951,20 +954,22 @@ done: * *------------------------------------------------------------------------- */ -herr_t -H5O_attr_iterate(hid_t loc_id, const H5O_loc_t *loc, hid_t dxpl_id, +static herr_t +H5O_attr_iterate_real(hid_t loc_id, const H5O_loc_t *loc, hid_t dxpl_id, H5_index_t idx_type, H5_iter_order_t order, hsize_t skip, hsize_t *last_attr, const H5A_attr_iter_op_t *attr_op, void *op_data) { H5O_t *oh = NULL; /* Pointer to actual object header */ unsigned oh_flags = H5AC__NO_FLAGS_SET; /* Metadata cache flags for object header */ H5A_attr_table_t atable = {0, NULL}; /* Table of attributes */ - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT(H5O_attr_iterate) + FUNC_ENTER_NOAPI_NOINIT(H5O_attr_iterate_real) /* Check arguments */ HDassert(loc); + HDassert(loc->file); + HDassert(H5F_addr_defined(loc->addr)); HDassert(attr_op); /* Protect the object header to iterate over */ @@ -1024,7 +1029,45 @@ done: HDONE_ERROR(H5E_ATTR, H5E_CANTFREE, FAIL, "unable to release attribute table") FUNC_LEAVE_NOAPI(ret_value) -} /* end H5O_attr_iterate */ +} /* end H5O_attr_iterate_real() */ + + +/*------------------------------------------------------------------------- + * Function: H5O_attr_iterate + * + * Purpose: Iterate over attributes for an object. + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Quincey Koziol + * Tuesday, December 5, 2006 + * + *------------------------------------------------------------------------- + */ +herr_t +H5O_attr_iterate(hid_t loc_id, hid_t dxpl_id, + H5_index_t idx_type, H5_iter_order_t order, hsize_t skip, + hsize_t *last_attr, const H5A_attr_iter_op_t *attr_op, void *op_data) +{ + H5G_loc_t loc; /* Object location */ + herr_t ret_value; /* Return value */ + + FUNC_ENTER_NOAPI_NOINIT(H5O_attr_iterate) + + /* Check arguments */ + HDassert(attr_op); + + /* Look up location for location ID */ + if(H5G_loc(loc_id, &loc) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") + + /* Iterate over attributes to locate correct one */ + if((ret_value = H5O_attr_iterate_real(loc_id, loc.oloc, dxpl_id, idx_type, order, skip, last_attr, attr_op, op_data)) < 0) + HERROR(H5E_ATTR, H5E_BADITER, "error iterating over attributes"); + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5O_attr_iterate() */ /*------------------------------------------------------------------------- diff --git a/src/H5Opkg.h b/src/H5Opkg.h index 29c9052..d8e63dc 100644 --- a/src/H5Opkg.h +++ b/src/H5Opkg.h @@ -276,7 +276,7 @@ typedef struct H5O_obj_class_t { void *(*get_copy_file_udata)(void); /*retrieve user data for 'copy file' operation */ void (*free_copy_file_udata)(void *); /*free user data for 'copy file' operation */ htri_t (*isa)(H5O_t *); /*if a header matches an object class */ - hid_t (*open)(H5G_loc_t *, hid_t ); /*open an object of this class */ + hid_t (*open)(const H5G_loc_t *, hid_t ); /*open an object of this class */ H5O_loc_t *(*get_oloc)(hid_t ); /*get the object header location for an object */ } H5O_obj_class_t; @@ -427,6 +427,7 @@ H5_DLLVAR const H5O_obj_class_t H5O_OBJ_DATATYPE[1]; /* Package-local function prototypes */ H5_DLL herr_t H5O_flush_msgs(H5F_t *f, H5O_t *oh); +H5_DLL hid_t H5O_open_by_loc(const H5G_loc_t *obj_loc, hid_t dxpl_id); H5_DLL herr_t H5O_delete_mesg(H5F_t *f, hid_t dxpl_id, H5O_mesg_t *mesg); H5_DLL const H5O_obj_class_t *H5O_obj_class_real(H5O_t *oh); diff --git a/src/H5Tcommit.c b/src/H5Tcommit.c index fe1d9f3..dd92fd3 100644 --- a/src/H5Tcommit.c +++ b/src/H5Tcommit.c @@ -37,7 +37,7 @@ /* Static local functions */ static herr_t H5T_commit(H5F_t *file, H5T_t *type, hid_t dxpl_id, hid_t tcpl_id, hid_t tapl_id); -static H5T_t *H5T_open_oid(H5G_loc_t *loc, hid_t dxpl_id); +static H5T_t *H5T_open_oid(const H5G_loc_t *loc, hid_t dxpl_id); /*-------------------------------------------------------------------------- @@ -667,7 +667,7 @@ done: *------------------------------------------------------------------------- */ H5T_t * -H5T_open(H5G_loc_t *loc, hid_t dxpl_id) +H5T_open(const H5G_loc_t *loc, hid_t dxpl_id) { H5T_shared_t *shared_fo = NULL; H5T_t *dt = NULL; @@ -776,7 +776,7 @@ done: *------------------------------------------------------------------------- */ static H5T_t * -H5T_open_oid(H5G_loc_t *loc, hid_t dxpl_id) +H5T_open_oid(const H5G_loc_t *loc, hid_t dxpl_id) { H5T_t *dt = NULL; H5T_t *ret_value; diff --git a/src/H5Toh.c b/src/H5Toh.c index 73e6c24..2c952e1 100644 --- a/src/H5Toh.c +++ b/src/H5Toh.c @@ -43,7 +43,7 @@ /********************/ static htri_t H5O_dtype_isa(H5O_t *loc); -static hid_t H5O_dtype_open(H5G_loc_t *obj_loc, hid_t dxpl_id); +static hid_t H5O_dtype_open(const H5G_loc_t *obj_loc, hid_t dxpl_id); static H5O_loc_t *H5O_dtype_get_oloc(hid_t obj_id); @@ -121,7 +121,7 @@ done: *------------------------------------------------------------------------- */ static hid_t -H5O_dtype_open(H5G_loc_t *obj_loc, hid_t dxpl_id) +H5O_dtype_open(const H5G_loc_t *obj_loc, hid_t dxpl_id) { H5T_t *type = NULL; /* Datatype opened */ hid_t ret_value; /* Return value */ diff --git a/src/H5Tprivate.h b/src/H5Tprivate.h index 759f7af..9ab7566 100644 --- a/src/H5Tprivate.h +++ b/src/H5Tprivate.h @@ -103,7 +103,7 @@ H5_DLL uint32_t H5T_hash(H5F_t * file, const H5T_t *dt); H5_DLL H5R_type_t H5T_get_ref_type(const H5T_t *dt); /* Operations on named datatypes */ -H5_DLL H5T_t *H5T_open(H5G_loc_t *loc, hid_t dxpl_id); +H5_DLL H5T_t *H5T_open(const H5G_loc_t *loc, hid_t dxpl_id); H5_DLL htri_t H5T_committed(const H5T_t *type); H5_DLL int H5T_link(const H5T_t *type, int adjust, hid_t dxpl_id); |