From 32efc535b86626646442de7fe5793f3a47f4ce91 Mon Sep 17 00:00:00 2001 From: Paolo Bonzini Date: Wed, 11 Apr 2012 23:30:20 +0200 Subject: qom: Add object_child_foreach() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit A utility function that will be used to implement hierarchical realization. Signed-off-by: Paolo Bonzini Reviewed-by: Anthony Liguori [AF: Drop unrelated whitespace change, add Returns: in documentation] [AF: Use new object_property_is_child() helper.] Signed-off-by: Andreas Färber --- qom/object.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'qom') diff --git a/qom/object.c b/qom/object.c index 105c649..7a70d52 100644 --- a/qom/object.c +++ b/qom/object.c @@ -607,6 +607,23 @@ void object_class_foreach(void (*fn)(ObjectClass *klass, void *opaque), g_hash_table_foreach(type_table_get(), object_class_foreach_tramp, &data); } +int object_child_foreach(Object *obj, int (*fn)(Object *child, void *opaque), + void *opaque) +{ + ObjectProperty *prop; + int ret = 0; + + QTAILQ_FOREACH(prop, &obj->properties, node) { + if (object_property_is_child(prop)) { + ret = fn(prop->opaque, opaque); + if (ret != 0) { + break; + } + } + } + return ret; +} + static void object_class_get_list_tramp(ObjectClass *klass, void *opaque) { GSList **list = opaque; -- cgit v1.1