diff options
author | Quincey Koziol <koziol@hdfgroup.org> | 2000-11-29 17:38:19 (GMT) |
---|---|---|
committer | Quincey Koziol <koziol@hdfgroup.org> | 2000-11-29 17:38:19 (GMT) |
commit | 19d811532a101399eed1a0f38d09574ee3c09001 (patch) | |
tree | 6f7e2147d0567594de2c521f60b1e2cdc6674577 /src | |
parent | ad731c2c1bc8683b6a5a4e77a0278d76fa2daec8 (diff) | |
download | hdf5-19d811532a101399eed1a0f38d09574ee3c09001.zip hdf5-19d811532a101399eed1a0f38d09574ee3c09001.tar.gz hdf5-19d811532a101399eed1a0f38d09574ee3c09001.tar.bz2 |
[svn-r3020] Purpose:
Code addition
Description:
The dumper needs to know when a datatype needs to be reclaimed, so I
added a small helper function to detect if a particular datatype is or
contains a particular class of datatypes.
Platforms tested:
Linux 2.2.16-3smp (eirene)
Diffstat (limited to 'src')
-rw-r--r-- | src/H5T.c | 93 | ||||
-rw-r--r-- | src/H5Tconv.c | 59 | ||||
-rw-r--r-- | src/H5Tprivate.h | 1 | ||||
-rw-r--r-- | src/H5Tpublic.h | 1 |
4 files changed, 96 insertions, 58 deletions
@@ -1878,6 +1878,99 @@ H5T_get_class(const H5T_t *dt) /*------------------------------------------------------------------------- + * Function: H5Tdetect_class + * + * Purpose: Check whether a datatype contains (or is) a certain type of + * datatype. + * + * Return: TRUE (1) or FALSE (0) on success/Negative on failure + * + * Programmer: Quincey Koziol + * Wednesday, November 29, 2000 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +htri_t +H5Tdetect_class(hid_t type, H5T_class_t cls) +{ + H5T_t *dt = NULL; + + FUNC_ENTER (H5Tdetect_class, FAIL); + H5TRACE2("b","iTt",type,cls); + + /* Check args */ + if (H5I_DATATYPE != H5I_get_type(type) || + NULL == (dt = H5I_object(type))) { + HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, H5T_NO_CLASS, "not a data type"); + } + if (!(cls>H5T_NO_CLASS && cls<H5T_NCLASSES)) { + HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, H5T_NO_CLASS, "not a data type class"); + } + + FUNC_LEAVE(H5T_detect_class(dt,cls)); +} + + +/*------------------------------------------------------------------------- + * Function: H5T_detect_class + * + * Purpose: Check whether a datatype contains (or is) a certain type of + * datatype. + * + * Return: TRUE (1) or FALSE (0) on success/Negative on failure + * + * Programmer: Quincey Koziol + * Wednesday, November 29, 2000 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +htri_t +H5T_detect_class (H5T_t *dt, H5T_class_t cls) +{ + intn i; + + FUNC_ENTER (H5T_detect_class, FAIL); + + assert(dt); + assert(cls>H5T_NO_CLASS && cls<H5T_NCLASSES); + + /* Check if this type is the correct type */ + if(dt->type==cls) + HRETURN(TRUE); + + /* check for types that might have the correct type as a component */ + switch(dt->type) { + case H5T_COMPOUND: + for (i=0; i<dt->u.compnd.nmembs; i++) { + /* Check if this field's type is the correct type */ + if(dt->u.compnd.memb[i].type->type==cls) + HRETURN(TRUE); + + /* Recurse if it's VL, compound or array */ + if(dt->u.compnd.memb[i].type->type==H5T_COMPOUND || dt->u.compnd.memb[i].type->type==H5T_VLEN || dt->u.compnd.memb[i].type->type==H5T_ARRAY) + HRETURN(H5T_detect_class(dt->u.compnd.memb[i].type,cls)); + } /* end for */ + break; + + case H5T_ARRAY: + case H5T_VLEN: + case H5T_ENUM: + HRETURN(H5T_detect_class(dt->parent,cls)); + break; + + default: + break; + } /* end if */ + + FUNC_LEAVE (FALSE); +} + + +/*------------------------------------------------------------------------- * Function: H5Tget_size * * Purpose: Determines the total size of a data type in bytes. diff --git a/src/H5Tconv.c b/src/H5Tconv.c index c7316e9..90fe6e8 100644 --- a/src/H5Tconv.c +++ b/src/H5Tconv.c @@ -776,63 +776,6 @@ H5T_conv_b_b(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, /*------------------------------------------------------------------------- - * Function: H5T_detect_type - * - * Purpose: Check whether a datatype contains (or is) a certain type of - * datatype. - * - * Return: TRUE (1) or FALSE (0) on success/Negative on failure - * - * Programmer: Quincey Koziol - * Wednesday, November 29, 2000 - * - * Modifications: - * - *------------------------------------------------------------------------- - */ -static herr_t -H5T_detect_type (H5T_t *dt, H5T_class_t cls) -{ - intn i; - - FUNC_ENTER (H5T_detect_type, FAIL); - - assert(dt); - assert(cls>H5T_NO_CLASS && cls<H5T_NCLASSES); - - /* Check if this type is the correct type */ - if(dt->type==cls) - HRETURN(TRUE); - - /* check for types that might have the correct type as a component */ - switch(dt->type) { - case H5T_COMPOUND: - for (i=0; i<dt->u.compnd.nmembs; i++) { - /* Check if this field's type is the correct type */ - if(dt->u.compnd.memb[i].type->type==cls) - HRETURN(TRUE); - - /* Recurse if it's VL, compound or array */ - if(dt->u.compnd.memb[i].type->type==H5T_COMPOUND || dt->u.compnd.memb[i].type->type==H5T_VLEN || dt->u.compnd.memb[i].type->type==H5T_ARRAY) - HRETURN(H5T_detect_type(dt->u.compnd.memb[i].type,cls)); - } /* end for */ - break; - - case H5T_ARRAY: - case H5T_VLEN: - case H5T_ENUM: - HRETURN(H5T_detect_type(dt->parent,cls)); - break; - - default: - break; - } /* end if */ - - FUNC_LEAVE (FALSE); -} - - -/*------------------------------------------------------------------------- * Function: H5T_conv_need_bkg * * Purpose: Check whether the source or destination datatypes require a @@ -861,7 +804,7 @@ H5T_conv_need_bkg (H5T_t *src, H5T_t *dst, H5T_cdata_t *cdata) assert(dst); assert(cdata); - if (H5T_detect_type(src,H5T_COMPOUND)==TRUE || H5T_detect_type(dst,H5T_COMPOUND)==TRUE) + if (H5T_detect_class(src,H5T_COMPOUND)==TRUE || H5T_detect_class(dst,H5T_COMPOUND)==TRUE) cdata->need_bkg = H5T_BKG_TEMP; FUNC_LEAVE (SUCCEED); diff --git a/src/H5Tprivate.h b/src/H5Tprivate.h index 59f3e8b..697ac6f 100644 --- a/src/H5Tprivate.h +++ b/src/H5Tprivate.h @@ -106,6 +106,7 @@ __DLL__ herr_t H5T_unregister(H5T_pers_t pers, const char *name, H5T_t *src, H5T_t *dst, H5T_conv_t func); __DLL__ herr_t H5T_path_force_reinit(H5T_t *dt); __DLL__ H5T_class_t H5T_get_class(const H5T_t *dt); +__DLL__ htri_t H5T_detect_class (H5T_t *dt, H5T_class_t cls); __DLL__ size_t H5T_get_size(const H5T_t *dt); __DLL__ intn H5T_cmp(const H5T_t *dt1, const H5T_t *dt2); __DLL__ htri_t H5T_is_atomic(const H5T_t *dt); diff --git a/src/H5Tpublic.h b/src/H5Tpublic.h index 1a20382..3abb8d5 100644 --- a/src/H5Tpublic.h +++ b/src/H5Tpublic.h @@ -489,6 +489,7 @@ __DLL__ char *H5Tget_tag(hid_t type); /* Querying property values */ __DLL__ hid_t H5Tget_super(hid_t type); __DLL__ H5T_class_t H5Tget_class(hid_t type_id); +__DLL__ htri_t H5Tdetect_class(hid_t type_id, H5T_class_t cls); __DLL__ size_t H5Tget_size(hid_t type_id); __DLL__ H5T_order_t H5Tget_order(hid_t type_id); __DLL__ size_t H5Tget_precision(hid_t type_id); |