From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:41485) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1S6PYT-0006I3-Pd for qemu-devel@nongnu.org; Sat, 10 Mar 2012 11:54:07 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1S6PYQ-0001OG-Gq for qemu-devel@nongnu.org; Sat, 10 Mar 2012 11:54:05 -0500 Received: from cantor2.suse.de ([195.135.220.15]:42615 helo=mx2.suse.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1S6PYQ-0001O5-6r for qemu-devel@nongnu.org; Sat, 10 Mar 2012 11:54:02 -0500 From: =?UTF-8?q?Andreas=20F=C3=A4rber?= Date: Sat, 10 Mar 2012 17:53:37 +0100 Message-Id: <1331398436-20761-2-git-send-email-afaerber@suse.de> In-Reply-To: <1331398436-20761-1-git-send-email-afaerber@suse.de> References: <1330893156-26569-1-git-send-email-afaerber@suse.de> <1331398436-20761-1-git-send-email-afaerber@suse.de> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: [Qemu-devel] [PATCH v2 RESEND 01/20] qom: Introduce object_class_get_list() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Andreas=20F=C3=A4rber?= , Anthony Liguori This function allows to obtain a singly-linked list of classes, which can be sorted by the caller. Signed-off-by: Andreas F=C3=A4rber Cc: Anthony Liguori --- include/qemu/object.h | 11 +++++++++++ qom/object.c | 17 +++++++++++++++++ 2 files changed, 28 insertions(+), 0 deletions(-) diff --git a/include/qemu/object.h b/include/qemu/object.h index ec2d294..e8fc126 100644 --- a/include/qemu/object.h +++ b/include/qemu/object.h @@ -560,6 +560,17 @@ ObjectClass *object_class_by_name(const char *typena= me); void object_class_foreach(void (*fn)(ObjectClass *klass, void *opaque), const char *implements_type, bool include_abst= ract, void *opaque); + +/** + * object_class_get_list: + * @implements_type: The type to filter for, including its derivatives. + * @include_abstract: Whether to include abstract classes. + * + * Returns: A singly-linked list of the classes in reverse hashtable ord= er. + */ +GSList *object_class_get_list(const char *implements_type, + bool include_abstract); + /** * object_ref: * @obj: the object diff --git a/qom/object.c b/qom/object.c index aa037d2..eef0b22 100644 --- a/qom/object.c +++ b/qom/object.c @@ -572,6 +572,23 @@ void object_class_foreach(void (*fn)(ObjectClass *kl= ass, void *opaque), g_hash_table_foreach(type_table_get(), object_class_foreach_tramp, &= data); } =20 +static void object_class_get_list_tramp(ObjectClass *klass, void *opaque= ) +{ + GSList **list =3D opaque; + + *list =3D g_slist_prepend(*list, klass); +} + +GSList *object_class_get_list(const char *implements_type, + bool include_abstract) +{ + GSList *list =3D NULL; + + object_class_foreach(object_class_get_list_tramp, + implements_type, include_abstract, &list); + return list; +} + void object_ref(Object *obj) { obj->ref++; --=20 1.7.7