From 418ba9e5d6849ef2e8512d8853628ce4bf37937a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20F=C3=A4rber?= Date: Sat, 25 Feb 2012 23:07:34 +0100 Subject: qom: Introduce object_class_get_list() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This function allows to obtain a singly-linked list of classes, which can be sorted by the caller. Signed-off-by: Andreas Färber Cc: Anthony Liguori Signed-off-by: Anthony Liguori --- qom/object.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'qom') diff --git a/qom/object.c b/qom/object.c index 664708d..9cd9506 100644 --- a/qom/object.c +++ b/qom/object.c @@ -584,6 +584,23 @@ void object_class_foreach(void (*fn)(ObjectClass *klass, void *opaque), g_hash_table_foreach(type_table_get(), object_class_foreach_tramp, &data); } +static void object_class_get_list_tramp(ObjectClass *klass, void *opaque) +{ + GSList **list = opaque; + + *list = g_slist_prepend(*list, klass); +} + +GSList *object_class_get_list(const char *implements_type, + bool include_abstract) +{ + GSList *list = NULL; + + object_class_foreach(object_class_get_list_tramp, + implements_type, include_abstract, &list); + return list; +} + void object_ref(Object *obj) { obj->ref++; -- cgit v1.1