configure: require __thread support
[qemu/ar7.git] / include / qom / object_interfaces.h
blob283ae0db4dce5d612d236186b9c309461cb4eeac
1 #ifndef OBJECT_INTERFACES_H
2 #define OBJECT_INTERFACES_H
4 #include "qom/object.h"
6 #define TYPE_USER_CREATABLE "user-creatable"
8 #define USER_CREATABLE_CLASS(klass) \
9 OBJECT_CLASS_CHECK(UserCreatableClass, (klass), \
10 TYPE_USER_CREATABLE)
11 #define USER_CREATABLE_GET_CLASS(obj) \
12 OBJECT_GET_CLASS(UserCreatableClass, (obj), \
13 TYPE_USER_CREATABLE)
14 #define USER_CREATABLE(obj) \
15 INTERFACE_CHECK(UserCreatable, (obj), \
16 TYPE_USER_CREATABLE)
19 typedef struct UserCreatable {
20 /* <private> */
21 Object Parent;
22 } UserCreatable;
24 /**
25 * UserCreatableClass:
26 * @parent_class: the base class
27 * @complete: callback to be called after @obj's properties are set.
28 * @can_be_deleted: callback to be called before an object is removed
29 * to check if @obj can be removed safely.
31 * Interface is designed to work with -object/object-add/object_add
32 * commands.
33 * Interface is mandatory for objects that are designed to be user
34 * creatable (i.e. -object/object-add/object_add, will accept only
35 * objects that inherit this interface).
37 * Interface also provides an optional ability to do the second
38 * stage * initialization of the object after its properties were
39 * set.
41 * For objects created without using -object/object-add/object_add,
42 * @user_creatable_complete() wrapper should be called manually if
43 * object's type implements USER_CREATABLE interface and needs
44 * complete() callback to be called.
46 typedef struct UserCreatableClass {
47 /* <private> */
48 InterfaceClass parent_class;
50 /* <public> */
51 void (*complete)(UserCreatable *uc, Error **errp);
52 bool (*can_be_deleted)(UserCreatable *uc, Error **errp);
53 } UserCreatableClass;
55 /**
56 * user_creatable_complete:
57 * @obj: the object whose complete() method is called if defined
58 * @errp: if an error occurs, a pointer to an area to store the error
60 * Wrapper to call complete() method if one of types it's inherited
61 * from implements USER_CREATABLE interface, otherwise the call does
62 * nothing.
64 void user_creatable_complete(Object *obj, Error **errp);
66 /**
67 * user_creatable_can_be_deleted:
68 * @uc: the object whose can_be_deleted() method is called if implemented
69 * @errp: if an error occurs, a pointer to an area to store the error
71 * Wrapper to call can_be_deleted() method if one of types it's inherited
72 * from implements USER_CREATABLE interface.
74 bool user_creatable_can_be_deleted(UserCreatable *uc, Error **errp);
75 #endif