qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Andreas Färber" <afaerber@suse.de>
To: qemu-devel@nongnu.org
Cc: "Anthony Liguori" <aliguori@us.ibm.com>,
	"Andreas Färber" <afaerber@suse.de>
Subject: [Qemu-devel] [PATCH RFC v2 1/8] qom: Allow object_class_foreach() to take additional parameters to refine search
Date: Wed,  1 Feb 2012 13:57:18 +0100	[thread overview]
Message-ID: <1328101045-10717-2-git-send-email-afaerber@suse.de> (raw)
In-Reply-To: <1328101045-10717-1-git-send-email-afaerber@suse.de>

From: Anthony Liguori <aliguori@us.ibm.com>

Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Signed-off-by: Andreas Färber <afaerber@suse.de>
---
 include/qemu/object.h |    1 +
 qom/object.c          |   18 ++++++++++++++++--
 2 files changed, 17 insertions(+), 2 deletions(-)

diff --git a/include/qemu/object.h b/include/qemu/object.h
index ba37850..adbcfb1 100644
--- a/include/qemu/object.h
+++ b/include/qemu/object.h
@@ -431,6 +431,7 @@ const char *object_class_get_name(ObjectClass *klass);
 ObjectClass *object_class_by_name(const char *typename);
 
 void object_class_foreach(void (*fn)(ObjectClass *klass, void *opaque),
+                          const char *implements_type, bool include_abstract,
                           void *opaque);
 
 #endif
diff --git a/qom/object.c b/qom/object.c
index a12895f..3dabb1a 100644
--- a/qom/object.c
+++ b/qom/object.c
@@ -467,6 +467,8 @@ ObjectClass *object_class_by_name(const char *typename)
 typedef struct OCFData
 {
     void (*fn)(ObjectClass *klass, void *opaque);
+    const char *implements_type;
+    bool include_abstract;
     void *opaque;
 } OCFData;
 
@@ -475,16 +477,28 @@ static void object_class_foreach_tramp(gpointer key, gpointer value,
 {
     OCFData *data = opaque;
     TypeImpl *type = value;
+    ObjectClass *k;
 
     type_class_init(type);
+    k = type->class;
 
-    data->fn(value, type->class);
+    if (!data->include_abstract && type->abstract) {
+        return;
+    }
+
+    if (data->implements_type && 
+        !object_class_dynamic_cast(k, data->implements_type)) {
+        return;
+    }
+
+    data->fn(k, data->opaque);
 }
 
 void object_class_foreach(void (*fn)(ObjectClass *klass, void *opaque),
+                          const char *implements_type, bool include_abstract,
                           void *opaque)
 {
-    OCFData data = { fn, opaque };
+    OCFData data = { fn, implements_type, include_abstract, opaque };
 
     g_hash_table_foreach(type_table_get(), object_class_foreach_tramp, &data);
 }
-- 
1.7.7

  reply	other threads:[~2012-02-01 13:00 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-02-01 12:57 [Qemu-devel] [PATCH RFC v2 0/8] Introduce QOM CPU and use for ARM Andreas Färber
2012-02-01 12:57 ` Andreas Färber [this message]
2012-02-01 12:57 ` [Qemu-devel] [PATCH RFC v2 2/8] qom: Register QOM infrastructure early Andreas Färber
2012-02-01 12:57 ` [Qemu-devel] [PATCH RFC v2 3/8] qom: Add QOM support to user emulators Andreas Färber
2012-02-01 12:57 ` [Qemu-devel] [PATCH RFC v2 4/8] qom: Introduce CPU class Andreas Färber
2012-02-01 22:25   ` Peter Maydell
2012-02-01 12:57 ` [Qemu-devel] [PATCH RFC v2 5/8] target-arm: Introduce QOM CPU and use it for CPUID lookup Andreas Färber
2012-02-01 16:16   ` Andreas Färber
2012-02-01 12:57 ` [Qemu-devel] [PATCH RFC v2 6/8] target-arm: Embed CPUARMState in QOM ARMCPU Andreas Färber
2012-02-01 12:57 ` [Qemu-devel] [PATCH RFC v2 7/8] target-arm: Prepare model-specific class_init function Andreas Färber
2012-02-01 12:57 ` [Qemu-devel] [PATCH RFC v2 8/8] target-arm: Move CPU feature flags out of CPUState Andreas Färber

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1328101045-10717-2-git-send-email-afaerber@suse.de \
    --to=afaerber@suse.de \
    --cc=aliguori@us.ibm.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).