All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Andreas Färber" <afaerber@suse.de>
To: Anthony Liguori <aliguori@us.ibm.com>
Cc: Paolo Bonzini <pbonzini@redhat.com>,
	qemu-devel@nongnu.org, Peter Maydell <peter.maydell@linaro.org>
Subject: Re: [Qemu-devel] [PATCH 07/22] qom: allow object_class_foreach to take additional parameters to refine search
Date: Wed, 01 Feb 2012 21:58:53 +0100	[thread overview]
Message-ID: <4F29A78D.8040403@suse.de> (raw)
In-Reply-To: <1328125863-6203-8-git-send-email-aliguori@us.ibm.com>

Am 01.02.2012 20:50, schrieb Anthony Liguori:
> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>

Reviewed-by: Andreas Färber <afaerber@suse.de>

Thanks,
Andreas

> ---
>  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);
>  }

-- 
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg

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

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-02-01 19:50 [Qemu-devel] [PATCH 00/22] qom: use Type system to register all devices (v2) Anthony Liguori
2012-02-01 19:50 ` [Qemu-devel] [PATCH 01/22] usb-hid: simplify class initialization a bit Anthony Liguori
2012-02-01 19:50 ` [Qemu-devel] [PATCH 02/22] usb: separate out legacy usb registration from type registration Anthony Liguori
2012-02-01 19:50 ` [Qemu-devel] [PATCH 03/22] qdev: make DeviceInfo private Anthony Liguori
2012-02-01 19:50 ` [Qemu-devel] [PATCH 04/22] qdev: remove info from class Anthony Liguori
2012-02-01 19:50 ` [Qemu-devel] [PATCH 05/22] qdev: allow classes to overload qdev functions Anthony Liguori
2012-02-01 19:50 ` [Qemu-devel] [PATCH 06/22] qdev: refactor device creation to allow bus_info to be set only in class Anthony Liguori
2012-02-01 19:50 ` [Qemu-devel] [PATCH 07/22] qom: allow object_class_foreach to take additional parameters to refine search Anthony Liguori
2012-02-01 20:58   ` Andreas Färber [this message]
2012-02-01 19:50 ` [Qemu-devel] [PATCH 08/22] qdev: kill off DeviceInfo list Anthony Liguori
2012-02-01 19:50 ` [Qemu-devel] [PATCH 09/22] qdev: register all types natively through QEMU Object Model Anthony Liguori
2012-02-02  0:07   ` Andreas Färber
2012-02-01 19:50 ` [Qemu-devel] [PATCH 10/22] qdev: kill off DeviceInfo Anthony Liguori
2012-02-01 19:50 ` [Qemu-devel] [PATCH 11/22] qdev: remove baked in notion of aliases (v2) Anthony Liguori
2012-02-01 19:50 ` [Qemu-devel] [PATCH 12/22] qom: add new command to search for types Anthony Liguori
2012-02-01 19:50 ` [Qemu-devel] [PATCH 13/22] qdev: split out common init to instance_init Anthony Liguori
2012-02-01 19:50 ` [Qemu-devel] [PATCH 14/22] qdev: refactor away qdev_create_from_info Anthony Liguori
2012-02-01 19:50 ` [Qemu-devel] [PATCH 15/22] qdev: split out UI portions into a new function Anthony Liguori
2012-02-01 19:50 ` [Qemu-devel] [PATCH 16/22] qdev: nuke qdev_init_chardev() Anthony Liguori
2012-02-01 19:50 ` [Qemu-devel] [PATCH 17/22] qom: move properties from qdev to object Anthony Liguori
2012-02-01 19:50 ` [Qemu-devel] [PATCH 18/22] qom: accept any compatible type when setting a link property Anthony Liguori
2012-02-01 19:51 ` [Qemu-devel] [PATCH 19/22] qdev: implement cleanup logic in finalize Anthony Liguori
2012-02-01 19:51 ` [Qemu-devel] [PATCH 20/22] info qdm: do not require a parent_bus to be set Anthony Liguori
2012-02-01 19:51 ` [Qemu-devel] [PATCH 21/22] object: sure up reference counting Anthony Liguori
2012-02-01 19:51 ` [Qemu-devel] [PATCH 22/22] container: make a decendent of Object Anthony Liguori
2012-02-03 17:20 ` [Qemu-devel] [PATCH 00/22] qom: use Type system to register all devices (v2) Anthony Liguori

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=4F29A78D.8040403@suse.de \
    --to=afaerber@suse.de \
    --cc=aliguori@us.ibm.com \
    --cc=pbonzini@redhat.com \
    --cc=peter.maydell@linaro.org \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.