[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH 07/22] qom: allow object_class_foreach to take a
From: |
Andreas Färber |
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 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:9.0) Gecko/20111220 Thunderbird/9.0 |
Am 01.02.2012 20:50, schrieb Anthony Liguori:
> Signed-off-by: Anthony Liguori <address@hidden>
Reviewed-by: Andreas Färber <address@hidden>
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
- [Qemu-devel] [PATCH 15/22] qdev: split out UI portions into a new function, (continued)
- [Qemu-devel] [PATCH 15/22] qdev: split out UI portions into a new function, Anthony Liguori, 2012/02/01
- [Qemu-devel] [PATCH 12/22] qom: add new command to search for types, Anthony Liguori, 2012/02/01
- [Qemu-devel] [PATCH 17/22] qom: move properties from qdev to object, Anthony Liguori, 2012/02/01
- [Qemu-devel] [PATCH 20/22] info qdm: do not require a parent_bus to be set, Anthony Liguori, 2012/02/01
- [Qemu-devel] [PATCH 21/22] object: sure up reference counting, Anthony Liguori, 2012/02/01
- [Qemu-devel] [PATCH 09/22] qdev: register all types natively through QEMU Object Model, Anthony Liguori, 2012/02/01
- [Qemu-devel] [PATCH 22/22] container: make a decendent of Object, Anthony Liguori, 2012/02/01
- [Qemu-devel] [PATCH 19/22] qdev: implement cleanup logic in finalize, Anthony Liguori, 2012/02/01
- [Qemu-devel] [PATCH 07/22] qom: allow object_class_foreach to take additional parameters to refine search, Anthony Liguori, 2012/02/01
- Re: [Qemu-devel] [PATCH 07/22] qom: allow object_class_foreach to take additional parameters to refine search,
Andreas Färber <=
- [Qemu-devel] [PATCH 14/22] qdev: refactor away qdev_create_from_info, Anthony Liguori, 2012/02/01
- [Qemu-devel] [PATCH 13/22] qdev: split out common init to instance_init, Anthony Liguori, 2012/02/01
- [Qemu-devel] [PATCH 18/22] qom: accept any compatible type when setting a link property, Anthony Liguori, 2012/02/01
- Re: [Qemu-devel] [PATCH 00/22] qom: use Type system to register all devices (v2), Anthony Liguori, 2012/02/03