* [Qemu-devel] [PATCH v2] qom: Introduce object_class_get_list()
@ 2012-02-25 22:07 Andreas Färber
2012-02-25 22:10 ` Andreas Färber
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: Andreas Färber @ 2012-02-25 22:07 UTC (permalink / raw)
To: qemu-devel; +Cc: Andreas Färber, 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ärber <afaerber@suse.de>
Cc: Anthony Liguori <anthony@codemonkey.ws>
---
v1 -> v2:
* Instead of object_class_foreach() using a GCompareFunc with a GTree internally,
return a GSList so that the caller can sort herself (suggested by Anthony).
* Add documentation.
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 69e4b7b..ddc3b81 100644
--- a/include/qemu/object.h
+++ b/include/qemu/object.h
@@ -560,6 +560,17 @@ 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);
+
+/**
+ * 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 order.
+ */
+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 *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++;
--
1.7.7
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [Qemu-devel] [PATCH v2] qom: Introduce object_class_get_list()
2012-02-25 22:07 [Qemu-devel] [PATCH v2] qom: Introduce object_class_get_list() Andreas Färber
@ 2012-02-25 22:10 ` Andreas Färber
2012-03-07 10:21 ` Andreas Färber
2012-03-14 21:18 ` Anthony Liguori
2 siblings, 0 replies; 5+ messages in thread
From: Andreas Färber @ 2012-02-25 22:10 UTC (permalink / raw)
To: Andreas Färber; +Cc: qemu-devel, Anthony Liguori
Am 25.02.2012 23:07, schrieb Andreas Färber:
> This function allows to obtain a singly-linked list of classes, which
> can be sorted by the caller.
>
> Signed-off-by: Andreas Färber <afaerber@suse.de>
> Cc: Anthony Liguori <anthony@codemonkey.ws>
> ---
> v1 -> v2:
> * Instead of object_class_foreach() using a GCompareFunc with a GTree internally,
Err, should've been object_class_foreach_ordered();
object_class_foreach() does continue to exist. ;)
Andreas
> return a GSList so that the caller can sort herself (suggested by Anthony).
> * Add documentation.
>
> 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 69e4b7b..ddc3b81 100644
> --- a/include/qemu/object.h
> +++ b/include/qemu/object.h
> @@ -560,6 +560,17 @@ 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);
> +
> +/**
> + * 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 order.
> + */
> +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 *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++;
--
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Qemu-devel] [PATCH v2] qom: Introduce object_class_get_list()
2012-02-25 22:07 [Qemu-devel] [PATCH v2] qom: Introduce object_class_get_list() Andreas Färber
2012-02-25 22:10 ` Andreas Färber
@ 2012-03-07 10:21 ` Andreas Färber
2012-03-10 1:29 ` Andreas Färber
2012-03-14 21:18 ` Anthony Liguori
2 siblings, 1 reply; 5+ messages in thread
From: Andreas Färber @ 2012-03-07 10:21 UTC (permalink / raw)
To: Anthony Liguori; +Cc: Paolo Bonzini, qemu-devel
Am 25.02.2012 23:07, schrieb Andreas Färber:
> This function allows to obtain a singly-linked list of classes, which
> can be sorted by the caller.
>
> Signed-off-by: Andreas Färber <afaerber@suse.de>
> Cc: Anthony Liguori <anthony@codemonkey.ws>
Ping? You requested me to do it via GSList instead of GTree, and the
qom-cpu branch has been successfully rebased onto it.
Andreas
> ---
> v1 -> v2:
> * Instead of [object_class_foreach_ordered()] using a GCompareFunc with a GTree internally,
> return a GSList so that the caller can sort herself (suggested by Anthony).
> * Add documentation.
>
> 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 69e4b7b..ddc3b81 100644
> --- a/include/qemu/object.h
> +++ b/include/qemu/object.h
> @@ -560,6 +560,17 @@ 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);
> +
> +/**
> + * 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 order.
> + */
> +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 *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++;
--
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Qemu-devel] [PATCH v2] qom: Introduce object_class_get_list()
2012-03-07 10:21 ` Andreas Färber
@ 2012-03-10 1:29 ` Andreas Färber
0 siblings, 0 replies; 5+ messages in thread
From: Andreas Färber @ 2012-03-10 1:29 UTC (permalink / raw)
To: Anthony Liguori; +Cc: Paolo Bonzini, Jan Kiszka, qemu-devel
Am 07.03.2012 11:21, schrieb Andreas Färber:
> Am 25.02.2012 23:07, schrieb Andreas Färber:
>> This function allows to obtain a singly-linked list of classes, which
>> can be sorted by the caller.
>>
>> Signed-off-by: Andreas Färber <afaerber@suse.de>
>> Cc: Anthony Liguori <anthony@codemonkey.ws>
>
> Ping? You requested me to do it via GSList instead of GTree, and the
> qom-cpu branch has been successfully rebased onto it.
Ping^2! Anthony, is this in your queue or do you want a PULL?
Andreas
>> ---
>> v1 -> v2:
>> * Instead of [object_class_foreach_ordered()] using a GCompareFunc with a GTree internally,
>> return a GSList so that the caller can sort herself (suggested by Anthony).
>> * Add documentation.
>>
>> 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 69e4b7b..ddc3b81 100644
>> --- a/include/qemu/object.h
>> +++ b/include/qemu/object.h
>> @@ -560,6 +560,17 @@ 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);
>> +
>> +/**
>> + * 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 order.
>> + */
>> +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 *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++;
>
--
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Qemu-devel] [PATCH v2] qom: Introduce object_class_get_list()
2012-02-25 22:07 [Qemu-devel] [PATCH v2] qom: Introduce object_class_get_list() Andreas Färber
2012-02-25 22:10 ` Andreas Färber
2012-03-07 10:21 ` Andreas Färber
@ 2012-03-14 21:18 ` Anthony Liguori
2 siblings, 0 replies; 5+ messages in thread
From: Anthony Liguori @ 2012-03-14 21:18 UTC (permalink / raw)
To: Andreas Färber; +Cc: qemu-devel
On 02/25/2012 04:07 PM, Andreas Färber wrote:
> This function allows to obtain a singly-linked list of classes, which
> can be sorted by the caller.
>
> Signed-off-by: Andreas Färber<afaerber@suse.de>
> Cc: Anthony Liguori<anthony@codemonkey.ws>
Applied. Thanks.
Regards,
Anthony Liguori
> ---
> v1 -> v2:
> * Instead of object_class_foreach() using a GCompareFunc with a GTree internally,
> return a GSList so that the caller can sort herself (suggested by Anthony).
> * Add documentation.
>
> 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 69e4b7b..ddc3b81 100644
> --- a/include/qemu/object.h
> +++ b/include/qemu/object.h
> @@ -560,6 +560,17 @@ 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);
> +
> +/**
> + * 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 order.
> + */
> +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 *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++;
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2012-03-14 21:18 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-02-25 22:07 [Qemu-devel] [PATCH v2] qom: Introduce object_class_get_list() Andreas Färber
2012-02-25 22:10 ` Andreas Färber
2012-03-07 10:21 ` Andreas Färber
2012-03-10 1:29 ` Andreas Färber
2012-03-14 21:18 ` Anthony Liguori
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).