diff options
author | Pedro Vicente Nunes <pvn@hdfgroup.org> | 2005-03-21 21:28:13 (GMT) |
---|---|---|
committer | Pedro Vicente Nunes <pvn@hdfgroup.org> | 2005-03-21 21:28:13 (GMT) |
commit | 98b02fbdcbe12ae422b3ee62f2dcab0025ce6b54 (patch) | |
tree | 5a1c237add42edf7f7d99e377a2a812574a4a438 /hl/src/H5DS.c | |
parent | 7079f6b1e90ae02ec6abbb3457047d9e8d7f2956 (diff) | |
download | hdf5-98b02fbdcbe12ae422b3ee62f2dcab0025ce6b54.zip hdf5-98b02fbdcbe12ae422b3ee62f2dcab0025ce6b54.tar.gz hdf5-98b02fbdcbe12ae422b3ee62f2dcab0025ce6b54.tar.bz2 |
[svn-r10248] Purpose:
new tests for DS
Description:
add a test that ckecks if a scale being attached itself has scales attached (error)
add a test for the dataset being attached to is a reserved High Level class (image, palette, table)
Solution:
Platforms tested:
linux
solaris
Misc. update:
Diffstat (limited to 'hl/src/H5DS.c')
-rw-r--r-- | hl/src/H5DS.c | 86 |
1 files changed, 86 insertions, 0 deletions
diff --git a/hl/src/H5DS.c b/hl/src/H5DS.c index 214769c..552de73 100644 --- a/hl/src/H5DS.c +++ b/hl/src/H5DS.c @@ -14,6 +14,10 @@ #include "H5DS.h" #include "H5LT.h" #include <stdlib.h> +#include "H5IM.h" +#include "H5TB.h" + + /*------------------------------------------------------------------------- * Function: H5DSset_scale @@ -156,6 +160,15 @@ herr_t H5DSattach_scale(hid_t did, if (H5I_DATASET!=it1 || H5I_DATASET!=it2) return FAIL; + /* the DS dataset cannot have dimension scales */ + if (H5LT_find_attribute(dsid,DIMENSION_LIST)==1) + return FAIL; + + /* check if the dataset is a "reserved" dataset (image, table) */ + if (H5DS_is_reserved(did)==1) + return FAIL; + + /*------------------------------------------------------------------------- * The dataset may or may not have the associated DS attribute * First we try to open to see if it is already there; if not, it is created. @@ -1959,3 +1972,76 @@ out: +/*------------------------------------------------------------------------- + * Function: H5DS_is_reserved + * + * Purpose: Verify that a dataset's CLASS is either an image, palette or table + * + * Return: true, false, fail + * + * Programmer: pvn@ncsa.uiuc.edu + * + * Date: March 19, 2005 + * + * Comments: + * + * Modifications: + * + *------------------------------------------------------------------------- + */ + +herr_t H5DS_is_reserved(hid_t did) +{ + int has_class; + hid_t tid; + hid_t aid; + char buf[40]; + herr_t ret; + + /* try to find the attribute "CLASS" on the dataset */ + if ((has_class = H5LT_find_attribute(did,"CLASS"))<0) + return -1; + + if ( has_class == 0 ) + return 0; + + else if ( has_class == 1 ) + { + if ((aid = H5Aopen_name(did,"CLASS"))<0) + goto out; + + if ((tid = H5Aget_type(aid))<0) + goto out; + + if (H5Aread(aid,tid,buf)<0) + goto out; + + if ( strcmp(buf,IMAGE_CLASS)==0 || + strcmp(buf,PALETTE_CLASS)==0 || + strcmp(buf,TABLE_CLASS)==0 ) + ret = 1; + else + ret = 0; + + if (H5Tclose(tid)<0) + goto out; + + if (H5Aclose(aid)<0) + goto out; + + } + + return ret; + +/* error zone, gracefully close */ +out: + H5E_BEGIN_TRY { + H5Tclose(tid); + H5Aclose(aid); + } H5E_END_TRY; + return FAIL; +} + + + + |