diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/qemu/object.h | 47 |
1 files changed, 42 insertions, 5 deletions
diff --git a/include/qemu/object.h b/include/qemu/object.h index d93b77293f..8b17776bb3 100644 --- a/include/qemu/object.h +++ b/include/qemu/object.h @@ -33,7 +33,7 @@ typedef struct TypeInfo TypeInfo; typedef struct InterfaceClass InterfaceClass; typedef struct InterfaceInfo InterfaceInfo; -#define TYPE_OBJECT NULL +#define TYPE_OBJECT "object" /** * SECTION:object.h @@ -291,10 +291,15 @@ struct Object * has occurred to allow a class to set its default virtual method pointers. * This is also the function to use to override virtual methods from a parent * class. + * @class_base_init: This function is called for all base classes after all + * parent class initialization has occurred, but before the class itself + * is initialized. This is the function to use to undo the effects of + * memcpy from the parent class to the descendents. * @class_finalize: This function is called during class destruction and is * meant to release and dynamic parameters allocated by @class_init. - * @class_data: Data to pass to the @class_init and @class_finalize functions. - * This can be useful when building dynamic classes. + * @class_data: Data to pass to the @class_init, @class_base_init and + * @class_finalize functions. This can be useful when building dynamic + * classes. * @interfaces: The list of interfaces associated with this type. This * should point to a static array that's terminated with a zero filled * element. @@ -312,6 +317,7 @@ struct TypeInfo size_t class_size; void (*class_init)(ObjectClass *klass, void *data); + void (*class_base_init)(ObjectClass *klass, void *data); void (*class_finalize)(ObjectClass *klass, void *data); void *class_data; @@ -521,8 +527,6 @@ const char *object_get_typename(Object *obj); */ Type type_register_static(const TypeInfo *info); -#define type_register_static_alias(info, name) do { } while (0) - /** * type_register: * @info: The #TypeInfo of the new type @@ -548,6 +552,14 @@ ObjectClass *object_class_dynamic_cast(ObjectClass *klass, const char *typename); /** + * object_class_get_parent: + * @klass: The class to obtain the parent for. + * + * Returns: The parent for @klass or %NULL if none. + */ +ObjectClass *object_class_get_parent(ObjectClass *klass); + +/** * object_class_get_name: * @klass: The class to obtain the QOM typename for. * @@ -623,6 +635,17 @@ void object_property_add(Object *obj, const char *name, const char *type, void object_property_del(Object *obj, const char *name, struct Error **errp); +/** + * object_property_find: + * @obj: the object + * @name: the name of the property + * @errp: returns an error if this function fails + * + * Look up a property for an object and return its #ObjectProperty if found. + */ +ObjectProperty *object_property_find(Object *obj, const char *name, + struct Error **errp); + void object_unparent(Object *obj); /** @@ -910,6 +933,20 @@ void object_property_add_str(Object *obj, const char *name, struct Error **errp); /** + * object_child_foreach: + * @obj: the object whose children will be navigated + * @fn: the iterator function to be called + * @opaque: an opaque value that will be passed to the iterator + * + * Call @fn passing each child of @obj and @opaque to it, until @fn returns + * non-zero. + * + * Returns: The last value returned by @fn, or 0 if there is no child. + */ +int object_child_foreach(Object *obj, int (*fn)(Object *child, void *opaque), + void *opaque); + +/** * container_get: * @root: root of the #path, e.g., object_get_root() * @path: path to the container |