summaryrefslogtreecommitdiffstats
path: root/src/H5Doh.c
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2006-11-06 21:35:44 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2006-11-06 21:35:44 (GMT)
commit2e8e42d6c9a229d0490cd97e9711fb707ad67578 (patch)
tree4c221dc336d6ef82cabe6af3c88ceeee15bf3067 /src/H5Doh.c
parent0a2cdffb0b11b92dc7ebdc6b188f3de10d53d9aa (diff)
downloadhdf5-2e8e42d6c9a229d0490cd97e9711fb707ad67578.zip
hdf5-2e8e42d6c9a229d0490cd97e9711fb707ad67578.tar.gz
hdf5-2e8e42d6c9a229d0490cd97e9711fb707ad67578.tar.bz2
[svn-r12869] Description:
Rename new H5Gcopy() routine to H5Ocopy() as discussed in last Friday's design discussion. Tested on: Linux/32 2.6 (chicago)
Diffstat (limited to 'src/H5Doh.c')
-rw-r--r--src/H5Doh.c168
1 files changed, 124 insertions, 44 deletions
diff --git a/src/H5Doh.c b/src/H5Doh.c
index ff42659..6781e25 100644
--- a/src/H5Doh.c
+++ b/src/H5Doh.c
@@ -22,8 +22,10 @@
/* Headers */
/***********/
#include "H5private.h" /* Generic Functions */
+#include "H5Dprivate.h" /* Datasets */
#include "H5Eprivate.h" /* Error handling */
#include "H5FLprivate.h" /* Free lists */
+#include "H5Iprivate.h" /* IDs */
#include "H5Opkg.h" /* Object headers */
/****************/
@@ -37,9 +39,11 @@
/********************/
/* Local Prototypes */
/********************/
-static htri_t H5O_dset_isa(H5O_t *loc);
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 H5O_loc_t *H5O_dset_get_oloc(hid_t obj_id);
/*********************/
/* Package Variables */
@@ -59,7 +63,9 @@ const H5O_obj_class_t H5O_OBJ_DATASET[1] = {{
"dataset", /* object name, for debugging */
H5O_dset_get_copy_file_udata, /* get 'copy file' user data */
H5O_dset_free_copy_file_udata, /* free 'copy file' user data */
- H5O_dset_isa /* "isa" message */
+ H5O_dset_isa, /* "isa" message */
+ H5O_dset_open, /* open an object of this class */
+ H5O_dset_get_oloc /* get an object header location for an object */
}};
/* Declare a free list to manage the H5D_copy_file_ud_t struct */
@@ -67,6 +73,79 @@ H5FL_DEFINE(H5D_copy_file_ud_t);
/*-------------------------------------------------------------------------
+ * Function: H5O_dset_get_copy_file_udata
+ *
+ * Purpose: Allocates the user data needed for copying a dataset's
+ * object header from file to file.
+ *
+ * Return: Success: Non-NULL pointer to user data
+ *
+ * Failure: NULL
+ *
+ * Programmer: Quincey Koziol
+ * Monday, November 21, 2005
+ *
+ *-------------------------------------------------------------------------
+ */
+static void *
+H5O_dset_get_copy_file_udata(void)
+{
+ void *ret_value; /* Return value */
+
+ FUNC_ENTER_NOAPI_NOINIT(H5O_dset_get_copy_file_udata)
+
+ /* Allocate space for the 'copy file' user data for copying datasets */
+ if(NULL == (ret_value = H5FL_CALLOC(H5D_copy_file_ud_t)))
+ HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed")
+
+done:
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5O_dset_get_copy_file_udata() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5O_dset_free_copy_file_udata
+ *
+ * Purpose: Release the user data needed for copying a dataset's
+ * object header from file to file.
+ *
+ * Return: <none>
+ *
+ * Programmer: Quincey Koziol
+ * Monday, November 21, 2005
+ *
+ * Modifications: Peter Cao
+ * Tuesday, December 27, 2005
+ * Free filter pipeline for copying a dataset
+ *
+ *-------------------------------------------------------------------------
+ */
+static void
+H5O_dset_free_copy_file_udata(void *_udata)
+{
+ H5D_copy_file_ud_t *udata = (H5D_copy_file_ud_t *)_udata;
+
+ FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5O_dset_free_copy_file_udata)
+
+ /* Sanity check */
+ HDassert(udata);
+
+ /* Release copy of dataset's datatype, if it was set */
+ if(udata->src_dtype)
+ H5T_close(udata->src_dtype);
+
+ /* Release copy of dataset's filter pipeline, if it was set */
+ if (udata->src_pline)
+ H5O_free(H5O_PLINE_ID, udata->src_pline);
+
+ /* Release space for 'copy file' user data */
+ H5FL_FREE(H5D_copy_file_ud_t, udata);
+
+ FUNC_LEAVE_NOAPI_VOID
+} /* end H5O_dset_free_copy_file_udata() */
+
+
+/*-------------------------------------------------------------------------
* Function: H5O_dset_isa
*
* Purpose: Determines if an object has the requisite messages for being
@@ -111,74 +190,75 @@ done:
/*-------------------------------------------------------------------------
- * Function: H5O_dset_get_copy_file_udata
+ * Function: H5O_dset_open
*
- * Purpose: Allocates the user data needed for copying a dataset's
- * object header from file to file.
+ * Purpose: Open a dataset at a particular location
*
- * Return: Success: Non-NULL pointer to user data
- *
- * Failure: NULL
+ * Return: Success: Open object identifier
+ * Failure: Negative
*
* Programmer: Quincey Koziol
- * Monday, November 21, 2005
+ * Monday, November 6, 2006
*
*-------------------------------------------------------------------------
*/
-static void *
-H5O_dset_get_copy_file_udata(void)
+static hid_t
+H5O_dset_open(H5G_loc_t *obj_loc, hid_t dxpl_id)
{
- void *ret_value; /* Return value */
+ H5D_t *dset = NULL; /* Dataset opened */
+ hid_t ret_value; /* Return value */
- FUNC_ENTER_NOAPI_NOINIT(H5O_dset_get_copy_file_udata)
+ FUNC_ENTER_NOAPI_NOINIT(H5O_dset_open)
- /* Allocate space for the 'copy file' user data for copying datasets */
- if(NULL == (ret_value = H5FL_CALLOC(H5D_copy_file_ud_t)))
- HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed")
+ HDassert(obj_loc);
+
+ /* Open the dataset */
+ if((dset = H5D_open(obj_loc, dxpl_id)) == NULL)
+ HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to open dataset")
+
+ /* Register an ID for the dataset */
+ if((ret_value = H5I_register(H5I_DATASET, dset)) < 0)
+ HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to register dataset")
done:
+ if(ret_value < 0)
+ if(dset != NULL)
+ H5D_close(dset);
+
FUNC_LEAVE_NOAPI(ret_value)
-} /* end H5O_dset_get_copy_file_udata() */
+} /* end H5O_dset_open() */
/*-------------------------------------------------------------------------
- * Function: H5O_dset_free_copy_file_udata
+ * Function: H5O_dset_get_oloc
*
- * Purpose: Release the user data needed for copying a dataset's
- * object header from file to file.
+ * Purpose: Retrieve the object header location for an open object
*
- * Return: <none>
+ * Return: Success: Pointer to object header location
+ * Failure: NULL
*
* Programmer: Quincey Koziol
- * Monday, November 21, 2005
- *
- * Modifications: Peter Cao
- * Tuesday, December 27, 2005
- * Free filter pipeline for copying a dataset
+ * Monday, November 6, 2006
*
*-------------------------------------------------------------------------
*/
-static void
-H5O_dset_free_copy_file_udata(void *_udata)
+static H5O_loc_t *
+H5O_dset_get_oloc(hid_t obj_id)
{
- H5D_copy_file_ud_t *udata = (H5D_copy_file_ud_t *)_udata;
-
- FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5O_dset_free_copy_file_udata)
+ H5D_t *dset; /* Dataset opened */
+ H5O_loc_t *ret_value; /* Return value */
- /* Sanity check */
- HDassert(udata);
+ FUNC_ENTER_NOAPI_NOINIT(H5O_dset_get_oloc)
- /* Release copy of dataset's datatype, if it was set */
- if(udata->src_dtype)
- H5T_close(udata->src_dtype);
+ /* Get the dataset */
+ if((dset = H5I_object(obj_id)) == NULL)
+ HGOTO_ERROR(H5E_OHDR, H5E_BADATOM, NULL, "couldn't get object from ID")
- /* Release copy of dataset's filter pipeline, if it was set */
- if (udata->src_pline)
- H5O_free(H5O_PLINE_ID, udata->src_pline);
+ /* Get the dataset's object header location */
+ if((ret_value = H5D_oloc(dset)) == NULL)
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, NULL, "unable to get object location from object")
- /* Release space for 'copy file' user data */
- H5FL_FREE(H5D_copy_file_ud_t, udata);
-
- FUNC_LEAVE_NOAPI_VOID
-} /* end H5O_dset_free_copy_file_udata() */
+done:
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5O_dset_get_oloc() */