From c368e32f0dd4a562af5a50c1c97cdb7dec85b43b Mon Sep 17 00:00:00 2001 From: Adam Sutton Date: Wed, 14 Aug 2013 16:10:17 +0100 Subject: [PATCH] idnode: add new deletion method to allow generic api method --- src/idnode.c | 17 +++++++++++++++++ src/idnode.h | 2 ++ 2 files changed, 19 insertions(+) diff --git a/src/idnode.c b/src/idnode.c index a0ab2307..59fc7d57 100644 --- a/src/idnode.c +++ b/src/idnode.c @@ -183,6 +183,23 @@ idnode_unlink(idnode_t *in) idnode_notify(in, NULL, 0, 1); } +/** + * + */ +void +idnode_delete(idnode_t *in) +{ + lock_assert(&global_lock); + const idclass_t *idc = in->in_class; + while (idc) { + if (idc->ic_delete) { + idc->ic_delete(in); + break; + } + idc = idc->ic_super; + } +} + /* ************************************************************************** * Info * *************************************************************************/ diff --git a/src/idnode.h b/src/idnode.h index 9730fbac..b90ada98 100644 --- a/src/idnode.h +++ b/src/idnode.h @@ -52,6 +52,7 @@ typedef struct idclass { idnode_set_t *(*ic_get_childs)(idnode_t *self); const char *(*ic_get_title) (idnode_t *self); void (*ic_save) (idnode_t *self); + void (*ic_delete) (idnode_t *self); } idclass_t; /* @@ -114,6 +115,7 @@ idnode_set_t *idnode_get_childs (idnode_t *in); const char *idnode_get_title (idnode_t *in); int idnode_is_leaf (idnode_t *in); int idnode_is_instance (idnode_t *in, const idclass_t *idc); +void idnode_delete (idnode_t *in); void *idnode_find (const char *uuid, const idclass_t *idc); idnode_set_t *idnode_find_all(const idclass_t *idc);