summaryrefslogtreecommitdiffstats
path: root/src/H5Adeprec.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/H5Adeprec.c')
-rw-r--r--src/H5Adeprec.c106
1 files changed, 71 insertions, 35 deletions
diff --git a/src/H5Adeprec.c b/src/H5Adeprec.c
index 9221254..1e031f7 100644
--- a/src/H5Adeprec.c
+++ b/src/H5Adeprec.c
@@ -38,6 +38,7 @@
/***********/
#include "H5private.h" /* Generic Functions */
#include "H5Apkg.h" /* Attributes */
+#include "H5CXprivate.h" /* API Contexts */
#include "H5Dprivate.h" /* Datasets */
#include "H5Eprivate.h" /* Error handling */
#include "H5Iprivate.h" /* IDs */
@@ -87,12 +88,12 @@
PURPOSE
Creates an attribute on an object
USAGE
- hid_t H5Acreate1(loc_id, name, type_id, space_id, plist_id)
+ hid_t H5Acreate1(loc_id, name, type_id, space_id, acpl_id)
hid_t loc_id; IN: Object (dataset or group) to be attached to
const char *name; IN: Name of attribute to create
hid_t type_id; IN: ID of datatype for attribute
hid_t space_id; IN: ID of dataspace for attribute
- hid_t plist_id; IN: ID of creation property list (currently not used)
+ hid_t acpl_id; IN: ID of creation property list (currently not used)
RETURNS
Non-negative on success/Negative on failure
@@ -110,16 +111,17 @@
--------------------------------------------------------------------------*/
hid_t
H5Acreate1(hid_t loc_id, const char *name, hid_t type_id, hid_t space_id,
- hid_t plist_id)
+ hid_t acpl_id)
{
- H5A_t *attr = NULL; /* Attribute created */
- H5G_loc_t loc; /* Object location */
- H5T_t *type; /* Datatype to use for attribute */
- H5S_t *space; /* Dataspace to use for attribute */
- hid_t ret_value; /* Return value */
+ H5A_t *attr = NULL; /* Attribute created */
+ H5G_loc_t loc; /* Object location */
+ H5T_t *type; /* Datatype to use for attribute */
+ H5S_t *space; /* Dataspace to use for attribute */
+hbool_t api_ctx_pushed = FALSE; /* Whether API context pushed */
+ hid_t ret_value; /* Return value */
FUNC_ENTER_API(FAIL)
- H5TRACE5("i", "i*siii", loc_id, name, type_id, space_id, plist_id);
+ H5TRACE5("i", "i*siii", loc_id, name, type_id, space_id, acpl_id);
/* check arguments */
if(H5I_ATTR == H5I_get_type(loc_id))
@@ -135,8 +137,16 @@ H5Acreate1(hid_t loc_id, const char *name, hid_t type_id, hid_t space_id,
if(NULL == (space = (H5S_t *)H5I_object_verify(space_id, H5I_DATASPACE)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data space")
+/* Set API context */
+if(H5CX_push() < 0)
+ HGOTO_ERROR(H5E_ATTR, H5E_CANTSET, H5I_INVALID_HID, "can't set API context")
+api_ctx_pushed = TRUE;
+/* Set up collective metadata if appropriate */
+if(H5CX_set_loc(loc_id, TRUE) < 0)
+ HGOTO_ERROR(H5E_ATTR, H5E_CANTSET, H5I_INVALID_HID, "can't set collective metadata read")
+
/* Go do the real work for attaching the attribute to the dataset */
- if(NULL==(attr = H5A_create(&loc, name, type, space, plist_id, H5AC_ind_read_dxpl_id)))
+ if(NULL == (attr = H5A__create(&loc, name, type, space, acpl_id)))
HGOTO_ERROR(H5E_ATTR, H5E_CANTINIT, FAIL, "unable to create attribute")
/* Register the new attribute and get an ID for it */
@@ -144,6 +154,12 @@ H5Acreate1(hid_t loc_id, const char *name, hid_t type_id, hid_t space_id,
HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to register attribute for ID")
done:
+ /* Cleanup on failure */
+ if(ret_value < 0 && attr && H5A__close(attr) < 0)
+ HDONE_ERROR(H5E_ATTR, H5E_CANTFREE, FAIL, "can't close attribute")
+if(api_ctx_pushed && H5CX_pop() < 0)
+ HDONE_ERROR(H5E_ATTR, H5E_CANTRESET, H5I_INVALID_HID, "can't reset API context")
+
FUNC_LEAVE_API(ret_value)
} /* H5Acreate1() */
@@ -173,9 +189,10 @@ done:
hid_t
H5Aopen_name(hid_t loc_id, const char *name)
{
- H5G_loc_t loc; /* Object location */
- H5A_t *attr = NULL; /* Attribute opened */
- hid_t ret_value;
+ H5G_loc_t loc; /* Object location */
+ H5A_t *attr = NULL; /* Attribute opened */
+hbool_t api_ctx_pushed = FALSE; /* Whether API context pushed */
+ hid_t ret_value;
FUNC_ENTER_API(FAIL)
H5TRACE2("i", "i*s", loc_id, name);
@@ -188,8 +205,13 @@ H5Aopen_name(hid_t loc_id, const char *name)
if(!name || !*name)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name")
+/* Set API context */
+if(H5CX_push() < 0)
+ HGOTO_ERROR(H5E_ATTR, H5E_CANTSET, H5I_INVALID_HID, "can't set API context")
+api_ctx_pushed = TRUE;
+
/* Open the attribute on the object header */
- if(NULL == (attr = H5A_open_by_name(&loc, ".", name, H5P_LINK_ACCESS_DEFAULT, H5AC_ind_read_dxpl_id)))
+ if(NULL == (attr = H5A__open_by_name(&loc, ".", name)))
HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, FAIL, "can't open attribute: '%s'", name)
/* Register the attribute and get an ID for it */
@@ -199,8 +221,10 @@ H5Aopen_name(hid_t loc_id, const char *name)
done:
/* Cleanup on failure */
if(ret_value < 0)
- if(attr && H5A_close(attr) < 0)
+ if(attr && H5A__close(attr) < 0)
HDONE_ERROR(H5E_ATTR, H5E_CANTFREE, FAIL, "can't close attribute")
+if(api_ctx_pushed && H5CX_pop() < 0)
+ HDONE_ERROR(H5E_ATTR, H5E_CANTRESET, H5I_INVALID_HID, "can't reset API context")
FUNC_LEAVE_API(ret_value)
} /* H5Aopen_name() */
@@ -233,6 +257,7 @@ H5Aopen_idx(hid_t loc_id, unsigned idx)
{
H5G_loc_t loc; /* Object location */
H5A_t *attr = NULL; /* Attribute opened */
+hbool_t api_ctx_pushed = FALSE; /* Whether API context pushed */
hid_t ret_value;
FUNC_ENTER_API(FAIL)
@@ -244,9 +269,14 @@ H5Aopen_idx(hid_t loc_id, unsigned idx)
if(H5G_loc(loc_id, &loc) < 0)
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location")
+/* Set API context */
+if(H5CX_push() < 0)
+ HGOTO_ERROR(H5E_ATTR, H5E_CANTSET, H5I_INVALID_HID, "can't set API context")
+api_ctx_pushed = TRUE;
+
/* Open the attribute in the object header */
- if(NULL == (attr = H5A_open_by_idx(&loc, ".", H5_INDEX_CRT_ORDER, H5_ITER_INC, (hsize_t)idx, H5P_LINK_ACCESS_DEFAULT, H5AC_ind_read_dxpl_id)))
- HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, FAIL, "unable to open attribute")
+ if(NULL == (attr = H5A__open_by_idx(&loc, ".", H5_INDEX_CRT_ORDER, H5_ITER_INC, (hsize_t)idx)))
+ HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, H5I_INVALID_HID, "unable to open attribute")
/* Register the attribute and get an ID for it */
if((ret_value = H5I_register(H5I_ATTR, attr, TRUE)) < 0)
@@ -255,8 +285,10 @@ H5Aopen_idx(hid_t loc_id, unsigned idx)
done:
/* Cleanup on failure */
if(ret_value < 0)
- if(attr && H5A_close(attr) < 0)
+ if(attr && H5A__close(attr) < 0)
HDONE_ERROR(H5E_ATTR, H5E_CANTFREE, FAIL, "can't close attribute")
+if(api_ctx_pushed && H5CX_pop() < 0)
+ HDONE_ERROR(H5E_ATTR, H5E_CANTRESET, H5I_INVALID_HID, "can't reset API context")
FUNC_LEAVE_API(ret_value)
} /* H5Aopen_idx() */
@@ -283,9 +315,10 @@ done:
int
H5Aget_num_attrs(hid_t loc_id)
{
- H5O_loc_t *loc; /* Object location for attribute */
- void *obj;
- int ret_value;
+ H5O_loc_t *loc; /* Object location for attribute */
+ void *obj;
+hbool_t api_ctx_pushed = FALSE; /* Whether API context pushed */
+ int ret_value;
FUNC_ENTER_API(FAIL)
H5TRACE1("Is", "i", loc_id);
@@ -330,11 +363,18 @@ H5Aget_num_attrs(hid_t loc_id)
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "inappropriate attribute target")
} /*lint !e788 All appropriate cases are covered */
+/* Set API context */
+if(H5CX_push() < 0)
+ HGOTO_ERROR(H5E_ATTR, H5E_CANTSET, H5I_INVALID_HID, "can't set API context")
+api_ctx_pushed = TRUE;
+
/* Look up the # of attributes for the object */
- if((ret_value = H5O_attr_count(loc, H5AC_ind_read_dxpl_id)) < 0)
+ if((ret_value = H5A__get_num_attrs(loc)) < 0)
HGOTO_ERROR(H5E_ATTR, H5E_CANTCOUNT, FAIL, "can't get attribute count for object")
done:
+if(api_ctx_pushed && H5CX_pop() < 0)
+ HDONE_ERROR(H5E_ATTR, H5E_CANTRESET, FAIL, "can't reset API context")
FUNC_LEAVE_API(ret_value)
} /* H5Aget_num_attrs() */
@@ -379,10 +419,8 @@ done:
herr_t
H5Aiterate1(hid_t loc_id, unsigned *attr_num, H5A_operator1_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 */
+hbool_t api_ctx_pushed = FALSE; /* Whether API context pushed */
+ herr_t ret_value; /* Return value */
FUNC_ENTER_API(FAIL)
H5TRACE4("e", "i*Iux*x", loc_id, attr_num, op, op_data);
@@ -391,20 +429,18 @@ H5Aiterate1(hid_t loc_id, unsigned *attr_num, H5A_operator1_t op, void *op_data)
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;
+/* Set API context */
+if(H5CX_push() < 0)
+ HGOTO_ERROR(H5E_ATTR, H5E_CANTSET, FAIL, "can't set API context")
+api_ctx_pushed = TRUE;
/* 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_read_dxpl_id, H5_INDEX_CRT_ORDER, H5_ITER_INC, start_idx, &last_attr, &attr_op, op_data)) < 0)
+ if((ret_value = H5A__iterate_old(loc_id, attr_num, 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:
+if(api_ctx_pushed && H5CX_pop() < 0)
+ HDONE_ERROR(H5E_ATTR, H5E_CANTRESET, FAIL, "can't reset API context")
FUNC_LEAVE_API(ret_value)
} /* H5Aiterate1() */
#endif /* H5_NO_DEPRECATED_SYMBOLS */