idnode: add new deletion method to allow generic api method

This commit is contained in:
Adam Sutton 2013-08-14 16:10:17 +01:00
parent f067952fd5
commit c368e32f0d
2 changed files with 19 additions and 0 deletions

View file

@ -183,6 +183,23 @@ idnode_unlink(idnode_t *in)
idnode_notify(in, NULL, 0, 1); 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 * Info
* *************************************************************************/ * *************************************************************************/

View file

@ -52,6 +52,7 @@ typedef struct idclass {
idnode_set_t *(*ic_get_childs)(idnode_t *self); idnode_set_t *(*ic_get_childs)(idnode_t *self);
const char *(*ic_get_title) (idnode_t *self); const char *(*ic_get_title) (idnode_t *self);
void (*ic_save) (idnode_t *self); void (*ic_save) (idnode_t *self);
void (*ic_delete) (idnode_t *self);
} idclass_t; } idclass_t;
/* /*
@ -114,6 +115,7 @@ idnode_set_t *idnode_get_childs (idnode_t *in);
const char *idnode_get_title (idnode_t *in); const char *idnode_get_title (idnode_t *in);
int idnode_is_leaf (idnode_t *in); int idnode_is_leaf (idnode_t *in);
int idnode_is_instance (idnode_t *in, const idclass_t *idc); 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); void *idnode_find (const char *uuid, const idclass_t *idc);
idnode_set_t *idnode_find_all(const idclass_t *idc); idnode_set_t *idnode_find_all(const idclass_t *idc);