diff options
author | Quincey Koziol <koziol@hdfgroup.org> | 2006-11-27 14:51:22 (GMT) |
---|---|---|
committer | Quincey Koziol <koziol@hdfgroup.org> | 2006-11-27 14:51:22 (GMT) |
commit | 59208d8a9b3e0c00cb604acfb153113789e66a28 (patch) | |
tree | 25a5583a49280d9a3bee876202b74b51094444b5 /src | |
parent | 50005f98ad6edbdcd9b1edbc729a909b88d06d1d (diff) | |
download | hdf5-59208d8a9b3e0c00cb604acfb153113789e66a28.zip hdf5-59208d8a9b3e0c00cb604acfb153113789e66a28.tar.gz hdf5-59208d8a9b3e0c00cb604acfb153113789e66a28.tar.bz2 |
[svn-r12976] Description:
Add # of attributes to the object info struct and deprecate
H5Aget_num_attrs().
Tested on:
FreeBSd/32 4.11 (sleipnir)
Linux/32 2.4 (heping)
Linux/64 2.4 (mir)
AIX/32 5.? (copper)
Diffstat (limited to 'src')
-rw-r--r-- | src/H5A.c | 144 | ||||
-rw-r--r-- | src/H5Adeprec.c | 164 | ||||
-rw-r--r-- | src/H5Apkg.h | 7 | ||||
-rw-r--r-- | src/H5Apublic.h | 8 | ||||
-rw-r--r-- | src/H5O.c | 58 | ||||
-rw-r--r-- | src/H5Opublic.h | 1 | ||||
-rwxr-xr-x | src/Makefile.am | 2 | ||||
-rw-r--r-- | src/Makefile.in | 5 |
8 files changed, 268 insertions, 121 deletions
@@ -12,16 +12,21 @@ * access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ +/****************/ +/* Module Setup */ +/****************/ + #define H5A_PACKAGE /*suppress error about including H5Apkg */ /* Interface initialization */ #define H5_INTERFACE_INIT_FUNC H5A_init_interface -/* Private header files */ +/***********/ +/* Headers */ +/***********/ #include "H5private.h" /* Generic Functions */ #include "H5Apkg.h" /* Attributes */ -#include "H5Dprivate.h" /* Datasets */ #include "H5Eprivate.h" /* Error handling */ #include "H5FLprivate.h" /* Free Lists */ #include "H5Iprivate.h" /* IDs */ @@ -29,7 +34,35 @@ #include "H5Sprivate.h" /* Dataspace functions */ #include "H5SMprivate.h" /* Shared Object Header Messages */ -/* PRIVATE PROTOTYPES */ +/****************/ +/* Local Macros */ +/****************/ + +/* The number of reserved IDs in dataset ID group */ +#define H5A_RESERVED_ATOMS 0 + + +/******************/ +/* Local Typedefs */ +/******************/ + +/* Object header iterator callbacks */ +/* Data structure for callback for locating the index by name */ +typedef struct H5A_iter_cb1 { + const char *name; + int idx; +} H5A_iter_cb1; + + +/********************/ +/* Package Typedefs */ +/********************/ + + +/********************/ +/* Local Prototypes */ +/********************/ + static hid_t H5A_create(const H5G_loc_t *loc, const char *name, const H5T_t *type, const H5S_t *space, hid_t acpl_id, hid_t dxpl_id); static hid_t H5A_open(H5G_loc_t *loc, unsigned idx, hid_t dxpl_id); @@ -38,17 +71,22 @@ static herr_t H5A_read(const H5A_t *attr, const H5T_t *mem_type, void *buf, hid_ static int H5A_get_index(H5O_loc_t *loc, const char *name, hid_t dxpl_id); static hsize_t H5A_get_storage_size(const H5A_t *attr); static herr_t H5A_rename(H5O_loc_t *loc, const char *old_name, const char *new_name, hid_t dxpl_id); - -/* Object header iterator callbacks */ -/* Data structure for callback for locating the index by name */ -typedef struct H5A_iter_cb1 { - const char *name; - int idx; -} H5A_iter_cb1; static herr_t H5A_find_idx_by_name(const void *mesg, unsigned idx, void *op_data); -/* The number of reserved IDs in dataset ID group */ -#define H5A_RESERVED_ATOMS 0 + +/*********************/ +/* Package Variables */ +/*********************/ + + +/*****************************/ +/* Library Private Variables */ +/*****************************/ + + +/*******************/ +/* Local Variables */ +/*******************/ /* Declare the free lists for H5A_t's */ H5FL_DEFINE(H5A_t); @@ -57,6 +95,32 @@ H5FL_DEFINE(H5A_t); H5FL_BLK_DEFINE(attr_buf); +/*------------------------------------------------------------------------- + * Function: H5A_init + * + * Purpose: Initialize the interface from some other package. + * + * Return: Success: non-negative + * Failure: negative + * + * Programmer: Quincey Koziol + * Monday, November 27, 2006 + * + *------------------------------------------------------------------------- + */ +herr_t +H5A_init(void) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(H5A_init, FAIL) + /* FUNC_ENTER() does all the work */ + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5A_init() */ + + /*-------------------------------------------------------------------------- NAME H5A_init_interface -- Initialize interface-specific information @@ -1220,62 +1284,6 @@ H5A_get_storage_size(const H5A_t *attr) } -/*-------------------------------------------------------------------------- - NAME - H5Aget_num_attrs - PURPOSE - Determines the number of attributes attached to an object - USAGE - int H5Aget_num_attrs (loc_id) - hid_t loc_id; IN: Object (dataset or group) to be queried - RETURNS - Number of attributes on success, negative on failure - - DESCRIPTION - This function returns the number of attributes attached to a dataset or - group, 'location_id'. ---------------------------------------------------------------------------*/ -int -H5Aget_num_attrs(hid_t loc_id) -{ - H5O_loc_t *loc = NULL; /* Object location for attribute */ - void *obj = NULL; - int ret_value; - - FUNC_ENTER_API(H5Aget_num_attrs, FAIL) - H5TRACE1("Is","i",loc_id); - - /* check arguments */ - if(H5I_FILE == H5I_get_type(loc_id) || H5I_ATTR == H5I_get_type(loc_id)) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "location is not valid for an attribute") - if(NULL == (obj = H5I_object(loc_id))) - HGOTO_ERROR(H5E_ARGS, H5E_BADATOM, FAIL, "illegal object atom") - switch (H5I_get_type (loc_id)) { - case H5I_DATASET: - loc = H5D_oloc((H5D_t*)obj); - break; - - case H5I_DATATYPE: - if(NULL == (loc = H5T_oloc((H5T_t*)obj))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "target datatype is not committed") - break; - - case H5I_GROUP: - loc = H5G_oloc((H5G_t*)obj); - break; - - default: - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "inappropriate attribute target") - } /*lint !e788 All appropriate cases are covered */ - - /* Look up the attribute for the object */ - ret_value = H5O_count(loc, H5O_ATTR_ID, H5AC_ind_dxpl_id); - -done: - FUNC_LEAVE_API(ret_value) -} /* H5Aget_num_attrs() */ - - /*------------------------------------------------------------------------- * Function: H5Arename * diff --git a/src/H5Adeprec.c b/src/H5Adeprec.c new file mode 100644 index 0000000..b2c0b01 --- /dev/null +++ b/src/H5Adeprec.c @@ -0,0 +1,164 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Copyright by the Board of Trustees of the University of Illinois. * + * All rights reserved. * + * * + * This file is part of HDF5. The full HDF5 copyright notice, including * + * terms governing use, modification, and redistribution, is contained in * + * the files COPYING and Copyright.html. COPYING can be found at the root * + * of the source code distribution tree; Copyright.html can be found at the * + * root level of an installed copy of the electronic HDF5 document set and * + * is linked from the top-level documents page. It can also be found at * + * http://hdf.ncsa.uiuc.edu/HDF5/doc/Copyright.html. If you do not have * + * access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/*------------------------------------------------------------------------- + * + * Created: H5Adeprec.c + * November 27 2006 + * Quincey Koziol <koziol@hdfgroup.org> + * + * Purpose: Deprecated functions from the H5A interface. These + * functions are here for compatibility purposes and may be + * removed in the future. Applications should switch to the + * newer APIs. + * + *------------------------------------------------------------------------- + */ + +/****************/ +/* Module Setup */ +/****************/ + +#define H5A_PACKAGE /*suppress error about including H5Apkg */ + +/* Interface initialization */ +#define H5_INTERFACE_INIT_FUNC H5A_init_deprec_interface + + +/***********/ +/* Headers */ +/***********/ +#include "H5private.h" /* Generic Functions */ +#include "H5Apkg.h" /* Attributes */ +#include "H5Dprivate.h" /* Datasets */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Iprivate.h" /* IDs */ + + +/****************/ +/* Local Macros */ +/****************/ + + +/******************/ +/* Local Typedefs */ +/******************/ + + +/********************/ +/* Package Typedefs */ +/********************/ + + +/********************/ +/* Local Prototypes */ +/********************/ + + +/*********************/ +/* Package Variables */ +/*********************/ + + +/*****************************/ +/* Library Private Variables */ +/*****************************/ + + +/*******************/ +/* Local Variables */ +/*******************/ + + + +/*-------------------------------------------------------------------------- +NAME + H5A_init_deprec_interface -- Initialize interface-specific information +USAGE + herr_t H5A_init_deprec_interface() +RETURNS + Non-negative on success/Negative on failure +DESCRIPTION + Initializes any interface-specific data or routines. (Just calls + H5A_init() currently). + +--------------------------------------------------------------------------*/ +static herr_t +H5A_init_deprec_interface(void) +{ + FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5A_init_deprec_interface) + + FUNC_LEAVE_NOAPI(H5A_init()) +} /* H5A_init_deprec_interface() */ + + +/*-------------------------------------------------------------------------- + NAME + H5Aget_num_attrs + PURPOSE + Determines the number of attributes attached to an object + NOTE + Deprecated in favor of H5Oget_info[_by_idx] + USAGE + int H5Aget_num_attrs (loc_id) + hid_t loc_id; IN: Object (dataset or group) to be queried + RETURNS + Number of attributes on success, negative on failure + DESCRIPTION + This function returns the number of attributes attached to a dataset or + group, 'location_id'. +--------------------------------------------------------------------------*/ +int +H5Aget_num_attrs(hid_t loc_id) +{ + H5O_loc_t *loc; /* Object location for attribute */ + void *obj; + int ret_value; + + FUNC_ENTER_API(H5Aget_num_attrs, FAIL) + H5TRACE1("Is","i",loc_id); + + /* check arguments */ + if(H5I_FILE == H5I_get_type(loc_id) || H5I_ATTR == H5I_get_type(loc_id)) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "location is not valid for an attribute") + if(NULL == (obj = H5I_object(loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADATOM, FAIL, "illegal object atom") + switch(H5I_get_type (loc_id)) { + case H5I_DATASET: + if(NULL == (loc = H5D_oloc((H5D_t*)obj))) + HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, FAIL, "can't get location for object") + break; + + case H5I_DATATYPE: + if(NULL == (loc = H5T_oloc((H5T_t*)obj))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "target datatype is not committed") + break; + + case H5I_GROUP: + if(NULL == (loc = H5G_oloc((H5G_t*)obj))) + HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, FAIL, "can't get location for object") + break; + + default: + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "inappropriate attribute target") + } /*lint !e788 All appropriate cases are covered */ + + /* Look up the # of attributes for the object */ + if((ret_value = H5O_count(loc, H5O_ATTR_ID, H5AC_ind_dxpl_id)) < 0) + HGOTO_ERROR(H5E_ATTR, H5E_CANTCOUNT, FAIL, "can't get attribute count for object") + +done: + FUNC_LEAVE_API(ret_value) +} /* H5Aget_num_attrs() */ + diff --git a/src/H5Apkg.h b/src/H5Apkg.h index b8babf9..e01d788 100644 --- a/src/H5Apkg.h +++ b/src/H5Apkg.h @@ -66,8 +66,9 @@ H5FL_EXTERN(H5A_t); H5FL_BLK_EXTERN(attr_buf); /* Function prototypes for H5A package scope */ -H5_DLL H5A_t *H5A_copy(H5A_t *new_attr, const H5A_t *old_attr, unsigned update_flags); -H5_DLL herr_t H5A_free(H5A_t *attr); -H5_DLL herr_t H5A_close(H5A_t *attr); +H5_DLL herr_t H5A_init(void); +H5_DLL H5A_t *H5A_copy(H5A_t *new_attr, const H5A_t *old_attr, unsigned update_flags); +H5_DLL herr_t H5A_free(H5A_t *attr); +H5_DLL herr_t H5A_close(H5A_t *attr); #endif diff --git a/src/H5Apublic.h b/src/H5Apublic.h index ec9904a..21545ae 100644 --- a/src/H5Apublic.h +++ b/src/H5Apublic.h @@ -41,12 +41,18 @@ H5_DLL hid_t H5Aget_type(hid_t attr_id); H5_DLL hid_t H5Aget_create_plist(hid_t attr_id); H5_DLL ssize_t H5Aget_name(hid_t attr_id, size_t buf_size, char *buf); H5_DLL hsize_t H5Aget_storage_size(hid_t attr_id); -H5_DLL int H5Aget_num_attrs(hid_t loc_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 H5Adelete(hid_t loc_id, const char *name); +/* Functions and variables defined for compatibility with previous versions + * of the HDF5 API. + * + * Use of these functions and variables is deprecated. + */ +H5_DLL int H5Aget_num_attrs(hid_t loc_id); + #ifdef __cplusplus } #endif @@ -123,8 +123,6 @@ static herr_t H5O_new(H5F_t *f, hid_t dxpl_id, size_t chunk_size, static herr_t H5O_reset_real(const H5O_msg_class_t *type, void *native); static void * H5O_copy_real(const H5O_msg_class_t *type, const void *mesg, void *dst); -static int H5O_count_real(H5O_loc_t *loc, const H5O_msg_class_t *type, - hid_t dxpl_id); static void *H5O_read_real(H5F_t *f, H5O_t *oh, unsigned type_id, int sequence, void *mesg, hid_t dxpl_id); static unsigned H5O_find_in_ohdr(H5F_t *f, hid_t dxpl_id, H5O_t *oh, @@ -1370,8 +1368,11 @@ done: int H5O_count(H5O_loc_t *loc, unsigned type_id, hid_t dxpl_id) { - const H5O_msg_class_t *type; /* Actual H5O class type for the ID */ - int ret_value; /* Return value */ + H5O_t *oh = NULL; /* Object header to operate on */ + const H5O_msg_class_t *type; /* Actual H5O class type for the ID */ + int acc; /* Count of the message type found */ + unsigned u; /* Local index variable */ + int ret_value; /* Return value */ FUNC_ENTER_NOAPI(H5O_count, FAIL) @@ -1383,46 +1384,6 @@ H5O_count(H5O_loc_t *loc, unsigned type_id, hid_t dxpl_id) type = H5O_msg_class_g[type_id]; /* map the type ID to the actual type object */ HDassert(type); - /* Call the "real" count routine */ - if((ret_value = H5O_count_real(loc, type, dxpl_id)) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_CANTCOUNT, FAIL, "unable to count object header messages") - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5O_count() */ - - -/*------------------------------------------------------------------------- - * Function: H5O_count_real - * - * Purpose: Counts the number of messages in an object header which are a - * certain type. - * - * Return: Success: Number of messages of specified type. - * - * Failure: Negative - * - * Programmer: Robb Matzke - * Tuesday, April 21, 1998 - * - *------------------------------------------------------------------------- - */ -static int -H5O_count_real(H5O_loc_t *loc, const H5O_msg_class_t *type, hid_t dxpl_id) -{ - H5O_t *oh = NULL; - int acc; - unsigned u; - int ret_value; - - FUNC_ENTER_NOAPI(H5O_count_real, FAIL) - - /* Check args */ - HDassert(loc); - HDassert(loc->file); - HDassert(H5F_addr_defined(loc->addr)); - HDassert(type); - /* Load the object header */ if(NULL == (oh = H5AC_protect(loc->file, dxpl_id, H5AC_OHDR, loc->addr, NULL, NULL, H5AC_READ))) HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, FAIL, "unable to load object header") @@ -1436,11 +1397,11 @@ H5O_count_real(H5O_loc_t *loc, const H5O_msg_class_t *type, hid_t dxpl_id) ret_value = acc; done: - if (oh && H5AC_unprotect(loc->file, dxpl_id, H5AC_OHDR, loc->addr, oh, H5AC__NO_FLAGS_SET) != SUCCEED) + if(oh && H5AC_unprotect(loc->file, dxpl_id, H5AC_OHDR, loc->addr, oh, H5AC__NO_FLAGS_SET) < 0) HDONE_ERROR(H5E_OHDR, H5E_PROTECT, FAIL, "unable to release object header") FUNC_LEAVE_NOAPI(ret_value) -} /* end H5O_count_real() */ +} /* end H5O_count() */ /*------------------------------------------------------------------------- @@ -3909,6 +3870,7 @@ H5O_get_info(H5O_loc_t *oloc, H5O_info_t *oinfo, hid_t dxpl_id) oinfo->hdr.nchunks = oh->nchunks; /* Iterate over all the messages, accumulating message size & type information */ + oinfo->num_attrs = 0; oinfo->hdr.meta_space = H5O_SIZEOF_HDR_OH(oh) + (H5O_SIZEOF_CHKHDR_OH(oh) * (oh->nchunks - 1)); oinfo->hdr.mesg_space = 0; oinfo->hdr.free_space = 0; @@ -3917,6 +3879,10 @@ H5O_get_info(H5O_loc_t *oloc, H5O_info_t *oinfo, hid_t dxpl_id) for(u = 0, curr_msg = &oh->mesg[0]; u < oh->nmesgs; u++, curr_msg++) { uint64_t type_flag; /* Flag for message type */ + /* Check for attribute message */ + if(H5O_ATTR_ID == curr_msg->type->id) + oinfo->num_attrs++; + /* Accumulate information, based on the type of message */ if(H5O_NULL_ID == curr_msg->type->id) oinfo->hdr.free_space += H5O_SIZEOF_MSGHDR_OH(oh) + curr_msg->raw_size; diff --git a/src/H5Opublic.h b/src/H5Opublic.h index b2a9778..4591120 100644 --- a/src/H5Opublic.h +++ b/src/H5Opublic.h @@ -87,6 +87,7 @@ typedef struct H5O_info_t { H5O_type_t type; /* Basic object type (group, dataset, etc.) */ unsigned rc; /* Reference count of object */ time_t mtime; /* Modification time */ + hsize_t num_attrs; /* # of attributes attached to object */ struct { unsigned version; /* Version number of header format in file */ unsigned nmesgs; /* Number of object header messages */ diff --git a/src/Makefile.am b/src/Makefile.am index 98103da..298b488 100755 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -41,7 +41,7 @@ DISTCLEANFILES=H5pubconf.h # library sources libhdf5_la_SOURCES= H5.c H5checksum.c H5dbg.c H5system.c H5timer.c H5trace.c \ - H5A.c H5AC.c H5B.c H5Bcache.c \ + H5A.c H5Adeprec.c H5AC.c H5B.c H5Bcache.c \ H5B2.c H5B2cache.c H5B2dbg.c H5B2int.c H5B2stat.c H5B2test.c \ H5C.c H5CS.c H5D.c H5Dcompact.c H5Dcontig.c \ H5Defl.c H5Dio.c H5Distore.c H5Dmpio.c H5Doh.c H5Dselect.c H5Dtest.c \ diff --git a/src/Makefile.in b/src/Makefile.in index 912c552..b4a7135 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -81,7 +81,7 @@ libLTLIBRARIES_INSTALL = $(INSTALL) LTLIBRARIES = $(lib_LTLIBRARIES) libhdf5_la_LIBADD = am_libhdf5_la_OBJECTS = H5.lo H5checksum.lo H5dbg.lo H5system.lo \ - H5timer.lo H5trace.lo H5A.lo H5AC.lo H5B.lo H5Bcache.lo \ + H5timer.lo H5trace.lo H5A.lo H5Adeprec.lo H5AC.lo H5B.lo H5Bcache.lo \ H5B2.lo H5B2cache.lo H5B2dbg.lo H5B2int.lo H5B2stat.lo \ H5B2test.lo H5C.lo H5CS.lo H5D.lo H5Dcompact.lo H5Dcontig.lo \ H5Defl.lo H5Dio.lo H5Distore.lo H5Dmpio.lo H5Doh.lo \ @@ -397,7 +397,7 @@ DISTCLEANFILES = H5pubconf.h # library sources libhdf5_la_SOURCES = H5.c H5checksum.c H5dbg.c H5system.c H5timer.c H5trace.c \ - H5A.c H5AC.c H5B.c H5Bcache.c \ + H5A.c H5Adeprec.c H5AC.c H5B.c H5Bcache.c \ H5B2.c H5B2cache.c H5B2dbg.c H5B2int.c H5B2stat.c H5B2test.c \ H5C.c H5CS.c H5D.c H5Dcompact.c H5Dcontig.c \ H5Defl.c H5Dio.c H5Distore.c H5Dmpio.c H5Doh.c H5Dselect.c H5Dtest.c \ @@ -565,6 +565,7 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/H5.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/H5A.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/H5Adeprec.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/H5AC.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/H5B.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/H5B2.Plo@am__quote@ |