aboutsummaryrefslogtreecommitdiff
path: root/include/qom/object.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/qom/object.h')
-rw-r--r--include/qom/object.h80
1 files changed, 37 insertions, 43 deletions
diff --git a/include/qom/object.h b/include/qom/object.h
index 13d3a65..26df613 100644
--- a/include/qom/object.h
+++ b/include/qom/object.h
@@ -26,6 +26,7 @@ typedef struct InterfaceClass InterfaceClass;
typedef struct InterfaceInfo InterfaceInfo;
#define TYPE_OBJECT "object"
+#define TYPE_CONTAINER "container"
typedef struct ObjectProperty ObjectProperty;
@@ -279,7 +280,7 @@ struct Object
static void \
module_obj_name##_finalize(Object *obj); \
static void \
- module_obj_name##_class_init(ObjectClass *oc, void *data); \
+ module_obj_name##_class_init(ObjectClass *oc, const void *data); \
static void \
module_obj_name##_init(Object *obj); \
\
@@ -293,7 +294,7 @@ struct Object
.class_size = CLASS_SIZE, \
.class_init = module_obj_name##_class_init, \
.abstract = ABSTRACT, \
- .interfaces = (InterfaceInfo[]) { __VA_ARGS__ } , \
+ .interfaces = (const InterfaceInfo[]) { __VA_ARGS__ } , \
}; \
\
static void \
@@ -444,7 +445,8 @@ struct Object
* class will have already been initialized so the type is only responsible
* for initializing its own members.
* @instance_post_init: This function is called to finish initialization of
- * an object, after all @instance_init functions were called.
+ * an object, after all @instance_init functions were called, as well as
+ * @instance_post_init functions for the parent classes.
* @instance_finalize: This function is called during object destruction. This
* is called before the parent @instance_finalize function has been called.
* An object should only free the members that are unique to its type in this
@@ -485,11 +487,11 @@ struct TypeInfo
bool abstract;
size_t class_size;
- void (*class_init)(ObjectClass *klass, void *data);
- void (*class_base_init)(ObjectClass *klass, void *data);
- void *class_data;
+ void (*class_init)(ObjectClass *klass, const void *data);
+ void (*class_base_init)(ObjectClass *klass, const void *data);
+ const void *class_data;
- InterfaceInfo *interfaces;
+ const InterfaceInfo *interfaces;
};
/**
@@ -572,12 +574,15 @@ struct InterfaceInfo {
*
* The class for all interfaces. Subclasses of this class should only add
* virtual methods.
+ *
+ * Note that most of the fields of ObjectClass are unused (all except
+ * "type", in fact). They are only present in InterfaceClass to allow
+ * @object_class_dynamic_cast to work with both regular classes and interfaces.
*/
struct InterfaceClass
{
ObjectClass parent_class;
/* private: */
- ObjectClass *concrete_class;
Type interface_type;
};
@@ -880,25 +885,11 @@ const char *object_get_typename(const Object *obj);
* type_register_static:
* @info: The #TypeInfo of the new type.
*
- * @info and all of the strings it points to should exist for the life time
- * that the type is registered.
- *
* Returns: the new #Type.
*/
Type type_register_static(const TypeInfo *info);
/**
- * type_register:
- * @info: The #TypeInfo of the new type
- *
- * Unlike type_register_static(), this call does not require @info or its
- * string members to continue to exist after the call returns.
- *
- * Returns: the new #Type.
- */
-Type type_register(const TypeInfo *info);
-
-/**
* type_register_static_array:
* @infos: The array of the new type #TypeInfo structures.
* @nr_infos: number of entries in @infos
@@ -1523,6 +1514,16 @@ const char *object_property_get_type(Object *obj, const char *name,
*/
Object *object_get_root(void);
+/**
+ * object_get_container:
+ * @name: the name of container to lookup
+ *
+ * Lookup a root level container.
+ *
+ * Returns: the container with @name.
+ */
+Object *object_get_container(const char *name);
+
/**
* object_get_objects_root:
@@ -1569,8 +1570,8 @@ char *object_get_canonical_path(const Object *obj);
/**
* object_resolve_path:
* @path: the path to resolve
- * @ambiguous: returns true if the path resolution failed because of an
- * ambiguous match
+ * @ambiguous: (out) (optional): location to store whether the lookup failed
+ * because it was ambiguous, or %NULL. Set to %false on success.
*
* There are two types of supported paths--absolute paths and partial paths.
*
@@ -1587,7 +1588,7 @@ char *object_get_canonical_path(const Object *obj);
* only one match is found. If more than one match is found, a flag is
* returned to indicate that the match was ambiguous.
*
- * Returns: The matched object or NULL on path lookup failure.
+ * Returns: The matched object or %NULL on path lookup failure.
*/
Object *object_resolve_path(const char *path, bool *ambiguous);
@@ -1595,10 +1596,10 @@ Object *object_resolve_path(const char *path, bool *ambiguous);
* object_resolve_path_type:
* @path: the path to resolve
* @typename: the type to look for.
- * @ambiguous: returns true if the path resolution failed because of an
- * ambiguous match
+ * @ambiguous: (out) (optional): location to store whether the lookup failed
+ * because it was ambiguous, or %NULL. Set to %false on success.
*
- * This is similar to object_resolve_path. However, when looking for a
+ * This is similar to object_resolve_path(). However, when looking for a
* partial path only matches that implement the given type are considered.
* This restricts the search and avoids spuriously flagging matches as
* ambiguous.
@@ -2020,25 +2021,18 @@ int object_child_foreach(Object *obj, int (*fn)(Object *child, void *opaque),
int object_child_foreach_recursive(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
- *
- * Return a container object whose path is @path. Create more containers
- * along the path if necessary.
- *
- * Returns: the container object.
- */
-Object *container_get(Object *root, const char *path);
/**
- * object_type_get_instance_size:
- * @typename: Name of the Type whose instance_size is required
+ * object_property_add_new_container:
+ * @obj: the parent object
+ * @name: the name of the parent object's property to add
+ *
+ * Add a newly created container object to a parent object.
*
- * Returns the instance_size of the given @typename.
+ * Returns: the newly created container object. Its reference count is 1,
+ * and the reference is owned by the parent object.
*/
-size_t object_type_get_instance_size(const char *typename);
+Object *object_property_add_new_container(Object *obj, const char *name);
/**
* object_property_help: