diff options
author | Dmitri Pal <dpal@redhat.com> | 2010-07-23 14:33:56 -0400 |
---|---|---|
committer | Stephen Gallagher <sgallagh@redhat.com> | 2010-09-22 14:57:53 -0400 |
commit | 2893de11973c4912f4c2a3d40f09ef0823a3f091 (patch) | |
tree | 155e6f883f8f6e54779e24d13563b8ef02e15307 /collection/collection.h | |
parent | 30eeb8e833570c9117f298005d33e6e238561237 (diff) | |
download | ding-libs-2893de11973c4912f4c2a3d40f09ef0823a3f091.tar.gz ding-libs-2893de11973c4912f4c2a3d40f09ef0823a3f091.tar.xz ding-libs-2893de11973c4912f4c2a3d40f09ef0823a3f091.zip |
Allow destroying collection with a callback
Addresses ticket #572
Bumps the library and interface version.
Updates the docs.
[COLLECTION] Changed callback signature
Diffstat (limited to 'collection/collection.h')
-rw-r--r-- | collection/collection.h | 63 |
1 files changed, 58 insertions, 5 deletions
diff --git a/collection/collection.h b/collection/collection.h index b656ebb..2ec81bd 100644 --- a/collection/collection.h +++ b/collection/collection.h @@ -484,6 +484,60 @@ int col_create_collection(struct collection_item **ci, void col_destroy_collection(struct collection_item *ci); /** + * @brief Cleanup Callback + * + * Signature of the callback that needs to be used when + * the collection is destroyed and a special cleanup operation + * is required for items in the collection. + * + * @param[in] property The name of the property will + * be passed in this parameter. + * @param[in] property_len Length of the property name + * will be passed in this parameter. + * @param[in] type Type of the data will be passed + * in this parameter. + * @param[in] data Pointer to the data will be passed + * in this parameter. + * @param[in] length Length of data will be passed in + * this parameter. + * @param[in] custom_data Custom data will be passed in + * this parameter. + * @return No return value. + */ + +typedef void (*col_item_cleanup_fn)(const char *property, + int property_len, + int type, + void *data, + int length, + void *custom_data); + +/** + * @brief Destroy a collection with callback + * + * Execute a provided callback for each item + * in the collection or subcollection immediately + * before freeing item. The callback is executed for each + * element including the collection header. + * It is the responsibility of the callback implementor + * to properly handle gifferent collection elements + * depending upon whether it is a header, reference to + * an embedded or external collection or a normal data + * element. + * + * The function will destroy a collection. + * + * @param[in] ci Collection object. + * @param[in] cb Cleanup callback. + * @param[in] custom_data Application data passed into + * the cleanup callback. + * + */ +void col_destroy_collection_with_cb(struct collection_item *ci, + col_item_cleanup_fn cb, + void *custom_data); + +/** * @brief Copy item callback. * * Callback is used by the @@ -618,7 +672,7 @@ int col_add_collection_to_collection(struct collection_item *ci, * in this parameter. * @param[in] length Length of data will be passed in * this parameter. - * @param[in] custom_dat Custom data will be passed in + * @param[in] custom_data Custom data will be passed in * this parameter. * @param[out] stop Pointer to a variable where the handler * can put nonzero to stop traversing @@ -633,10 +687,9 @@ typedef int (*col_item_fn)(const char *property, int type, void *data, int length, - void *custom_dat, + void *custom_data, int *stop); - /** * @brief Traverse collection * @@ -2366,9 +2419,9 @@ int col_get_item_type(struct collection_item *ci); int col_get_item_length(struct collection_item *ci); /** - * @brief Get property value from the item. + * @brief Get value from the item. * - * Get property value from the item. + * Get value from the item. * * @param[in] ci Item to get value from. * If item is invalid the function |