Debian Codegraph @

lib/wp/event-hook.h

raw
1 /* WirePlumber
2 *
3 * Copyright © 2022 Collabora Ltd.
4 * @author George Kiagiadakis <[email protected]>
5 *
6 * SPDX-License-Identifier: MIT
7 */
8
9 #ifndef __WIREPLUMBER_EVENT_HOOK_H__
10 #define __WIREPLUMBER_EVENT_HOOK_H__
11
12 #include "properties.h"
13 #include "object-interest.h"
14
15 G_BEGIN_DECLS
16
17 typedef struct _WpEvent WpEvent;
18 typedef struct _WpEventDispatcher WpEventDispatcher;
19
20 /*! \defgroup wpeventhook WpEventHook */
21 /*!
22 * \struct WpEventHook
23 *
24 * The event hook is a structure that describes some executable action
25 * that an event dispatcher will run when a matching event has been received.
26 */
27 #define WP_TYPE_EVENT_HOOK (wp_event_hook_get_type ())
28 WP_API
29 G_DECLARE_DERIVABLE_TYPE (WpEventHook, wp_event_hook, WP, EVENT_HOOK, GObject)
30
31 struct _WpEventHookClass
32 {
33 GObjectClass parent_class;
34
35 gboolean (*runs_for_event) (WpEventHook * self, WpEvent * event);
36
37 void (*run) (WpEventHook * self, WpEvent * event, GCancellable * cancellable,
38 GAsyncReadyCallback callback, gpointer callback_data);
39
40 gboolean (*finish) (WpEventHook * self, GAsyncResult * res, GError ** error);
41
42 GPtrArray * (*get_matching_event_types) (WpEventHook *self);
43
44 /*< private >*/
45 WP_PADDING(4)
46 };
47
48 WP_API
49 const gchar * wp_event_hook_get_name (WpEventHook * self);
50
51 WP_API
52 const gchar * const * wp_event_hook_get_runs_before_hooks (WpEventHook * self);
53
54 WP_API
55 const gchar * const * wp_event_hook_get_runs_after_hooks (WpEventHook * self);
56
57 WP_PRIVATE_API
58 WpEventDispatcher * wp_event_hook_get_dispatcher (WpEventHook * self);
59
60 WP_PRIVATE_API
61 void wp_event_hook_set_dispatcher (WpEventHook * self,
62 WpEventDispatcher * dispatcher);
63
64 WP_API
65 gboolean wp_event_hook_runs_for_event (WpEventHook * self, WpEvent * event);
66
67 WP_API
68 void wp_event_hook_run (WpEventHook * self,
69 WpEvent * event, GCancellable * cancellable,
70 GAsyncReadyCallback callback, gpointer callback_data);
71
72 WP_API
73 GPtrArray * wp_event_hook_get_matching_event_types (WpEventHook * self);
74
75 WP_API
76 gboolean wp_event_hook_finish (WpEventHook * self, GAsyncResult * res,
77 GError ** error);
78
79
80 /*!
81 * \brief The WpInterestEventHook GType
82 * \ingroup wpeventhook
83 */
84 #define WP_TYPE_INTEREST_EVENT_HOOK (wp_interest_event_hook_get_type ())
85 WP_API
86 G_DECLARE_DERIVABLE_TYPE (WpInterestEventHook, wp_interest_event_hook,
87 WP, INTEREST_EVENT_HOOK, WpEventHook)
88
89 struct _WpInterestEventHookClass
90 {
91 WpEventHookClass parent_class;
92
93 /*< private >*/
94 WP_PADDING(4)
95 };
96
97 WP_API
98 void wp_interest_event_hook_add_interest (WpInterestEventHook * self,
99 ...) G_GNUC_NULL_TERMINATED;
100
101 WP_API
102 void wp_interest_event_hook_add_interest_full (WpInterestEventHook * self,
103 WpObjectInterest * interest);
104
105
106 /*!
107 * \brief The WpSimpleEventHook GType
108 * \ingroup wpeventhook
109 */
110 #define WP_TYPE_SIMPLE_EVENT_HOOK (wp_simple_event_hook_get_type ())
111 WP_API
112 G_DECLARE_FINAL_TYPE (WpSimpleEventHook, wp_simple_event_hook,
113 WP, SIMPLE_EVENT_HOOK, WpInterestEventHook)
114
115 WP_API
116 WpEventHook * wp_simple_event_hook_new (const gchar *name,
117 const gchar * before[], const gchar * after[],
118 GClosure * closure);
119
120
121 /*!
122 * \brief The WpAsyncEventHook GType
123 * \ingroup wpeventhook
124 */
125 #define WP_TYPE_ASYNC_EVENT_HOOK (wp_async_event_hook_get_type ())
126 WP_API
127 G_DECLARE_FINAL_TYPE (WpAsyncEventHook, wp_async_event_hook,
128 WP, ASYNC_EVENT_HOOK, WpInterestEventHook)
129
130 WP_API
131 WpEventHook * wp_async_event_hook_new (const gchar *name,
132 const gchar * before[], const gchar * after[],
133 GClosure * get_next_step, GClosure * execute_step);
134
135 G_END_DECLS
136
137 #endif