1998-10-08 05:04:51 +08:00
|
|
|
|
/****************************************************************************
|
|
|
|
|
* NCSA HDF *
|
|
|
|
|
* Software Development Group *
|
|
|
|
|
* National Center for Supercomputing Applications *
|
|
|
|
|
* University of Illinois at Urbana-Champaign *
|
|
|
|
|
* 605 E. Springfield, Champaign IL 61820 *
|
|
|
|
|
* *
|
|
|
|
|
* For conditions of distribution and use, see the accompanying *
|
|
|
|
|
* hdf/COPYING file. *
|
|
|
|
|
* *
|
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
|
|
/* $Id$ */
|
|
|
|
|
|
2000-10-10 15:43:38 +08:00
|
|
|
|
#define H5F_PACKAGE /*suppress error about including H5Fpkg */
|
|
|
|
|
|
2001-04-06 01:29:14 +08:00
|
|
|
|
#include "H5private.h" /* Generic Functions */
|
|
|
|
|
#include "H5Iprivate.h" /* ID Functions */
|
|
|
|
|
#include "H5Dprivate.h" /* Datasets */
|
|
|
|
|
#include "H5Eprivate.h" /* Error handling */
|
|
|
|
|
#include "H5Fpkg.h" /* Files */
|
|
|
|
|
#include "H5Gprivate.h" /* Groups */
|
|
|
|
|
#include "H5HGprivate.h" /* Global Heaps */
|
|
|
|
|
#include "H5MMprivate.h" /* Memory Management */
|
|
|
|
|
#include "H5Rprivate.h" /* References */
|
|
|
|
|
#include "H5Sprivate.h" /* Dataspaces */
|
|
|
|
|
#include "H5Tprivate.h" /* Datatypes */
|
1998-10-08 05:04:51 +08:00
|
|
|
|
|
|
|
|
|
/* Interface initialization */
|
|
|
|
|
#define PABLO_MASK H5R_mask
|
|
|
|
|
#define INTERFACE_INIT H5R_init_interface
|
2001-08-15 06:09:56 +08:00
|
|
|
|
static int interface_initialize_g = 0;
|
1998-10-08 05:04:51 +08:00
|
|
|
|
static herr_t H5R_init_interface(void);
|
|
|
|
|
|
1998-10-14 05:28:53 +08:00
|
|
|
|
/* Static functions */
|
1998-10-23 06:49:16 +08:00
|
|
|
|
static herr_t H5R_create(void *ref, H5G_entry_t *loc, const char *name,
|
1998-10-14 05:28:53 +08:00
|
|
|
|
H5R_type_t ref_type, H5S_t *space);
|
1999-06-26 03:36:54 +08:00
|
|
|
|
static hid_t H5R_dereference(H5F_t *file, H5R_type_t ref_type, void *_ref);
|
|
|
|
|
static H5S_t * H5R_get_region(H5F_t *file, H5R_type_t ref_type, void *_ref);
|
2001-08-15 06:09:56 +08:00
|
|
|
|
static int H5R_get_object_type(H5F_t *file, void *_ref);
|
1998-10-14 05:28:53 +08:00
|
|
|
|
|
1998-10-08 05:04:51 +08:00
|
|
|
|
|
|
|
|
|
/*--------------------------------------------------------------------------
|
|
|
|
|
NAME
|
|
|
|
|
H5R_init_interface -- Initialize interface-specific information
|
|
|
|
|
USAGE
|
|
|
|
|
herr_t H5R_init_interface()
|
|
|
|
|
|
|
|
|
|
RETURNS
|
1998-10-27 05:18:54 +08:00
|
|
|
|
Non-negative on success/Negative on failure
|
1998-10-08 05:04:51 +08:00
|
|
|
|
DESCRIPTION
|
|
|
|
|
Initializes any interface-specific data or routines.
|
|
|
|
|
|
|
|
|
|
--------------------------------------------------------------------------*/
|
|
|
|
|
static herr_t
|
|
|
|
|
H5R_init_interface(void)
|
|
|
|
|
{
|
|
|
|
|
FUNC_ENTER(H5R_init_interface, FAIL);
|
|
|
|
|
|
|
|
|
|
/* Initialize the atom group for the file IDs */
|
1998-11-21 11:36:51 +08:00
|
|
|
|
if (H5I_init_group(H5I_REFERENCE, H5I_REFID_HASHSIZE, H5R_RESERVED_ATOMS,
|
1999-02-21 00:18:51 +08:00
|
|
|
|
(H5I_free_t)NULL)<0) {
|
1998-11-21 11:36:51 +08:00
|
|
|
|
HRETURN_ERROR (H5E_REFERENCE, H5E_CANTINIT, FAIL,
|
|
|
|
|
"unable to initialize interface");
|
1998-10-08 05:04:51 +08:00
|
|
|
|
}
|
|
|
|
|
|
1998-11-21 11:36:51 +08:00
|
|
|
|
FUNC_LEAVE(SUCCEED);
|
|
|
|
|
}
|
1998-10-08 05:04:51 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*--------------------------------------------------------------------------
|
|
|
|
|
NAME
|
|
|
|
|
H5R_term_interface
|
|
|
|
|
PURPOSE
|
|
|
|
|
Terminate various H5R objects
|
|
|
|
|
USAGE
|
|
|
|
|
void H5R_term_interface()
|
|
|
|
|
RETURNS
|
1998-10-14 05:28:53 +08:00
|
|
|
|
void
|
1998-10-08 05:04:51 +08:00
|
|
|
|
DESCRIPTION
|
|
|
|
|
Release the atom group and any other resources allocated.
|
|
|
|
|
GLOBAL VARIABLES
|
|
|
|
|
COMMENTS, BUGS, ASSUMPTIONS
|
|
|
|
|
Can't report errors...
|
|
|
|
|
EXAMPLES
|
|
|
|
|
REVISION LOG
|
|
|
|
|
--------------------------------------------------------------------------*/
|
2001-08-15 06:09:56 +08:00
|
|
|
|
int
|
1999-03-30 19:38:34 +08:00
|
|
|
|
H5R_term_interface(void)
|
1998-10-08 05:04:51 +08:00
|
|
|
|
{
|
2001-08-15 06:09:56 +08:00
|
|
|
|
int n=0;
|
1999-03-30 19:38:34 +08:00
|
|
|
|
|
|
|
|
|
if (interface_initialize_g) {
|
|
|
|
|
if ((n=H5I_nmembers(H5I_REFERENCE))) {
|
1999-04-27 22:47:54 +08:00
|
|
|
|
H5I_clear_group(H5I_REFERENCE, FALSE);
|
1999-03-30 19:38:34 +08:00
|
|
|
|
} else {
|
|
|
|
|
H5I_destroy_group(H5I_REFERENCE);
|
|
|
|
|
interface_initialize_g = 0;
|
|
|
|
|
n = 1; /*H5I*/
|
|
|
|
|
}
|
1998-11-21 11:36:51 +08:00
|
|
|
|
}
|
|
|
|
|
|
1999-03-30 19:38:34 +08:00
|
|
|
|
return n;
|
1998-11-21 11:36:51 +08:00
|
|
|
|
}
|
1998-10-08 05:04:51 +08:00
|
|
|
|
|
1998-10-14 05:28:53 +08:00
|
|
|
|
|
|
|
|
|
/*--------------------------------------------------------------------------
|
|
|
|
|
NAME
|
|
|
|
|
H5R_create
|
|
|
|
|
PURPOSE
|
|
|
|
|
Creates a particular kind of reference for the user
|
|
|
|
|
USAGE
|
|
|
|
|
herr_t H5R_create(ref, loc, name, ref_type, space)
|
1998-10-23 06:49:16 +08:00
|
|
|
|
void *ref; OUT: Reference created
|
1998-10-14 05:28:53 +08:00
|
|
|
|
H5G_entry_t *loc; IN: File location used to locate object pointed to
|
|
|
|
|
const char *name; IN: Name of object at location LOC_ID of object
|
|
|
|
|
pointed to
|
|
|
|
|
H5R_type_t ref_type; IN: Type of reference to create
|
|
|
|
|
H5S_t *space; IN: Dataspace ID with selection, used for Dataset
|
|
|
|
|
Region references.
|
|
|
|
|
|
|
|
|
|
RETURNS
|
1998-10-27 05:18:54 +08:00
|
|
|
|
Non-negative on success/Negative on failure
|
1998-10-14 05:28:53 +08:00
|
|
|
|
DESCRIPTION
|
|
|
|
|
Creates a particular type of reference specified with REF_TYPE, in the
|
|
|
|
|
space pointed to by REF. The LOC_ID and NAME are used to locate the object
|
|
|
|
|
pointed to and the SPACE_ID is used to choose the region pointed to (for
|
|
|
|
|
Dataset Region references).
|
|
|
|
|
GLOBAL VARIABLES
|
|
|
|
|
COMMENTS, BUGS, ASSUMPTIONS
|
|
|
|
|
EXAMPLES
|
|
|
|
|
REVISION LOG
|
|
|
|
|
--------------------------------------------------------------------------*/
|
|
|
|
|
static herr_t
|
1998-11-13 08:28:29 +08:00
|
|
|
|
H5R_create(void *_ref, H5G_entry_t *loc, const char *name, H5R_type_t ref_type, H5S_t *space)
|
1998-10-14 05:28:53 +08:00
|
|
|
|
{
|
|
|
|
|
H5G_stat_t sb; /* Stat buffer for retrieving OID */
|
|
|
|
|
herr_t ret_value = FAIL;
|
|
|
|
|
|
|
|
|
|
FUNC_ENTER(H5R_create, FAIL);
|
|
|
|
|
|
1998-10-23 06:49:16 +08:00
|
|
|
|
assert(_ref);
|
1998-10-14 05:28:53 +08:00
|
|
|
|
assert(loc);
|
|
|
|
|
assert(name);
|
|
|
|
|
assert(ref_type>H5R_BADTYPE || ref_type<H5R_MAXTYPE);
|
|
|
|
|
|
|
|
|
|
if (H5G_get_objinfo (loc, name, 0, &sb)<0)
|
|
|
|
|
HGOTO_ERROR (H5E_REFERENCE, H5E_NOTFOUND, FAIL, "unable to stat object");
|
|
|
|
|
|
1998-10-23 06:49:16 +08:00
|
|
|
|
switch(ref_type) {
|
|
|
|
|
case H5R_OBJECT:
|
|
|
|
|
{
|
1998-10-29 02:51:20 +08:00
|
|
|
|
haddr_t addr;
|
1998-10-23 06:49:16 +08:00
|
|
|
|
hobj_ref_t *ref=(hobj_ref_t *)_ref; /* Get pointer to correct type of reference struct */
|
1998-11-19 02:40:09 +08:00
|
|
|
|
uint8_t *p; /* Pointer to OID to store */
|
1998-10-23 06:49:16 +08:00
|
|
|
|
|
|
|
|
|
/* Set information for reference */
|
1998-11-19 02:40:09 +08:00
|
|
|
|
p=(uint8_t *)ref->oid;
|
1998-10-29 02:51:20 +08:00
|
|
|
|
H5F_addr_pack(loc->file,&addr,&sb.objno[0]);
|
1999-07-29 02:25:43 +08:00
|
|
|
|
H5F_addr_encode(loc->file,&p,addr);
|
1998-10-23 06:49:16 +08:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
case H5R_DATASET_REGION:
|
1998-11-13 08:28:29 +08:00
|
|
|
|
{
|
|
|
|
|
haddr_t addr;
|
1998-11-25 08:29:09 +08:00
|
|
|
|
H5HG_t hobjid; /* Heap object ID */
|
1998-11-13 08:28:29 +08:00
|
|
|
|
hdset_reg_ref_t *ref=(hdset_reg_ref_t *)_ref; /* Get pointer to correct type of reference struct */
|
|
|
|
|
hssize_t buf_size; /* Size of buffer needed to serialize selection */
|
1998-11-19 02:40:09 +08:00
|
|
|
|
uint8_t *p; /* Pointer to OID to store */
|
|
|
|
|
uint8_t *buf; /* Buffer to store serialized selection in */
|
2001-08-15 06:09:56 +08:00
|
|
|
|
unsigned heapid_found; /* Flag for non-zero heap ID found */
|
|
|
|
|
unsigned u; /* local index */
|
1998-11-13 08:28:29 +08:00
|
|
|
|
|
|
|
|
|
/* Set up information for dataset region */
|
1998-11-25 08:29:09 +08:00
|
|
|
|
|
|
|
|
|
/* Return any previous heap block to the free list if we are garbage collecting */
|
1999-08-18 03:12:59 +08:00
|
|
|
|
if(loc->file->shared->gc_ref) {
|
1998-11-25 08:29:09 +08:00
|
|
|
|
/* Check for an existing heap ID in the reference */
|
|
|
|
|
for(u=0, heapid_found=0; u<H5R_DSET_REG_REF_BUF_SIZE; u++)
|
|
|
|
|
if(ref->heapid[u]!=0) {
|
|
|
|
|
heapid_found=1;
|
|
|
|
|
break;
|
|
|
|
|
} /* end if */
|
|
|
|
|
|
|
|
|
|
if(heapid_found!=0) {
|
|
|
|
|
/* Return heap block to free list */
|
|
|
|
|
} /* end if */
|
|
|
|
|
} /* end if */
|
|
|
|
|
|
|
|
|
|
/* Zero the heap ID out, may leak heap space if user is re-using reference and doesn't have garbage collection on */
|
|
|
|
|
HDmemset(ref->heapid,H5R_DSET_REG_REF_BUF_SIZE,0);
|
1998-11-13 08:28:29 +08:00
|
|
|
|
|
|
|
|
|
/* Get the amount of space required to serialize the selection */
|
|
|
|
|
if ((buf_size = H5S_select_serial_size(space)) < 0)
|
|
|
|
|
HGOTO_ERROR(H5E_REFERENCE, H5E_CANTINIT, FAIL,
|
|
|
|
|
"Invalid amount of space for serializing selection");
|
|
|
|
|
|
1998-11-25 08:29:09 +08:00
|
|
|
|
/* Increase buffer size to allow for the dataset OID */
|
|
|
|
|
buf_size+=sizeof(haddr_t);
|
|
|
|
|
|
1998-11-13 08:28:29 +08:00
|
|
|
|
/* Allocate the space to store the serialized information */
|
2001-11-28 00:29:13 +08:00
|
|
|
|
H5_CHECK_OVERFLOW(buf_size,hssize_t,size_t);
|
|
|
|
|
if (NULL==(buf = H5MM_malloc((size_t)buf_size)))
|
|
|
|
|
HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed");
|
1998-11-13 08:28:29 +08:00
|
|
|
|
|
1998-11-25 08:29:09 +08:00
|
|
|
|
/* Serialize information for dataset OID */
|
|
|
|
|
p=(uint8_t *)buf;
|
|
|
|
|
H5F_addr_pack(loc->file,&addr,&sb.objno[0]);
|
1999-07-29 02:25:43 +08:00
|
|
|
|
H5F_addr_encode(loc->file,&p,addr);
|
1998-11-25 08:29:09 +08:00
|
|
|
|
|
1998-11-13 08:28:29 +08:00
|
|
|
|
/* Serialize the selection */
|
1998-11-25 08:29:09 +08:00
|
|
|
|
if (H5S_select_serialize(space,p) < 0)
|
2001-11-28 00:29:13 +08:00
|
|
|
|
HGOTO_ERROR(H5E_REFERENCE, H5E_CANTCOPY, FAIL, "Unable to serialize selection");
|
1998-11-25 08:29:09 +08:00
|
|
|
|
|
|
|
|
|
/* Save the serialized buffer for later */
|
2001-11-28 00:29:13 +08:00
|
|
|
|
H5_CHECK_OVERFLOW(buf_size,hssize_t,size_t);
|
2001-01-10 05:22:30 +08:00
|
|
|
|
if(H5HG_insert(loc->file,(size_t)buf_size,buf,&hobjid)<0)
|
2001-11-28 00:29:13 +08:00
|
|
|
|
HGOTO_ERROR(H5E_REFERENCE, H5E_WRITEERROR, FAIL, "Unable to serialize selection");
|
1998-11-25 08:29:09 +08:00
|
|
|
|
|
|
|
|
|
/* Serialize the heap ID and index for storage in the file */
|
|
|
|
|
p=(uint8_t *)ref->heapid;
|
1999-07-29 02:25:43 +08:00
|
|
|
|
H5F_addr_encode(loc->file,&p,hobjid.addr);
|
1998-11-25 08:29:09 +08:00
|
|
|
|
INT32ENCODE(p,hobjid.idx);
|
|
|
|
|
|
|
|
|
|
/* Free the buffer we serialized data in */
|
|
|
|
|
H5MM_xfree(buf);
|
1998-11-13 08:28:29 +08:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
1998-10-23 06:49:16 +08:00
|
|
|
|
case H5R_INTERNAL:
|
|
|
|
|
HRETURN_ERROR(H5E_REFERENCE, H5E_UNSUPPORTED, FAIL,
|
1998-11-25 08:29:09 +08:00
|
|
|
|
"Internal references are not yet supported");
|
1998-10-23 06:49:16 +08:00
|
|
|
|
|
|
|
|
|
case H5R_BADTYPE:
|
|
|
|
|
case H5R_MAXTYPE:
|
1998-11-25 08:29:09 +08:00
|
|
|
|
default:
|
1998-10-23 06:49:16 +08:00
|
|
|
|
assert("unknown reference type" && 0);
|
|
|
|
|
HRETURN_ERROR(H5E_REFERENCE, H5E_UNSUPPORTED, FAIL,
|
|
|
|
|
"internal error (unknown reference type)");
|
|
|
|
|
} /* end switch */
|
1998-10-14 05:28:53 +08:00
|
|
|
|
|
|
|
|
|
/* Return success */
|
|
|
|
|
ret_value=SUCCEED;
|
|
|
|
|
|
|
|
|
|
done:
|
|
|
|
|
FUNC_LEAVE(ret_value);
|
|
|
|
|
} /* end H5R_create() */
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*--------------------------------------------------------------------------
|
|
|
|
|
NAME
|
|
|
|
|
H5Rcreate
|
|
|
|
|
PURPOSE
|
|
|
|
|
Creates a particular kind of reference for the user
|
|
|
|
|
USAGE
|
|
|
|
|
herr_t H5Rcreate(ref, loc_id, name, ref_type, space_id)
|
1998-10-23 06:49:16 +08:00
|
|
|
|
void *ref; OUT: Reference created
|
1998-10-14 05:28:53 +08:00
|
|
|
|
hid_t loc_id; IN: Location ID used to locate object pointed to
|
|
|
|
|
const char *name; IN: Name of object at location LOC_ID of object
|
|
|
|
|
pointed to
|
|
|
|
|
H5R_type_t ref_type; IN: Type of reference to create
|
|
|
|
|
hid_t space_id; IN: Dataspace ID with selection, used for Dataset
|
|
|
|
|
Region references.
|
|
|
|
|
|
|
|
|
|
RETURNS
|
1998-10-27 05:18:54 +08:00
|
|
|
|
Non-negative on success/Negative on failure
|
1998-10-14 05:28:53 +08:00
|
|
|
|
DESCRIPTION
|
|
|
|
|
Creates a particular type of reference specified with REF_TYPE, in the
|
|
|
|
|
space pointed to by REF. The LOC_ID and NAME are used to locate the object
|
|
|
|
|
pointed to and the SPACE_ID is used to choose the region pointed to (for
|
|
|
|
|
Dataset Region references).
|
|
|
|
|
GLOBAL VARIABLES
|
|
|
|
|
COMMENTS, BUGS, ASSUMPTIONS
|
|
|
|
|
EXAMPLES
|
|
|
|
|
REVISION LOG
|
|
|
|
|
--------------------------------------------------------------------------*/
|
|
|
|
|
herr_t
|
1998-10-23 06:49:16 +08:00
|
|
|
|
H5Rcreate(void *ref, hid_t loc_id, const char *name, H5R_type_t ref_type, hid_t space_id)
|
1998-10-14 05:28:53 +08:00
|
|
|
|
{
|
|
|
|
|
H5G_entry_t *loc = NULL; /* File location */
|
|
|
|
|
H5S_t *space = NULL; /* Pointer to dataspace containing region */
|
|
|
|
|
herr_t ret_value = FAIL;
|
|
|
|
|
|
|
|
|
|
FUNC_ENTER(H5Rcreate, FAIL);
|
1998-10-26 22:49:52 +08:00
|
|
|
|
H5TRACE5("e","xisRti",ref,loc_id,name,ref_type,space_id);
|
1998-10-14 05:28:53 +08:00
|
|
|
|
|
|
|
|
|
/* Check args */
|
|
|
|
|
if(ref==NULL)
|
|
|
|
|
HRETURN_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "invalid reference pointer");
|
|
|
|
|
if (NULL==(loc=H5G_loc (loc_id)))
|
|
|
|
|
HRETURN_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "not a location");
|
|
|
|
|
if (!name || !*name)
|
|
|
|
|
HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name given");
|
|
|
|
|
if(ref_type<=H5R_BADTYPE || ref_type>=H5R_MAXTYPE)
|
|
|
|
|
HRETURN_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "invalid reference type");
|
1998-11-13 08:28:29 +08:00
|
|
|
|
if(ref_type!=H5R_OBJECT && ref_type!=H5R_DATASET_REGION)
|
1998-10-14 05:28:53 +08:00
|
|
|
|
HRETURN_ERROR (H5E_ARGS, H5E_UNSUPPORTED, FAIL, "reference type not supported");
|
|
|
|
|
if (space_id!=(-1) && (H5I_DATASPACE!=H5I_get_type (space_id) || NULL==(space=H5I_object (space_id))))
|
|
|
|
|
HRETURN_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataspace");
|
|
|
|
|
|
|
|
|
|
/* Create reference */
|
|
|
|
|
if ((ret_value=H5R_create(ref,loc,name,ref_type,space))<0)
|
|
|
|
|
HGOTO_ERROR (H5E_REFERENCE, H5E_CANTINIT, FAIL, "unable to create reference");
|
|
|
|
|
|
|
|
|
|
done:
|
|
|
|
|
FUNC_LEAVE(ret_value);
|
|
|
|
|
} /* end H5Rcreate() */
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*--------------------------------------------------------------------------
|
|
|
|
|
NAME
|
|
|
|
|
H5R_dereference
|
|
|
|
|
PURPOSE
|
|
|
|
|
Opens the HDF5 object referenced.
|
|
|
|
|
USAGE
|
|
|
|
|
hid_t H5R_dereference(ref)
|
1999-06-26 03:36:54 +08:00
|
|
|
|
H5F_t *file; IN: File the object being dereferenced is within
|
1998-10-23 06:49:16 +08:00
|
|
|
|
H5R_type_t ref_type; IN: Type of reference
|
|
|
|
|
void *ref; IN: Reference to open.
|
1998-10-14 05:28:53 +08:00
|
|
|
|
|
|
|
|
|
RETURNS
|
1998-10-27 05:18:54 +08:00
|
|
|
|
Valid ID on success, Negative on failure
|
1998-10-14 05:28:53 +08:00
|
|
|
|
DESCRIPTION
|
|
|
|
|
Given a reference to some object, open that object and return an ID for
|
|
|
|
|
that object.
|
|
|
|
|
GLOBAL VARIABLES
|
|
|
|
|
COMMENTS, BUGS, ASSUMPTIONS
|
|
|
|
|
Currently only set up to work with references to datasets
|
|
|
|
|
EXAMPLES
|
|
|
|
|
REVISION LOG
|
|
|
|
|
--------------------------------------------------------------------------*/
|
|
|
|
|
static hid_t
|
1999-06-26 03:36:54 +08:00
|
|
|
|
H5R_dereference(H5F_t *file, H5R_type_t ref_type, void *_ref)
|
1998-10-14 05:28:53 +08:00
|
|
|
|
{
|
|
|
|
|
H5D_t *dataset; /* Pointer to dataset to open */
|
1999-03-18 08:07:50 +08:00
|
|
|
|
H5G_t *group; /* Pointer to group to open */
|
1999-03-18 09:30:03 +08:00
|
|
|
|
H5T_t *datatype; /* Pointer to datatype to open */
|
1998-10-14 05:28:53 +08:00
|
|
|
|
H5G_entry_t ent; /* Symbol table entry */
|
1998-11-19 02:40:09 +08:00
|
|
|
|
uint8_t *p; /* Pointer to OID to store */
|
2001-08-15 06:09:56 +08:00
|
|
|
|
int oid_type; /* type of object being dereferenced */
|
1998-10-14 05:28:53 +08:00
|
|
|
|
hid_t ret_value = FAIL;
|
|
|
|
|
|
|
|
|
|
FUNC_ENTER(H5R_dereference, FAIL);
|
|
|
|
|
|
1998-11-25 08:29:09 +08:00
|
|
|
|
assert(_ref);
|
|
|
|
|
assert(ref_type>H5R_BADTYPE || ref_type<H5R_MAXTYPE);
|
1999-06-26 03:36:54 +08:00
|
|
|
|
assert(file);
|
1998-10-14 05:28:53 +08:00
|
|
|
|
|
|
|
|
|
/* Initialize the symbol table entry */
|
|
|
|
|
HDmemset(&ent,0,sizeof(H5G_entry_t));
|
|
|
|
|
ent.type=H5G_NOTHING_CACHED;
|
1999-06-26 03:36:54 +08:00
|
|
|
|
ent.file=file;
|
1998-11-25 08:29:09 +08:00
|
|
|
|
|
|
|
|
|
switch(ref_type) {
|
|
|
|
|
case H5R_OBJECT:
|
|
|
|
|
{
|
|
|
|
|
hobj_ref_t *ref=(hobj_ref_t *)_ref; /* Only object references currently supported */
|
|
|
|
|
/*
|
|
|
|
|
* Switch on object type, when we implement that feature, always try to
|
|
|
|
|
* open a dataset for now
|
|
|
|
|
*/
|
|
|
|
|
/* Get the object oid */
|
|
|
|
|
p=(uint8_t *)ref->oid;
|
|
|
|
|
H5F_addr_decode(ent.file,(const uint8_t **)&p,&(ent.header));
|
|
|
|
|
break;
|
|
|
|
|
} /* end case */
|
|
|
|
|
|
|
|
|
|
case H5R_DATASET_REGION:
|
|
|
|
|
{
|
|
|
|
|
hdset_reg_ref_t *ref=(hdset_reg_ref_t *)_ref; /* Get pointer to correct type of reference struct */
|
|
|
|
|
H5HG_t hobjid; /* Heap object ID */
|
|
|
|
|
uint8_t *buf; /* Buffer to store serialized selection in */
|
|
|
|
|
|
|
|
|
|
/* Get the heap ID for the dataset region */
|
|
|
|
|
p=(uint8_t *)ref->heapid;
|
|
|
|
|
H5F_addr_decode(ent.file,(const uint8_t **)&p,&(hobjid.addr));
|
|
|
|
|
INT32DECODE(p,hobjid.idx);
|
|
|
|
|
|
|
|
|
|
/* Get the dataset region from the heap (allocate inside routine) */
|
|
|
|
|
if((buf=H5HG_read(ent.file,&hobjid,NULL))==NULL)
|
|
|
|
|
HGOTO_ERROR(H5E_REFERENCE, H5E_READERROR, FAIL,
|
|
|
|
|
"Unable to read dataset region information");
|
|
|
|
|
|
|
|
|
|
/* Get the object oid for the dataset */
|
|
|
|
|
p=(uint8_t *)buf;
|
|
|
|
|
H5F_addr_decode(ent.file,(const uint8_t **)&p,&(ent.header));
|
|
|
|
|
|
|
|
|
|
/* Free the buffer allocated in H5HG_read() */
|
|
|
|
|
H5MM_xfree(buf);
|
|
|
|
|
break;
|
|
|
|
|
} /* end case */
|
|
|
|
|
|
|
|
|
|
case H5R_INTERNAL:
|
|
|
|
|
HRETURN_ERROR(H5E_REFERENCE, H5E_UNSUPPORTED, FAIL,
|
|
|
|
|
"Internal references are not yet supported");
|
|
|
|
|
|
|
|
|
|
case H5R_BADTYPE:
|
|
|
|
|
case H5R_MAXTYPE:
|
|
|
|
|
default:
|
|
|
|
|
assert("unknown reference type" && 0);
|
|
|
|
|
HRETURN_ERROR(H5E_REFERENCE, H5E_UNSUPPORTED, FAIL,
|
|
|
|
|
"internal error (unknown reference type)");
|
|
|
|
|
} /* end switch */
|
1998-10-14 05:28:53 +08:00
|
|
|
|
|
2000-10-18 04:46:57 +08:00
|
|
|
|
/* Check to make certain that this object hasn't been deleted since the reference was created */
|
|
|
|
|
if(H5O_link(&ent,0)<=0)
|
|
|
|
|
HRETURN_ERROR(H5E_REFERENCE, H5E_LINKCOUNT, FAIL, "dereferencing deleted object");
|
|
|
|
|
|
1998-10-14 05:28:53 +08:00
|
|
|
|
/* Open the dataset object */
|
1999-03-12 05:03:30 +08:00
|
|
|
|
oid_type=H5G_get_type(&ent);
|
|
|
|
|
switch(oid_type) {
|
|
|
|
|
case H5G_GROUP:
|
1999-03-18 08:07:50 +08:00
|
|
|
|
if ((group=H5G_open_oid(&ent)) == NULL) {
|
|
|
|
|
HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "not found");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Create an atom for the dataset */
|
|
|
|
|
if ((ret_value = H5I_register(H5I_GROUP, group)) < 0) {
|
|
|
|
|
H5G_close(group);
|
|
|
|
|
HGOTO_ERROR(H5E_SYM, H5E_CANTREGISTER, FAIL,
|
|
|
|
|
"can't register group");
|
|
|
|
|
}
|
1999-03-12 05:03:30 +08:00
|
|
|
|
break;
|
1998-10-14 05:28:53 +08:00
|
|
|
|
|
1999-03-12 05:03:30 +08:00
|
|
|
|
case H5G_TYPE:
|
1999-03-18 09:30:03 +08:00
|
|
|
|
if ((datatype=H5T_open_oid(&ent)) == NULL) {
|
|
|
|
|
HGOTO_ERROR(H5E_DATATYPE, H5E_NOTFOUND, FAIL, "not found");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Create an atom for the dataset */
|
|
|
|
|
if ((ret_value = H5I_register(H5I_DATATYPE, datatype)) < 0) {
|
|
|
|
|
H5T_close(datatype);
|
|
|
|
|
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, FAIL,
|
|
|
|
|
"can't register group");
|
|
|
|
|
}
|
1999-03-12 05:03:30 +08:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case H5G_DATASET:
|
|
|
|
|
if ((dataset=H5D_open_oid(&ent)) == NULL) {
|
|
|
|
|
HGOTO_ERROR(H5E_DATASET, H5E_NOTFOUND, FAIL, "not found");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Create an atom for the dataset */
|
|
|
|
|
if ((ret_value = H5I_register(H5I_DATASET, dataset)) < 0) {
|
|
|
|
|
H5D_close(dataset);
|
|
|
|
|
HGOTO_ERROR(H5E_DATASET, H5E_CANTREGISTER, FAIL,
|
|
|
|
|
"can't register dataset");
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
HGOTO_ERROR(H5E_REFERENCE, H5E_BADTYPE, FAIL,
|
|
|
|
|
"can't identify type of object referenced");
|
|
|
|
|
} /* end switch */
|
1998-10-14 05:28:53 +08:00
|
|
|
|
|
|
|
|
|
done:
|
|
|
|
|
FUNC_LEAVE(ret_value);
|
|
|
|
|
} /* end H5R_dereference() */
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*--------------------------------------------------------------------------
|
|
|
|
|
NAME
|
|
|
|
|
H5Rdereference
|
|
|
|
|
PURPOSE
|
|
|
|
|
Opens the HDF5 object referenced.
|
|
|
|
|
USAGE
|
|
|
|
|
hid_t H5Rdereference(ref)
|
1999-06-26 03:36:54 +08:00
|
|
|
|
hid_t id; IN: Dataset reference object is in or location ID of
|
|
|
|
|
object that the dataset is located within.
|
1998-10-23 06:49:16 +08:00
|
|
|
|
H5R_type_t ref_type; IN: Type of reference to create
|
1999-06-26 03:36:54 +08:00
|
|
|
|
void *ref; IN: Reference to open.
|
1998-10-14 05:28:53 +08:00
|
|
|
|
|
|
|
|
|
RETURNS
|
1998-10-27 05:18:54 +08:00
|
|
|
|
Valid ID on success, Negative on failure
|
1998-10-14 05:28:53 +08:00
|
|
|
|
DESCRIPTION
|
|
|
|
|
Given a reference to some object, open that object and return an ID for
|
|
|
|
|
that object.
|
|
|
|
|
GLOBAL VARIABLES
|
|
|
|
|
COMMENTS, BUGS, ASSUMPTIONS
|
|
|
|
|
EXAMPLES
|
|
|
|
|
REVISION LOG
|
|
|
|
|
--------------------------------------------------------------------------*/
|
|
|
|
|
hid_t
|
1999-06-26 03:36:54 +08:00
|
|
|
|
H5Rdereference(hid_t id, H5R_type_t ref_type, void *_ref)
|
1998-10-14 05:28:53 +08:00
|
|
|
|
{
|
1999-06-26 03:36:54 +08:00
|
|
|
|
H5G_entry_t *loc = NULL; /* Symbol table entry */
|
|
|
|
|
H5F_t *file=NULL; /* File object */
|
1998-10-14 05:28:53 +08:00
|
|
|
|
hid_t ret_value = FAIL;
|
|
|
|
|
|
|
|
|
|
FUNC_ENTER(H5Rdereference, FAIL);
|
1999-06-26 03:36:54 +08:00
|
|
|
|
H5TRACE3("i","iRtx",id,ref_type,_ref);
|
1998-10-14 05:28:53 +08:00
|
|
|
|
|
|
|
|
|
/* Check args */
|
2000-12-02 23:11:57 +08:00
|
|
|
|
if (NULL == (loc = H5G_loc(id)))
|
|
|
|
|
HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location");
|
1998-10-23 06:49:16 +08:00
|
|
|
|
if(ref_type<=H5R_BADTYPE || ref_type>=H5R_MAXTYPE)
|
|
|
|
|
HRETURN_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "invalid reference type");
|
|
|
|
|
if(_ref==NULL)
|
1998-10-14 05:28:53 +08:00
|
|
|
|
HRETURN_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "invalid reference pointer");
|
|
|
|
|
|
2000-12-02 23:11:57 +08:00
|
|
|
|
/* Get the file pointer from the entry */
|
|
|
|
|
file=loc->file;
|
|
|
|
|
|
1998-10-14 05:28:53 +08:00
|
|
|
|
/* Create reference */
|
1999-06-26 03:36:54 +08:00
|
|
|
|
if ((ret_value=H5R_dereference(file, ref_type, _ref))<0)
|
1998-10-14 05:28:53 +08:00
|
|
|
|
HGOTO_ERROR (H5E_REFERENCE, H5E_CANTINIT, FAIL, "unable dereference object");
|
|
|
|
|
|
|
|
|
|
done:
|
|
|
|
|
FUNC_LEAVE(ret_value);
|
|
|
|
|
} /* end H5Rdereference() */
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*--------------------------------------------------------------------------
|
|
|
|
|
NAME
|
1998-10-27 01:14:00 +08:00
|
|
|
|
H5R_get_region
|
1998-10-14 05:28:53 +08:00
|
|
|
|
PURPOSE
|
|
|
|
|
Retrieves a dataspace with the region pointed to selected.
|
|
|
|
|
USAGE
|
1999-06-26 03:36:54 +08:00
|
|
|
|
H5S_t *H5R_get_region(file, ref_type, ref)
|
|
|
|
|
H5F_t *file; IN: File the object being dereferenced is within
|
|
|
|
|
H5R_type_t ref_type; UNUSED
|
|
|
|
|
void *ref; IN: Reference to open.
|
1998-10-14 05:28:53 +08:00
|
|
|
|
|
|
|
|
|
RETURNS
|
|
|
|
|
Pointer to the dataspace on success, NULL on failure
|
|
|
|
|
DESCRIPTION
|
|
|
|
|
Given a reference to some object, creates a copy of the dataset pointed
|
|
|
|
|
to's dataspace and defines a selection in the copy which is the region
|
|
|
|
|
pointed to.
|
|
|
|
|
GLOBAL VARIABLES
|
|
|
|
|
COMMENTS, BUGS, ASSUMPTIONS
|
|
|
|
|
EXAMPLES
|
|
|
|
|
REVISION LOG
|
|
|
|
|
--------------------------------------------------------------------------*/
|
|
|
|
|
static H5S_t *
|
1999-06-26 03:36:54 +08:00
|
|
|
|
H5R_get_region(H5F_t *file, H5R_type_t UNUSED ref_type, void *_ref)
|
1998-10-14 05:28:53 +08:00
|
|
|
|
{
|
1998-11-25 08:29:09 +08:00
|
|
|
|
H5D_t *dataset; /* Pointer to dataset to open */
|
|
|
|
|
H5G_entry_t ent; /* Symbol table entry */
|
|
|
|
|
uint8_t *p; /* Pointer to OID to store */
|
|
|
|
|
hdset_reg_ref_t *ref=(hdset_reg_ref_t *)_ref; /* Get pointer to correct type of reference struct */
|
|
|
|
|
H5HG_t hobjid; /* Heap object ID */
|
|
|
|
|
uint8_t *buf; /* Buffer to store serialized selection in */
|
1998-10-14 05:28:53 +08:00
|
|
|
|
H5S_t *ret_value = NULL;
|
|
|
|
|
|
1998-10-27 01:14:00 +08:00
|
|
|
|
FUNC_ENTER(H5R_get_region, NULL);
|
1998-10-14 05:28:53 +08:00
|
|
|
|
|
1998-11-25 08:29:09 +08:00
|
|
|
|
assert(_ref);
|
|
|
|
|
assert(ref_type==H5R_DATASET_REGION);
|
1999-06-26 03:36:54 +08:00
|
|
|
|
assert(file);
|
1998-11-25 08:29:09 +08:00
|
|
|
|
|
|
|
|
|
/* Initialize the symbol table entry */
|
|
|
|
|
HDmemset(&ent,0,sizeof(H5G_entry_t));
|
|
|
|
|
ent.type=H5G_NOTHING_CACHED;
|
1999-06-26 03:36:54 +08:00
|
|
|
|
ent.file=file;
|
1998-11-25 08:29:09 +08:00
|
|
|
|
|
|
|
|
|
/* Get the heap ID for the dataset region */
|
|
|
|
|
p=(uint8_t *)ref->heapid;
|
|
|
|
|
H5F_addr_decode(ent.file,(const uint8_t **)&p,&(hobjid.addr));
|
|
|
|
|
INT32DECODE(p,hobjid.idx);
|
|
|
|
|
|
|
|
|
|
/* Get the dataset region from the heap (allocate inside routine) */
|
|
|
|
|
if((buf=H5HG_read(ent.file,&hobjid,NULL))==NULL)
|
|
|
|
|
HGOTO_ERROR(H5E_REFERENCE, H5E_READERROR, NULL,
|
|
|
|
|
"Unable to read dataset region information");
|
|
|
|
|
|
|
|
|
|
/* Get the object oid for the dataset */
|
|
|
|
|
p=(uint8_t *)buf;
|
|
|
|
|
H5F_addr_decode(ent.file,(const uint8_t **)&p,&(ent.header));
|
|
|
|
|
|
|
|
|
|
/* Open the dataset object */
|
|
|
|
|
if ((dataset=H5D_open_oid(&ent)) == NULL) {
|
|
|
|
|
HGOTO_ERROR(H5E_DATASET, H5E_NOTFOUND, NULL, "not found");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Copy the dataspace object */
|
|
|
|
|
if ((ret_value=H5D_get_space(dataset)) == NULL) {
|
|
|
|
|
HGOTO_ERROR(H5E_DATASPACE, H5E_NOTFOUND, NULL, "not found");
|
|
|
|
|
}
|
|
|
|
|
|
1999-03-11 07:50:03 +08:00
|
|
|
|
/* Unserialize the selection */
|
|
|
|
|
if (H5S_select_deserialize(ret_value,p) < 0) {
|
|
|
|
|
HGOTO_ERROR(H5E_REFERENCE, H5E_CANTDECODE, NULL, "can't deserialize selection");
|
|
|
|
|
}
|
1998-11-25 08:29:09 +08:00
|
|
|
|
|
|
|
|
|
/* Free the buffer allocated in H5HG_read() */
|
|
|
|
|
H5MM_xfree(buf);
|
|
|
|
|
|
1999-03-11 07:50:03 +08:00
|
|
|
|
/* Close the dataset we opened */
|
|
|
|
|
if (H5D_close(dataset) < 0) {
|
|
|
|
|
HGOTO_ERROR(H5E_DATASET, H5E_CLOSEERROR, NULL, "not found");
|
|
|
|
|
}
|
1998-10-14 05:28:53 +08:00
|
|
|
|
|
|
|
|
|
done:
|
|
|
|
|
FUNC_LEAVE(ret_value);
|
1998-10-27 01:14:00 +08:00
|
|
|
|
} /* end H5R_get_region() */
|
1998-10-14 05:28:53 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*--------------------------------------------------------------------------
|
|
|
|
|
NAME
|
1998-10-27 01:14:00 +08:00
|
|
|
|
H5Rget_region
|
1998-10-14 05:28:53 +08:00
|
|
|
|
PURPOSE
|
|
|
|
|
Retrieves a dataspace with the region pointed to selected.
|
|
|
|
|
USAGE
|
1999-06-26 03:36:54 +08:00
|
|
|
|
hid_t H5Rget_region(id, ref_type, ref)
|
|
|
|
|
hid_t id; IN: Dataset reference object is in or location ID of
|
|
|
|
|
object that the dataset is located within.
|
|
|
|
|
H5R_type_t ref_type; IN: Type of reference to get region of
|
1998-10-23 06:49:16 +08:00
|
|
|
|
void *ref; IN: Reference to open.
|
1998-10-14 05:28:53 +08:00
|
|
|
|
|
|
|
|
|
RETURNS
|
1998-10-27 05:18:54 +08:00
|
|
|
|
Valid ID on success, Negative on failure
|
1998-10-14 05:28:53 +08:00
|
|
|
|
DESCRIPTION
|
|
|
|
|
Given a reference to some object, creates a copy of the dataset pointed
|
|
|
|
|
to's dataspace and defines a selection in the copy which is the region
|
|
|
|
|
pointed to.
|
|
|
|
|
GLOBAL VARIABLES
|
|
|
|
|
COMMENTS, BUGS, ASSUMPTIONS
|
|
|
|
|
EXAMPLES
|
|
|
|
|
REVISION LOG
|
|
|
|
|
--------------------------------------------------------------------------*/
|
|
|
|
|
hid_t
|
1999-06-26 03:36:54 +08:00
|
|
|
|
H5Rget_region(hid_t id, H5R_type_t ref_type, void *_ref)
|
1998-10-14 05:28:53 +08:00
|
|
|
|
{
|
1999-06-26 03:36:54 +08:00
|
|
|
|
H5G_entry_t *loc = NULL; /* Symbol table entry */
|
1998-11-25 08:29:09 +08:00
|
|
|
|
H5S_t *space = NULL; /* dataspace object */
|
1999-06-26 03:36:54 +08:00
|
|
|
|
H5F_t *file=NULL; /* File object */
|
1998-10-14 05:28:53 +08:00
|
|
|
|
hid_t ret_value = FAIL;
|
|
|
|
|
|
1998-10-27 01:14:00 +08:00
|
|
|
|
FUNC_ENTER(H5Rget_region, FAIL);
|
1999-06-26 03:36:54 +08:00
|
|
|
|
H5TRACE3("i","iRtx",id,ref_type,_ref);
|
1998-10-14 05:28:53 +08:00
|
|
|
|
|
|
|
|
|
/* Check args */
|
2000-12-02 23:11:57 +08:00
|
|
|
|
if (NULL == (loc = H5G_loc(id)))
|
|
|
|
|
HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location");
|
1998-11-25 08:29:09 +08:00
|
|
|
|
if(ref_type!=H5R_DATASET_REGION)
|
|
|
|
|
HRETURN_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "invalid reference type");
|
|
|
|
|
if(_ref==NULL)
|
|
|
|
|
HRETURN_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "invalid reference pointer");
|
1998-10-14 05:28:53 +08:00
|
|
|
|
|
2000-12-02 23:11:57 +08:00
|
|
|
|
/* Get the file pointer from the entry */
|
|
|
|
|
file=loc->file;
|
|
|
|
|
|
1998-11-25 08:29:09 +08:00
|
|
|
|
/* Get the dataspace with the correct region selected */
|
1999-06-26 03:36:54 +08:00
|
|
|
|
if ((space=H5R_get_region(file,ref_type,_ref))==NULL)
|
1998-10-14 05:28:53 +08:00
|
|
|
|
HGOTO_ERROR (H5E_REFERENCE, H5E_CANTCREATE, FAIL, "unable to create dataspace");
|
|
|
|
|
|
|
|
|
|
/* Atomize */
|
|
|
|
|
if ((ret_value=H5I_register (H5I_DATASPACE, space))<0)
|
|
|
|
|
HGOTO_ERROR (H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to register dataspace atom");
|
|
|
|
|
|
|
|
|
|
done:
|
|
|
|
|
FUNC_LEAVE(ret_value);
|
1998-10-27 01:14:00 +08:00
|
|
|
|
} /* end H5Rget_region() */
|
1998-10-14 05:28:53 +08:00
|
|
|
|
|
1999-03-13 04:05:43 +08:00
|
|
|
|
|
|
|
|
|
/*--------------------------------------------------------------------------
|
|
|
|
|
NAME
|
|
|
|
|
H5R_get_object_type
|
|
|
|
|
PURPOSE
|
|
|
|
|
Retrieves the type of object that an object reference points to
|
|
|
|
|
USAGE
|
2001-08-15 06:09:56 +08:00
|
|
|
|
int H5R_get_object_type(file, ref)
|
1999-06-26 03:36:54 +08:00
|
|
|
|
H5F_t *file; IN: File the object being dereferenced is within
|
1999-03-13 04:05:43 +08:00
|
|
|
|
void *ref; IN: Reference to query.
|
|
|
|
|
|
|
|
|
|
RETURNS
|
|
|
|
|
Success: An object type defined in H5Gpublic.h
|
|
|
|
|
Failure: H5G_UNKNOWN
|
|
|
|
|
DESCRIPTION
|
|
|
|
|
Given a reference to some object, this function returns the type of object
|
|
|
|
|
pointed to.
|
|
|
|
|
GLOBAL VARIABLES
|
|
|
|
|
COMMENTS, BUGS, ASSUMPTIONS
|
|
|
|
|
EXAMPLES
|
|
|
|
|
REVISION LOG
|
|
|
|
|
--------------------------------------------------------------------------*/
|
2001-08-15 06:09:56 +08:00
|
|
|
|
static int
|
1999-06-26 03:36:54 +08:00
|
|
|
|
H5R_get_object_type(H5F_t *file, void *_ref)
|
1999-03-13 04:05:43 +08:00
|
|
|
|
{
|
|
|
|
|
H5G_entry_t ent; /* Symbol table entry */
|
|
|
|
|
hobj_ref_t *ref=(hobj_ref_t *)_ref; /* Only object references currently supported */
|
|
|
|
|
uint8_t *p; /* Pointer to OID to store */
|
2001-08-15 06:09:56 +08:00
|
|
|
|
int ret_value = H5G_UNKNOWN;
|
1999-03-13 04:05:43 +08:00
|
|
|
|
|
1999-04-26 22:43:53 +08:00
|
|
|
|
FUNC_ENTER(H5R_get_object_type, H5G_UNKNOWN);
|
1999-03-13 04:05:43 +08:00
|
|
|
|
|
|
|
|
|
assert(ref);
|
1999-06-26 03:36:54 +08:00
|
|
|
|
assert(file);
|
1999-03-13 04:05:43 +08:00
|
|
|
|
|
|
|
|
|
/* Initialize the symbol table entry */
|
|
|
|
|
HDmemset(&ent,0,sizeof(H5G_entry_t));
|
|
|
|
|
ent.type=H5G_NOTHING_CACHED;
|
1999-06-26 03:36:54 +08:00
|
|
|
|
ent.file=file;
|
1999-03-13 04:05:43 +08:00
|
|
|
|
|
|
|
|
|
/* Get the object oid */
|
|
|
|
|
p=(uint8_t *)ref->oid;
|
|
|
|
|
H5F_addr_decode(ent.file,(const uint8_t **)&p,&(ent.header));
|
|
|
|
|
|
|
|
|
|
/* Get the OID type */
|
|
|
|
|
ret_value=H5G_get_type(&ent);
|
|
|
|
|
|
|
|
|
|
#ifdef LATER
|
|
|
|
|
done:
|
|
|
|
|
#endif /* LATER */
|
|
|
|
|
FUNC_LEAVE(ret_value);
|
|
|
|
|
} /* end H5R_get_object_type() */
|
|
|
|
|
|
|
|
|
|
/*--------------------------------------------------------------------------
|
|
|
|
|
NAME
|
|
|
|
|
H5Rget_object_type
|
|
|
|
|
PURPOSE
|
|
|
|
|
Retrieves the type of object that an object reference points to
|
|
|
|
|
USAGE
|
2001-08-15 06:09:56 +08:00
|
|
|
|
int H5Rget_object_type(id, ref)
|
1999-06-26 03:36:54 +08:00
|
|
|
|
hid_t id; IN: Dataset reference object is in or location ID of
|
|
|
|
|
object that the dataset is located within.
|
1999-03-13 04:05:43 +08:00
|
|
|
|
void *ref; IN: Reference to query.
|
|
|
|
|
|
|
|
|
|
RETURNS
|
|
|
|
|
Success: An object type defined in H5Gpublic.h
|
|
|
|
|
Failure: H5G_UNKNOWN
|
|
|
|
|
DESCRIPTION
|
|
|
|
|
Given a reference to some object, this function returns the type of object
|
|
|
|
|
pointed to.
|
|
|
|
|
GLOBAL VARIABLES
|
|
|
|
|
COMMENTS, BUGS, ASSUMPTIONS
|
|
|
|
|
EXAMPLES
|
|
|
|
|
REVISION LOG
|
|
|
|
|
--------------------------------------------------------------------------*/
|
1999-03-20 04:09:50 +08:00
|
|
|
|
int
|
1999-06-26 03:36:54 +08:00
|
|
|
|
H5Rget_object_type(hid_t id, void *_ref)
|
1999-03-13 04:05:43 +08:00
|
|
|
|
{
|
1999-06-26 03:36:54 +08:00
|
|
|
|
H5G_entry_t *loc = NULL; /* Symbol table entry */
|
|
|
|
|
H5F_t *file=NULL; /* File object */
|
1999-04-26 22:43:53 +08:00
|
|
|
|
hid_t ret_value = H5G_UNKNOWN;
|
1999-03-13 04:05:43 +08:00
|
|
|
|
|
1999-04-26 22:43:53 +08:00
|
|
|
|
FUNC_ENTER(H5Rget_object_type, H5G_UNKNOWN);
|
1999-06-26 03:36:54 +08:00
|
|
|
|
H5TRACE2("Is","ix",id,_ref);
|
1999-03-13 04:05:43 +08:00
|
|
|
|
|
|
|
|
|
/* Check args */
|
2000-12-02 23:11:57 +08:00
|
|
|
|
if (NULL == (loc = H5G_loc(id)))
|
|
|
|
|
HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location");
|
1999-03-13 04:05:43 +08:00
|
|
|
|
if(_ref==NULL)
|
1999-04-26 22:43:53 +08:00
|
|
|
|
HGOTO_ERROR (H5E_ARGS, H5E_BADVALUE, H5G_UNKNOWN,
|
|
|
|
|
"invalid reference pointer");
|
1999-03-13 04:05:43 +08:00
|
|
|
|
|
2000-12-02 23:11:57 +08:00
|
|
|
|
/* Get the file pointer from the entry */
|
|
|
|
|
file=loc->file;
|
|
|
|
|
|
1999-03-13 04:05:43 +08:00
|
|
|
|
/* Get the object information */
|
1999-06-26 03:36:54 +08:00
|
|
|
|
if ((ret_value=H5R_get_object_type(file,_ref))<0) {
|
1999-06-07 23:05:02 +08:00
|
|
|
|
HGOTO_ERROR(H5E_REFERENCE, H5E_CANTINIT, H5G_UNKNOWN,
|
|
|
|
|
"unable to determine object type");
|
|
|
|
|
}
|
|
|
|
|
|
1999-03-13 04:05:43 +08:00
|
|
|
|
done:
|
|
|
|
|
FUNC_LEAVE(ret_value);
|
|
|
|
|
} /* end H5Rget_object_type() */
|
1999-06-12 06:04:42 +08:00
|
|
|
|
|