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.h109
1 files changed, 96 insertions, 13 deletions
diff --git a/include/qom/object.h b/include/qom/object.h
index 54a548868c..29546496c1 100644
--- a/include/qom/object.h
+++ b/include/qom/object.h
@@ -309,6 +309,8 @@ typedef struct InterfaceInfo InterfaceInfo;
*/
+typedef struct ObjectProperty ObjectProperty;
+
/**
* ObjectPropertyAccessor:
* @obj: the object that owns the property
@@ -356,7 +358,16 @@ typedef void (ObjectPropertyRelease)(Object *obj,
const char *name,
void *opaque);
-typedef struct ObjectProperty
+/**
+ * ObjectPropertyInit:
+ * @obj: the object that owns the property
+ * @prop: the property to set
+ *
+ * Called when a property is initialized.
+ */
+typedef void (ObjectPropertyInit)(Object *obj, ObjectProperty *prop);
+
+struct ObjectProperty
{
gchar *name;
gchar *type;
@@ -365,8 +376,10 @@ typedef struct ObjectProperty
ObjectPropertyAccessor *set;
ObjectPropertyResolve *resolve;
ObjectPropertyRelease *release;
+ ObjectPropertyInit *init;
void *opaque;
-} ObjectProperty;
+ QObject *defval;
+};
/**
* ObjectUnparent:
@@ -992,8 +1005,9 @@ GSList *object_class_get_list_sorted(const char *implements_type,
*
* Increase the reference count of a object. A object cannot be freed as long
* as its reference count is greater than zero.
+ * Returns: @obj
*/
-void object_ref(Object *obj);
+Object *object_ref(Object *obj);
/**
* object_unref:
@@ -1044,6 +1058,42 @@ ObjectProperty *object_class_property_add(ObjectClass *klass, const char *name,
void *opaque, Error **errp);
/**
+ * object_property_set_default_bool:
+ * @prop: the property to set
+ * @value: the value to be written to the property
+ *
+ * Set the property default value.
+ */
+void object_property_set_default_bool(ObjectProperty *prop, bool value);
+
+/**
+ * object_property_set_default_str:
+ * @prop: the property to set
+ * @value: the value to be written to the property
+ *
+ * Set the property default value.
+ */
+void object_property_set_default_str(ObjectProperty *prop, const char *value);
+
+/**
+ * object_property_set_default_int:
+ * @prop: the property to set
+ * @value: the value to be written to the property
+ *
+ * Set the property default value.
+ */
+void object_property_set_default_int(ObjectProperty *prop, int64_t value);
+
+/**
+ * object_property_set_default_uint:
+ * @prop: the property to set
+ * @value: the value to be written to the property
+ *
+ * Set the property default value.
+ */
+void object_property_set_default_uint(ObjectProperty *prop, uint64_t value);
+
+/**
* object_property_find:
* @obj: the object
* @name: the name of the property
@@ -1462,6 +1512,10 @@ void object_property_add_child(Object *obj, const char *name,
typedef enum {
/* Unref the link pointer when the property is deleted */
OBJ_PROP_LINK_STRONG = 0x1,
+
+ /* private */
+ OBJ_PROP_LINK_DIRECT = 0x2,
+ OBJ_PROP_LINK_CLASS = 0x4,
} ObjectPropertyLinkFlags;
/**
@@ -1479,7 +1533,7 @@ void object_property_allow_set_link(const Object *, const char *,
* @obj: the object to add a property to
* @name: the name of the property
* @type: the qobj type of the link
- * @child: a pointer to where the link object reference is stored
+ * @targetp: a pointer to where the link object reference is stored
* @check: callback to veto setting or NULL if the property is read-only
* @flags: additional options for the link
* @errp: if an error occurs, a pointer to an area to store the error
@@ -1504,7 +1558,15 @@ void object_property_allow_set_link(const Object *, const char *,
* modified.
*/
void object_property_add_link(Object *obj, const char *name,
- const char *type, Object **child,
+ const char *type, Object **targetp,
+ void (*check)(const Object *obj, const char *name,
+ Object *val, Error **errp),
+ ObjectPropertyLinkFlags flags,
+ Error **errp);
+
+ObjectProperty *object_class_property_add_link(ObjectClass *oc,
+ const char *name,
+ const char *type, ptrdiff_t offset,
void (*check)(const Object *obj, const char *name,
Object *val, Error **errp),
ObjectPropertyLinkFlags flags,
@@ -1527,7 +1589,8 @@ void object_property_add_str(Object *obj, const char *name,
void (*set)(Object *, const char *, Error **),
Error **errp);
-void object_class_property_add_str(ObjectClass *klass, const char *name,
+ObjectProperty *object_class_property_add_str(ObjectClass *klass,
+ const char *name,
char *(*get)(Object *, Error **),
void (*set)(Object *, const char *,
Error **),
@@ -1549,7 +1612,8 @@ void object_property_add_bool(Object *obj, const char *name,
void (*set)(Object *, bool, Error **),
Error **errp);
-void object_class_property_add_bool(ObjectClass *klass, const char *name,
+ObjectProperty *object_class_property_add_bool(ObjectClass *klass,
+ const char *name,
bool (*get)(Object *, Error **),
void (*set)(Object *, bool, Error **),
Error **errp);
@@ -1573,7 +1637,8 @@ void object_property_add_enum(Object *obj, const char *name,
void (*set)(Object *, int, Error **),
Error **errp);
-void object_class_property_add_enum(ObjectClass *klass, const char *name,
+ObjectProperty *object_class_property_add_enum(ObjectClass *klass,
+ const char *name,
const char *typename,
const QEnumLookup *lookup,
int (*get)(Object *, Error **),
@@ -1594,7 +1659,8 @@ void object_property_add_tm(Object *obj, const char *name,
void (*get)(Object *, struct tm *, Error **),
Error **errp);
-void object_class_property_add_tm(ObjectClass *klass, const char *name,
+ObjectProperty *object_class_property_add_tm(ObjectClass *klass,
+ const char *name,
void (*get)(Object *, struct tm *, Error **),
Error **errp);
@@ -1610,7 +1676,8 @@ void object_class_property_add_tm(ObjectClass *klass, const char *name,
*/
void object_property_add_uint8_ptr(Object *obj, const char *name,
const uint8_t *v, Error **errp);
-void object_class_property_add_uint8_ptr(ObjectClass *klass, const char *name,
+ObjectProperty *object_class_property_add_uint8_ptr(ObjectClass *klass,
+ const char *name,
const uint8_t *v, Error **errp);
/**
@@ -1625,7 +1692,8 @@ void object_class_property_add_uint8_ptr(ObjectClass *klass, const char *name,
*/
void object_property_add_uint16_ptr(Object *obj, const char *name,
const uint16_t *v, Error **errp);
-void object_class_property_add_uint16_ptr(ObjectClass *klass, const char *name,
+ObjectProperty *object_class_property_add_uint16_ptr(ObjectClass *klass,
+ const char *name,
const uint16_t *v, Error **errp);
/**
@@ -1640,7 +1708,8 @@ void object_class_property_add_uint16_ptr(ObjectClass *klass, const char *name,
*/
void object_property_add_uint32_ptr(Object *obj, const char *name,
const uint32_t *v, Error **errp);
-void object_class_property_add_uint32_ptr(ObjectClass *klass, const char *name,
+ObjectProperty *object_class_property_add_uint32_ptr(ObjectClass *klass,
+ const char *name,
const uint32_t *v, Error **errp);
/**
@@ -1655,7 +1724,8 @@ void object_class_property_add_uint32_ptr(ObjectClass *klass, const char *name,
*/
void object_property_add_uint64_ptr(Object *obj, const char *name,
const uint64_t *v, Error **errp);
-void object_class_property_add_uint64_ptr(ObjectClass *klass, const char *name,
+ObjectProperty *object_class_property_add_uint64_ptr(ObjectClass *klass,
+ const char *name,
const uint64_t *v, Error **errp);
/**
@@ -1767,6 +1837,19 @@ Object *container_get(Object *root, const char *path);
*/
size_t object_type_get_instance_size(const char *typename);
+/**
+ * object_property_help:
+ * @name: the name of the property
+ * @type: the type of the property
+ * @defval: the default value
+ * @description: description of the property
+ *
+ * Returns: a user-friendly formatted string describing the property
+ * for help purposes.
+ */
+char *object_property_help(const char *name, const char *type,
+ QObject *defval, const char *description);
+
G_DEFINE_AUTOPTR_CLEANUP_FUNC(Object, object_unref)
#endif