diff options
author | Quincey Koziol <koziol@hdfgroup.org> | 2002-02-06 16:07:23 (GMT) |
---|---|---|
committer | Quincey Koziol <koziol@hdfgroup.org> | 2002-02-06 16:07:23 (GMT) |
commit | eb5697d309462919f3f00ec16c16bea7d0d66432 (patch) | |
tree | 700d17f1342adb4ab47b8b54f377870aade79d75 | |
parent | 0288e2f9da0f35ace658e23ee82ac203a11a7fed (diff) | |
download | hdf5-eb5697d309462919f3f00ec16c16bea7d0d66432.zip hdf5-eb5697d309462919f3f00ec16c16bea7d0d66432.tar.gz hdf5-eb5697d309462919f3f00ec16c16bea7d0d66432.tar.bz2 |
[svn-r4904] Purpose:
Bug fix
Description:
Generic property classes derived from an existing class were not having
the parent class's properties copied into the new class.
Additionally, derived classes were not being detected correctly.
Solution:
Copied properties from parent class into derived class.
Modified H5P_isa_class_real() to walk back up the chain of parent classes
to proper detect derived classes.
Platforms tested:
FreeBSD 4.5 (sleipnir)
-rw-r--r-- | src/H5P.c | 65 |
1 files changed, 49 insertions, 16 deletions
@@ -4716,7 +4716,10 @@ H5P_create_class(H5P_genclass_t *par_class, const char *name, unsigned hashsize, H5P_cls_close_func_t cls_close, void *close_data ) { - H5P_genclass_t *pclass; /* Property list class created */ + H5P_genclass_t *pclass; /* Property list class created */ + H5P_genprop_t *tmp; /* Temporary pointer to parent class properties */ + H5P_genprop_t *pcopy; /* Copy of property to insert into class */ + unsigned u; /* Local index variable */ H5P_genclass_t *ret_value=NULL; /* return value */ FUNC_ENTER (H5P_create_class, NULL); @@ -4753,10 +4756,36 @@ H5P_create_class(H5P_genclass_t *par_class, const char *name, unsigned hashsize, pclass->close_data = close_data; /* Increment parent class's derived class value */ - if(par_class!=NULL) + if(par_class!=NULL) { if(H5P_access_class(par_class,H5P_MOD_INC_CLS)<0) HGOTO_ERROR (H5E_PLIST, H5E_CANTINIT, NULL,"Can't increment parent class ref count"); + /* Copy parent class's properties into this new class */ + if(par_class->nprops>0) { + /* Walk through the hash table */ + for(u=0; u<par_class->hashsize; u++) { + tmp=par_class->props[u]; + + /* Walk through the list of properties at each hash location */ + while(tmp!=NULL) { + /* Make a copy of the class's property */ + if((pcopy=H5P_dup_prop(tmp))==NULL) + HGOTO_ERROR (H5E_PLIST, H5E_CANTCOPY, NULL,"Can't copy property"); + + /* Insert the initialized property into the property list */ + if(H5P_add_prop(pclass->props,pclass->hashsize,pcopy)<0) + HGOTO_ERROR (H5E_PLIST, H5E_CANTINSERT, NULL,"Can't insert property into class"); + + /* Increment property count for class */ + pclass->nprops++; + + /* Go to next registered property in class */ + tmp=tmp->next; + } /* end while */ + } /* end for */ + } /* end if */ + } /* end if */ + /* Set return value */ ret_value=pclass; @@ -6726,39 +6755,43 @@ done: NAME H5P_isa_class_real PURPOSE - Internal routine to query whether a property list is a certain class + Internal routine to query whether a property class is the same as another + class. USAGE - htri_t H5P_isa_class_real(plist, pclass) - H5P_genplist_t *plist; IN: Property list to check - H5P_genclass_t *pclass; IN: Property class to compare with + htri_t H5P_isa_class_real(pclass1, pclass2) + H5P_genclass_t *pclass1; IN: Property class to check + H5P_genclass_t *pclass2; IN: Property class to compare with RETURNS Success: TRUE (1) or FALSE (0) Failure: negative value DESCRIPTION - This routine queries whether a property list is a member of the property - list class. + This routine queries whether a property class is the same as another class, + and walks up the hierarchy of derived classes, checking if the first class + is derived from the second class also. GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS - What about returning a value indicating that the property class is further - up the class hierarchy? EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ -static htri_t H5P_isa_class_real(H5P_genplist_t *plist, H5P_genclass_t *pclass) +static htri_t H5P_isa_class_real(H5P_genclass_t *pclass1, H5P_genclass_t *pclass2) { htri_t ret_value=FAIL; FUNC_ENTER (H5P_isa_class_real, FAIL); - assert(plist); - assert(pclass); + assert(pclass1); + assert(pclass2); /* Compare property classes */ - if(H5P_cmp_class(plist->pclass,pclass)==0) { + if(H5P_cmp_class(pclass1,pclass2)==0) { HGOTO_DONE(TRUE); } else { - HGOTO_DONE(FALSE); + /* Check if the class is derived, and walk up the chain, if so */ + if(pclass1->parent!=NULL) + ret_value=H5P_isa_class_real(pclass1->parent,pclass2); + else + HGOTO_DONE(FALSE); } /* end else */ done: @@ -6809,7 +6842,7 @@ htri_t H5P_isa_class(hid_t plist_id, hid_t pclass_id) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property class"); /* Compare the property list's class against the other class */ - if ((ret_value = H5P_isa_class_real(plist, pclass))<0) + if ((ret_value = H5P_isa_class_real(plist->pclass, pclass))<0) HGOTO_ERROR(H5E_PLIST, H5E_CANTREGISTER, FAIL, "unable to compare property list classes"); done: |