Debian Codegraph @

lib/wp/transition.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_TRANSITION_H__
10 #define __WIREPLUMBER_TRANSITION_H__
11
12 #include <gio/gio.h>
13 #include "defs.h"
14
15 G_BEGIN_DECLS
16
17 /*!
18 * \brief The WpTransition GType
19 * \ingroup wptransition
20 */
21 #define WP_TYPE_TRANSITION (wp_transition_get_type ())
22 WP_API
23 G_DECLARE_DERIVABLE_TYPE (WpTransition, wp_transition, WP, TRANSITION, GObject)
24
25 /*!
26 * \brief Values for the \em steps of the implemented state machine
27 * \ingroup wptransition
28 */
29 typedef enum {
30 /*! the initial and final step of the transition */
31 WP_TRANSITION_STEP_NONE = 0,
32 /*! returned by _WpTransitionClass::get_next_step() in case of an error */
33 WP_TRANSITION_STEP_ERROR,
34 /*! starting value for steps defined in subclasses */
35 WP_TRANSITION_STEP_CUSTOM_START = 0x10
36 } WpTransitionStep;
37
38 struct _WpTransitionClass
39 {
40 GObjectClass parent_class;
41
42 /*! See wp_transition_advance() */
43 guint (*get_next_step) (WpTransition * transition, guint step);
44 /*! See wp_transition_advance() */
45 void (*execute_step) (WpTransition * transition, guint step);
46
47 /*< private >*/
48 WP_PADDING(6)
49 };
50
51 WP_API
52 WpTransition * wp_transition_new (GType type,
53 gpointer source_object, GCancellable * cancellable,
54 GAsyncReadyCallback callback, gpointer callback_data);
55
56 WP_API
57 WpTransition * wp_transition_new_closure (GType type,
58 gpointer source_object, GCancellable * cancellable, GClosure * closure);
59
60 /* source object */
61
62 WP_API
63 gpointer wp_transition_get_source_object (WpTransition * self);
64
65 /* tag */
66
67 WP_API
68 gboolean wp_transition_is_tagged (WpTransition * self, gpointer tag);
69
70 WP_API
71 gpointer wp_transition_get_source_tag (WpTransition * self);
72
73 WP_API
74 void wp_transition_set_source_tag (WpTransition * self, gpointer tag);
75
76 /* task data */
77
78 WP_API
79 gpointer wp_transition_get_data (WpTransition * self);
80
81 WP_API
82 void wp_transition_set_data (WpTransition * self, gpointer data,
83 GDestroyNotify data_destroy);
84
85 /* state machine */
86
87 WP_API
88 gboolean wp_transition_get_completed (WpTransition * self);
89
90 WP_API
91 gboolean wp_transition_had_error (WpTransition * self);
92
93 WP_API
94 void wp_transition_advance (WpTransition * self);
95
96 WP_API
97 void wp_transition_return_error (WpTransition * self, GError * error);
98
99 /* result */
100
101 WP_API
102 gboolean wp_transition_finish (GAsyncResult * res, GError ** error);
103
104 G_END_DECLS
105
106 #endif