summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/H5P.c190
-rw-r--r--src/H5Pprivate.h1
-rw-r--r--src/H5Ppublic.h10
3 files changed, 178 insertions, 23 deletions
diff --git a/src/H5P.c b/src/H5P.c
index ba3162e..d9a55d3 100644
--- a/src/H5P.c
+++ b/src/H5P.c
@@ -4012,7 +4012,7 @@ done:
Internal routine to create a new property
USAGE
H5P_genprop_t *H5P_create_prop(name,size,def_value,prp_create,prp_set,
- prp_get,prp_close)
+ prp_get,prp_delete,prp_close)
const char *name; IN: Name of property to register
size_t size; IN: Size of property in bytes
void *def_value; IN: Pointer to buffer containing default value
@@ -4021,6 +4021,7 @@ done:
creation callback
H5P_prp_set_func_t prp_set; IN: Function pointer to property set callback
H5P_prp_get_func_t prp_get; IN: Function pointer to property get callback
+ H5P_prp_delete_func_t prp_delete; IN: Function pointer to property delete callback
H5P_prp_close_func_t prp_close; IN: Function pointer to property close
callback
RETURNS
@@ -4036,7 +4037,8 @@ done:
static H5P_genprop_t *
H5P_create_prop(const char *name, size_t size, void *def_value, void *value,
H5P_prp_create_func_t prp_create, H5P_prp_set_func_t prp_set,
- H5P_prp_get_func_t prp_get, H5P_prp_close_func_t prp_close)
+ H5P_prp_get_func_t prp_get, H5P_prp_delete_func_t prp_delete,
+ H5P_prp_close_func_t prp_close)
{
H5P_genprop_t *prop=NULL; /* Pointer to new property copied */
H5P_genprop_t *ret_value=NULL; /* Return value */
@@ -4044,7 +4046,7 @@ H5P_create_prop(const char *name, size_t size, void *def_value, void *value,
FUNC_ENTER (H5P_create_prop, NULL);
assert(name);
- assert((size>0 && def_value!=NULL) || (size==0));
+ assert((size>0 && (def_value!=NULL || value!=NULL)) || (size==0));
/* Allocate the new property */
if (NULL==(prop = H5MM_malloc (sizeof(H5P_genprop_t))))
@@ -4054,6 +4056,7 @@ H5P_create_prop(const char *name, size_t size, void *def_value, void *value,
prop->xor_val = H5P_xor_name(name); /* Generate the XOR'd value for the name */
prop->name = HDstrdup(name); /* Duplicate name */
prop->size=size;
+
/* Duplicate value, if it exists */
if(value!=NULL) {
if (NULL==(prop->value = H5MM_malloc (prop->size)))
@@ -4063,7 +4066,6 @@ H5P_create_prop(const char *name, size_t size, void *def_value, void *value,
else
prop->value=NULL;
-
/* Duplicate default value, if it exists */
if(def_value!=NULL) {
if (NULL==(prop->def_value = H5MM_malloc (prop->size)))
@@ -4077,6 +4079,7 @@ H5P_create_prop(const char *name, size_t size, void *def_value, void *value,
prop->create=prp_create;
prop->set=prp_set;
prop->get=prp_get;
+ prop->delete=prp_delete;
prop->close=prp_close;
/* Reset the link to the next property */
@@ -4284,7 +4287,7 @@ H5P_free_all_prop(H5P_genprop_t *hash[], uintn hashsize, uintn make_cb)
/* Call the close callback and ignore the return value, there's nothing we can do about it */
if(make_cb && tprop->close!=NULL)
- (tprop->close)(tprop->name,&(tprop->value));
+ (tprop->close)(tprop->name,tprop->value);
/* Free the property, ignoring return value, nothing we can do */
H5P_free_prop(tprop);
@@ -4630,7 +4633,7 @@ static H5P_genplist_t *H5P_create_list(H5P_genclass_t *pclass)
/* Call property creation callback, if it exists */
if(pcopy->create) {
- if((pcopy->create)(pcopy->name,&(pcopy->value))<0) {
+ if((pcopy->create)(pcopy->name,pcopy->value)<0) {
H5P_free_prop(pcopy);
HGOTO_ERROR (H5E_PLIST, H5E_CANTINIT, NULL,"Can't initialize property");
} /* end if */
@@ -4639,6 +4642,9 @@ static H5P_genplist_t *H5P_create_list(H5P_genclass_t *pclass)
/* Insert the initialized property into the property list */
if(H5P_add_prop(plist->props,tclass->hashsize,pcopy)<0)
HGOTO_ERROR (H5E_PLIST, H5E_CANTINSERT, NULL,"Can't insert property into class");
+
+ /* Increment the number of properties in list */
+ plist->nprops++;
} /* end if */
/* Go to next registered property in class */
@@ -4756,6 +4762,7 @@ done:
creation callback
H5P_prp_set_func_t prp_set; IN: Function pointer to property set callback
H5P_prp_get_func_t prp_get; IN: Function pointer to property get callback
+ H5P_prp_delete_func_t prp_delete; IN: Function pointer to property delete callback
H5P_prp_close_func_t prp_close; IN: Function pointer to property close
callback
RETURNS
@@ -4815,6 +4822,19 @@ done:
negative value, the property value is returned and the property list get
routine returns an error value.
+ The 'delete' callback is called when a property is deleted from a
+ property list. H5P_prp_del_func_t is defined as:
+ typedef herr_t (*H5P_prp_del_func_t)(hid_t prop_id, const char *name,
+ void *value);
+ where the parameters to the callback function are:
+ hid_t prop_id; IN: The ID of the property list the property is deleted from.
+ const char *name; IN: The name of the property being deleted.
+ void *value; IN/OUT: The value of the property being deleted.
+ The 'delete' routine may modify the value passed in, but the value is not
+ used by the library when the 'delete' routine returns. If the
+ 'delete' routine returns a negative value, the property list deletion
+ routine returns an error value but the property is still deleted.
+
The 'close' callback is called when a property list with this
property is being destroyed. H5P_prp_close_func_t is defined as:
typedef herr_t (*H5P_prp_close_func_t)(const char *name, void *value);
@@ -4847,7 +4867,7 @@ done:
--------------------------------------------------------------------------*/
static herr_t H5P_register(H5P_genclass_t *pclass, const char *name, size_t size,
void *def_value, H5P_prp_create_func_t prp_create, H5P_prp_set_func_t prp_set,
- H5P_prp_get_func_t prp_get, H5P_prp_close_func_t prp_close)
+ H5P_prp_get_func_t prp_get, H5P_prp_delete_func_t prp_delete, H5P_prp_close_func_t prp_close)
{
H5P_genclass_t *new_class; /* New class pointer */
H5P_genprop_t *tmp_prop; /* Temporary property pointer */
@@ -4897,7 +4917,7 @@ static herr_t H5P_register(H5P_genclass_t *pclass, const char *name, size_t size
} /* end if */
/* Create property object from parameters */
- if((new_prop=H5P_create_prop(name,size,def_value,NULL,prp_create,prp_set,prp_get,prp_close))==NULL)
+ if((new_prop=H5P_create_prop(name,size,def_value,NULL,prp_create,prp_set,prp_get,prp_delete,prp_close))==NULL)
HGOTO_ERROR (H5E_PLIST, H5E_CANTCREATE, FAIL,"Can't create property");
/* Insert property into property list class */
@@ -4942,6 +4962,7 @@ done:
creation callback
H5P_prp_set_func_t prp_set; IN: Function pointer to property set callback
H5P_prp_get_func_t prp_get; IN: Function pointer to property get callback
+ H5P_prp_delete_func_t prp_delete; IN: Function pointer to property delete callback
H5P_prp_close_func_t prp_close; IN: Function pointer to property close
callback
RETURNS
@@ -5001,6 +5022,19 @@ done:
negative value, the property value is returned and the property list get
routine returns an error value.
+ The 'delete' callback is called when a property is deleted from a
+ property list. H5P_prp_del_func_t is defined as:
+ typedef herr_t (*H5P_prp_del_func_t)(hid_t prop_id, const char *name,
+ void *value);
+ where the parameters to the callback function are:
+ hid_t prop_id; IN: The ID of the property list the property is deleted from.
+ const char *name; IN: The name of the property being deleted.
+ void *value; IN/OUT: The value of the property being deleted.
+ The 'delete' routine may modify the value passed in, but the value is not
+ used by the library when the 'delete' routine returns. If the
+ 'delete' routine returns a negative value, the property list deletion
+ routine returns an error value but the property is still deleted.
+
The 'close' callback is called when a property list with this
property is being destroyed. H5P_prp_close_func_t is defined as:
typedef herr_t (*H5P_prp_close_func_t)(const char *name, void *value);
@@ -5033,7 +5067,7 @@ done:
--------------------------------------------------------------------------*/
herr_t H5Pregister(hid_t cls_id, const char *name, size_t size, void *def_value,
H5P_prp_create_func_t prp_create, H5P_prp_set_func_t prp_set,
- H5P_prp_get_func_t prp_get, H5P_prp_close_func_t prp_close)
+ H5P_prp_get_func_t prp_get, H5P_prp_delete_func_t prp_delete, H5P_prp_close_func_t prp_close)
{
H5P_genclass_t *pclass; /* Property list class to modify */
herr_t ret_value=FAIL; /* return value */
@@ -5049,7 +5083,7 @@ herr_t H5Pregister(hid_t cls_id, const char *name, size_t size, void *def_value,
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "properties >0 size must have default");
/* Create the new property list class */
- if ((ret_value=H5P_register(pclass,name,size,def_value,prp_create,prp_set,prp_get,prp_close))<0)
+ if ((ret_value=H5P_register(pclass,name,size,def_value,prp_create,prp_set,prp_get,prp_delete,prp_close))<0)
HGOTO_ERROR(H5E_PLIST, H5E_CANTREGISTER, FAIL, "unable to register property in class");
done:
@@ -5070,6 +5104,7 @@ done:
void *value; IN: Pointer to the value for the property
H5P_prp_set_func_t prp_set; IN: Function pointer to property set callback
H5P_prp_get_func_t prp_get; IN: Function pointer to property get callback
+ H5P_prp_delete_func_t prp_delete; IN: Function pointer to property delete callback
H5P_prp_close_func_t prp_close; IN: Function pointer to property close
callback
RETURNS
@@ -5114,6 +5149,19 @@ done:
negative value, the property value is returned and the property list get
routine returns an error value.
+ The 'delete' callback is called when a property is deleted from a
+ property list. H5P_prp_del_func_t is defined as:
+ typedef herr_t (*H5P_prp_del_func_t)(hid_t prop_id, const char *name,
+ void *value);
+ where the parameters to the callback function are:
+ hid_t prop_id; IN: The ID of the property list the property is deleted from.
+ const char *name; IN: The name of the property being deleted.
+ void *value; IN/OUT: The value of the property being deleted.
+ The 'delete' routine may modify the value passed in, but the value is not
+ used by the library when the 'delete' routine returns. If the
+ 'delete' routine returns a negative value, the property list deletion
+ routine returns an error value but the property is still deleted.
+
The 'close' callback is called when a property list with this
property is being destroyed. H5P_prp_close_func_t is defined as:
typedef herr_t (*H5P_prp_close_func_t)(const char *name,
@@ -5151,7 +5199,7 @@ done:
--------------------------------------------------------------------------*/
static herr_t H5P_insert(H5P_genplist_t *plist, const char *name, size_t size,
void *value, H5P_prp_set_func_t prp_set, H5P_prp_get_func_t prp_get,
- H5P_prp_close_func_t prp_close)
+ H5P_prp_delete_func_t prp_delete, H5P_prp_close_func_t prp_close)
{
H5P_genprop_t *new_prop=NULL; /* Temporary property pointer */
herr_t ret_value=FAIL; /* return value */
@@ -5167,7 +5215,7 @@ static herr_t H5P_insert(H5P_genplist_t *plist, const char *name, size_t size,
HGOTO_ERROR(H5E_PLIST, H5E_EXISTS, FAIL, "property already exists");
/* Create property object from parameters */
- if((new_prop=H5P_create_prop(name,size,NULL,value,NULL,prp_set,prp_get,prp_close))==NULL)
+ if((new_prop=H5P_create_prop(name,size,NULL,value,NULL,prp_set,prp_get,prp_delete,prp_close))==NULL)
HGOTO_ERROR (H5E_PLIST, H5E_CANTCREATE, FAIL,"Can't create property");
/* Insert property into property list class */
@@ -5209,6 +5257,7 @@ done:
void *value; IN: Pointer to the value for the property
H5P_prp_set_func_t prp_set; IN: Function pointer to property set callback
H5P_prp_get_func_t prp_get; IN: Function pointer to property get callback
+ H5P_prp_delete_func_t prp_delete; IN: Function pointer to property delete callback
H5P_prp_close_func_t prp_close; IN: Function pointer to property close
callback
RETURNS
@@ -5253,6 +5302,19 @@ done:
negative value, the property value is returned and the property list get
routine returns an error value.
+ The 'delete' callback is called when a property is deleted from a
+ property list. H5P_prp_del_func_t is defined as:
+ typedef herr_t (*H5P_prp_del_func_t)(hid_t prop_id, const char *name,
+ void *value);
+ where the parameters to the callback function are:
+ hid_t prop_id; IN: The ID of the property list the property is deleted from.
+ const char *name; IN: The name of the property being deleted.
+ void *value; IN/OUT: The value of the property being deleted.
+ The 'delete' routine may modify the value passed in, but the value is not
+ used by the library when the 'delete' routine returns. If the
+ 'delete' routine returns a negative value, the property list deletion
+ routine returns an error value but the property is still deleted.
+
The 'close' callback is called when a property list with this
property is being destroyed. H5P_prp_close_func_t is defined as:
typedef herr_t (*H5P_prp_close_func_t)(const char *name, void *value);
@@ -5289,7 +5351,7 @@ done:
--------------------------------------------------------------------------*/
herr_t H5Pinsert(hid_t plist_id, const char *name, size_t size, void *value,
H5P_prp_set_func_t prp_set, H5P_prp_get_func_t prp_get,
- H5P_prp_close_func_t prp_close)
+ H5P_prp_delete_func_t prp_delete, H5P_prp_close_func_t prp_close)
{
H5P_genplist_t *plist; /* Property list to modify */
herr_t ret_value=FAIL; /* return value */
@@ -5305,7 +5367,7 @@ herr_t H5Pinsert(hid_t plist_id, const char *name, size_t size, void *value,
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "properties >0 size must have default");
/* Create the new property list class */
- if ((ret_value=H5P_insert(plist,name,size,value,prp_set,prp_get,prp_close))<0)
+ if ((ret_value=H5P_insert(plist,name,size,value,prp_set,prp_get,prp_delete,prp_close))<0)
HGOTO_ERROR(H5E_PLIST, H5E_CANTREGISTER, FAIL, "unable to register property in plist");
done:
@@ -5374,7 +5436,7 @@ static herr_t H5P_set(hid_t plist_id, const char *name, void *value)
/* Make a copy of the current value, in case the callback fails */
if (NULL==(tmp_value=H5MM_malloc(prop->size)))
HRETURN_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed temporary property value");
- HDmemcpy(tmp_value,prop->value,prop->size);
+ HDmemcpy(tmp_value,value,prop->size);
/* Call user's callback */
if((*(prop->set))(plist_id,name,tmp_value)<0)
@@ -6281,6 +6343,96 @@ done:
/*--------------------------------------------------------------------------
NAME
+ H5P_isa_class
+ PURPOSE
+ Internal routine to query whether a property list is a certain class
+ USAGE
+ htri_t H5P_isa_class(plist, pclass)
+ H5P_genplist_t *plist; IN: Property list to check
+ H5P_genclass_t *pclass; 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.
+
+ 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(H5P_genplist_t *plist, H5P_genclass_t *pclass)
+{
+ htri_t ret_value=FAIL;
+
+ FUNC_ENTER (H5P_isa_class, FAIL);
+
+ assert(plist);
+ assert(pclass);
+
+ /* Compare property classes */
+ if(H5P_cmp_class(plist->pclass,pclass)==0) {
+ HGOTO_DONE(TRUE);
+ } else {
+ HGOTO_DONE(FALSE);
+ } /* end else */
+
+done:
+ FUNC_LEAVE (ret_value);
+} /* H5P_isa_class() */
+
+
+/*--------------------------------------------------------------------------
+ NAME
+ H5Pisa_class
+ PURPOSE
+ Routine to query whether a property list is a certain class
+ USAGE
+ hid_t H5Pisa_class(plist_id, pclass_id)
+ hid_t plist_id; IN: Property list to query
+ hid_t pclass_id; IN: Property class to query
+ RETURNS
+ Success: TRUE (1) or FALSE (0)
+ Failure: negative
+ DESCRIPTION
+ This routine queries whether a property list is a member of the property
+ list class.
+
+ GLOBAL VARIABLES
+ What about returning a value indicating that the property class is further
+ up the class hierarchy?
+ COMMENTS, BUGS, ASSUMPTIONS
+ EXAMPLES
+ REVISION LOG
+--------------------------------------------------------------------------*/
+hid_t H5Pisa_class(hid_t plist_id, hid_t pclass_id)
+{
+ H5P_genplist_t *plist; /* Property list to query */
+ H5P_genclass_t *pclass=NULL; /* Property list class */
+ htri_t ret_value=FAIL; /* return value */
+
+ FUNC_ENTER (H5Pget_class, FAIL);
+
+ /* Check arguments. */
+ if (H5I_GENPROP_LST != H5I_get_type(plist_id) || NULL == (plist = H5I_object(plist_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list");
+ if (H5I_GENPROP_CLS != H5I_get_type(pclass_id) || NULL == (pclass = H5I_object(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(plist, pclass))<0)
+ HGOTO_ERROR(H5E_PLIST, H5E_CANTREGISTER, FAIL, "unable to compare property list classes");
+
+done:
+ FUNC_LEAVE (ret_value);
+} /* H5Pisa_class() */
+
+
+/*--------------------------------------------------------------------------
+ NAME
H5P_iterate_props
PURPOSE
Internal routine to iterate over a hashtable of properties
@@ -6761,7 +6913,7 @@ done:
EXAMPLES
REVISION LOG
--------------------------------------------------------------------------*/
-static herr_t H5P_remove(H5P_genplist_t *plist, const char *name)
+static herr_t H5P_remove(hid_t plist_id, H5P_genplist_t *plist, const char *name)
{
H5P_genprop_t *prop; /* Temporary property pointer */
H5P_genprop_t *tprop, *prev;/* Temporary pointer to properties */
@@ -6778,9 +6930,9 @@ static herr_t H5P_remove(H5P_genplist_t *plist, const char *name)
HGOTO_ERROR(H5E_PLIST, H5E_NOTFOUND, FAIL, "property doesn't exist");
/* Pass value to 'close' callback, if it exists */
- if(prop->close!=NULL) {
+ if(prop->delete!=NULL) {
/* Call user's callback */
- if((*(prop->close))(name,prop->value)<0)
+ if((*(prop->delete))(plist_id,name,prop->value)<0)
HRETURN_ERROR(H5E_PLIST, H5E_CANTINIT, FAIL, "can't close property value");
} /* end if */
@@ -6864,7 +7016,7 @@ herr_t H5Premove(hid_t plist_id, const char *name)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid property name");
/* Create the new property list class */
- if ((ret_value=H5P_remove(plist,name))<0)
+ if ((ret_value=H5P_remove(plist_id,plist,name))<0)
HGOTO_ERROR(H5E_PLIST, H5E_CANTREGISTER, FAIL, "unable to remove property");
done:
diff --git a/src/H5Pprivate.h b/src/H5Pprivate.h
index e46dad2..7bd10c0 100644
--- a/src/H5Pprivate.h
+++ b/src/H5Pprivate.h
@@ -49,6 +49,7 @@ typedef struct H5P_genprop_tag {
void *def_value; /* Pointer to default value to pass along to create callback */
H5P_prp_set_func_t set; /* Function to call when a property value is set */
H5P_prp_get_func_t get; /* Function to call when a property value is retrieved */
+ H5P_prp_delete_func_t delete; /* Function to call when a property is deleted */
H5P_prp_close_func_t close; /* Function to call when a property is closed */
struct H5P_genprop_tag *next; /* Pointer to the next property in this list */
diff --git a/src/H5Ppublic.h b/src/H5Ppublic.h
index e03d1bf..9b5b3c0 100644
--- a/src/H5Ppublic.h
+++ b/src/H5Ppublic.h
@@ -52,9 +52,10 @@ typedef herr_t (*H5P_cls_create_func_t)(hid_t prop_id, void *create_data);
typedef herr_t (*H5P_cls_close_func_t)(hid_t prop_id, void *close_data);
/* Define property list callback function pointer types */
-typedef herr_t (*H5P_prp_create_func_t)(const char *name, void **def_value);
-typedef herr_t (*H5P_prp_set_func_t)(hid_t prop_id, const char *name, void **value);
+typedef herr_t (*H5P_prp_create_func_t)(const char *name, void *def_value);
+typedef herr_t (*H5P_prp_set_func_t)(hid_t prop_id, const char *name, void *value);
typedef herr_t (*H5P_prp_get_func_t)(hid_t prop_id, const char *name, void *value);
+typedef herr_t (*H5P_prp_delete_func_t)(hid_t prop_id, const char *name, void *value);
typedef herr_t (*H5P_prp_close_func_t)(const char *name, void *value);
/* Define property list iteration function type */
@@ -95,10 +96,10 @@ __DLL__ hid_t H5Pcreate_list(hid_t cls_id);
__DLL__ herr_t H5Pregister(hid_t cls_id, const char *name, size_t size,
void *def_value, H5P_prp_create_func_t prp_create,
H5P_prp_set_func_t prp_set, H5P_prp_get_func_t prp_get,
- H5P_prp_close_func_t prp_close);
+ H5P_prp_delete_func_t prp_del, H5P_prp_close_func_t prp_close);
__DLL__ herr_t H5Pinsert(hid_t plist_id, const char *name, size_t size,
void *value, H5P_prp_set_func_t prp_set, H5P_prp_get_func_t prp_get,
- H5P_prp_close_func_t prp_close);
+ H5P_prp_delete_func_t prp_delete, H5P_prp_close_func_t prp_close);
__DLL__ herr_t H5Pset(hid_t plist_id, const char *name, void *value);
__DLL__ htri_t H5Pexist(hid_t plist_id, const char *name);
__DLL__ herr_t H5Pget_size(hid_t id, const char *name, size_t *size);
@@ -107,6 +108,7 @@ __DLL__ hid_t H5Pget_class_new(hid_t plist_id);
__DLL__ hid_t H5Pget_class_parent(hid_t pclass_id);
__DLL__ herr_t H5Pget(hid_t plist_id, const char *name, void * value);
__DLL__ htri_t H5Pequal(hid_t id1, hid_t id2);
+__DLL__ hid_t H5Pisa_class(hid_t plist_id, hid_t pclass_id);
__DLL__ int H5Piterate(hid_t id, int *idx, H5P_iterate_t iter_func,
void *iter_data);
__DLL__ herr_t H5Premove(hid_t plist_id, const char *name);