Debian Codegraph @

lib/wp/object.h

raw
1 /* WirePlumber
2 *
3 * Copyright © 2020 Collabora Ltd.
4 * @author George Kiagiadakis <[email protected]>
5 *
6 * SPDX-License-Identifier: MIT
7 */
8
9 #ifndef __WIREPLUMBER_OBJECT_H__
10 #define __WIREPLUMBER_OBJECT_H__
11
12 #include "transition.h"
13
14 G_BEGIN_DECLS
15
16 typedef struct _WpCore WpCore;
17
18 /*!
19 * \brief Flags that specify functionality that is available on this class.
20 *
21 * Use wp_object_activate() to enable more features,
22 * wp_object_get_supported_features() to see which features are supported and
23 * wp_object_get_active_features() to find out which features are already
24 * enabled. Features can also be deactivated later using wp_object_deactivate().
25 *
26 * Actual feature flags are to be specified by subclasses and their interfaces.
27 * WP_OBJECT_FEATURES_ALL is a special value that can be used to activate
28 * all the supported features in any given object.
29 *
30 * \ingroup wpobject
31 */
32 typedef guint WpObjectFeatures;
33
34 /*!
35 * \brief Special value that can be used to activate
36 * all the supported features in any given object.
37 * \ingroup wpobject
38 */
39 static const WpObjectFeatures WP_OBJECT_FEATURES_ALL = 0xffffffff;
40
41 /*!
42 * \brief The WpFeatureActivationTransition GType
43 * \ingroup wpfeatureactivationtransition
44 */
45 #define WP_TYPE_FEATURE_ACTIVATION_TRANSITION \
46 (wp_feature_activation_transition_get_type ())
47 WP_API
48 G_DECLARE_FINAL_TYPE (WpFeatureActivationTransition,
49 wp_feature_activation_transition,
50 WP, FEATURE_ACTIVATION_TRANSITION, WpTransition)
51
52 WP_API
53 WpObjectFeatures wp_feature_activation_transition_get_requested_features (
54 WpFeatureActivationTransition * self);
55
56 /*!
57 * \brief The WpObject GType
58 * \ingroup wpobject
59 */
60 #define WP_TYPE_OBJECT (wp_object_get_type ())
61 WP_API
62 G_DECLARE_DERIVABLE_TYPE (WpObject, wp_object, WP, OBJECT, GObject)
63
64 struct _WpObjectClass
65 {
66 GObjectClass parent_class;
67
68 WpObjectFeatures (*get_supported_features) (WpObject * self);
69
70 guint (*activate_get_next_step) (WpObject * self,
71 WpFeatureActivationTransition * transition, guint step,
72 WpObjectFeatures missing);
73 void (*activate_execute_step) (WpObject * self,
74 WpFeatureActivationTransition * transition, guint step,
75 WpObjectFeatures missing);
76
77 void (*deactivate) (WpObject * self, WpObjectFeatures features);
78
79 /*< private >*/
80 WP_PADDING(8)
81 };
82
83 WP_API
84 guint wp_object_get_id (WpObject * self);
85
86 WP_API
87 WpCore * wp_object_get_core (WpObject * self);
88
89 WP_API
90 WpObjectFeatures wp_object_get_active_features (WpObject * self);
91
92 WP_API
93 gboolean wp_object_test_active_features (WpObject * self, WpObjectFeatures features);
94
95 WP_API
96 WpObjectFeatures wp_object_get_supported_features (WpObject * self);
97
98 WP_API
99 gboolean wp_object_test_supported_features (WpObject * self, WpObjectFeatures features);
100
101 WP_API
102 void wp_object_activate (WpObject * self,
103 WpObjectFeatures features, GCancellable * cancellable,
104 GAsyncReadyCallback callback, gpointer user_data);
105
106 WP_API
107 void wp_object_activate_closure (WpObject * self,
108 WpObjectFeatures features, GCancellable * cancellable, GClosure *closure);
109
110 WP_API
111 gboolean wp_object_activate_finish (WpObject * self, GAsyncResult * res,
112 GError ** error);
113
114 WP_API
115 void wp_object_deactivate (WpObject * self, WpObjectFeatures features);
116
117 /* for subclasses only */
118
119 WP_API
120 void wp_object_abort_activation (WpObject * self, const gchar *msg);
121
122 WP_API
123 void wp_object_update_features (WpObject * self, WpObjectFeatures activated,
124 WpObjectFeatures deactivated);
125
126 G_END_DECLS
127
128 #endif