| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
#pragma once |
| 23 |
|
| 24 |
#if !defined (DEX_INSIDE) && !defined (DEX_COMPILATION) |
| 25 |
# error "Only <libdex.h> can be included directly." |
| 26 |
#endif |
| 27 |
|
| 28 |
#include "dex-future.h" |
| 29 |
#include "dex-scheduler.h" |
| 30 |
#include "dex-version-macros.h" |
| 31 |
|
| 32 |
G_BEGIN_DECLS |
| 33 |
|
| 34 |
#define DEX_TYPE_STATE_MACHINE (dex_state_machine_get_type()) |
| 35 |
#define DEX_STATE_MACHINE(object) (G_TYPE_CHECK_INSTANCE_CAST(object, DEX_TYPE_STATE_MACHINE, DexStateMachine)) |
| 36 |
#define DEX_IS_STATE_MACHINE(object) (G_TYPE_CHECK_INSTANCE_TYPE(object, DEX_TYPE_STATE_MACHINE)) |
| 37 |
|
| 38 |
typedef struct _DexStateMachine DexStateMachine; |
| 39 |
typedef struct _DexStateTransitionContext DexStateTransitionContext; |
| 40 |
|
| 41 |
|
| 42 |
|
| 43 |
|
| 44 |
|
| 45 |
|
| 46 |
|
| 47 |
|
| 48 |
|
| 49 |
|
| 50 |
|
| 51 |
|
| 52 |
|
| 53 |
|
| 54 |
|
| 55 |
|
| 56 |
|
| 57 |
|
| 58 |
|
| 59 |
|
| 60 |
|
| 61 |
|
| 62 |
typedef gboolean (*DexStateTransitionFunc) (DexStateTransitionContext *context, |
| 63 |
gpointer user_data, |
| 64 |
GError **error); |
| 65 |
|
| 66 |
|
| 67 |
|
| 68 |
|
| 69 |
|
| 70 |
|
| 71 |
|
| 72 |
|
| 73 |
|
| 74 |
typedef struct _DexStateTransition |
| 75 |
{ |
| 76 |
guint from; |
| 77 |
guint to; |
| 78 |
DexStateTransitionFunc func; |
| 79 |
} DexStateTransition; |
| 80 |
|
| 81 |
DEX_AVAILABLE_IN_1_2 |
| 82 |
guint dex_state_transition_context_get_from (DexStateTransitionContext *context); |
| 83 |
DEX_AVAILABLE_IN_1_2 |
| 84 |
guint dex_state_transition_context_get_to (DexStateTransitionContext *context); |
| 85 |
DEX_AVAILABLE_IN_1_2 |
| 86 |
guint dex_state_transition_context_get_state (DexStateTransitionContext *context); |
| 87 |
DEX_AVAILABLE_IN_1_2 |
| 88 |
void dex_state_transition_context_set_state (DexStateTransitionContext *context, |
| 89 |
guint state); |
| 90 |
DEX_AVAILABLE_IN_1_2 |
| 91 |
DexFuture *dex_state_transition_context_wait_for_interrupt (DexStateTransitionContext *context) G_GNUC_WARN_UNUSED_RESULT; |
| 92 |
DEX_AVAILABLE_IN_1_2 |
| 93 |
gboolean dex_state_transition_context_continue_to (DexStateTransitionContext *context, |
| 94 |
guint target, |
| 95 |
GError **error) G_GNUC_WARN_UNUSED_RESULT; |
| 96 |
DEX_AVAILABLE_IN_1_2 |
| 97 |
GType dex_state_machine_get_type (void); |
| 98 |
DEX_AVAILABLE_IN_1_2 |
| 99 |
DexStateMachine *dex_state_machine_new (GType state_enum_type, |
| 100 |
guint initial_state, |
| 101 |
const DexStateTransition *transitions, |
| 102 |
guint n_transitions, |
| 103 |
DexScheduler *scheduler, |
| 104 |
gsize stack_size, |
| 105 |
gpointer user_data, |
| 106 |
GDestroyNotify user_data_destroy); |
| 107 |
DEX_AVAILABLE_IN_1_2 |
| 108 |
DexFuture *dex_state_machine_transition (DexStateMachine *state_machine, |
| 109 |
guint target) G_GNUC_WARN_UNUSED_RESULT; |
| 110 |
DEX_AVAILABLE_IN_1_2 |
| 111 |
DexFuture *dex_state_machine_wait_for_state (DexStateMachine *state_machine, |
| 112 |
guint state) G_GNUC_WARN_UNUSED_RESULT; |
| 113 |
DEX_AVAILABLE_IN_1_2 |
| 114 |
gboolean dex_state_machine_interrupt (DexStateMachine *state_machine); |
| 115 |
DEX_AVAILABLE_IN_1_2 |
| 116 |
guint dex_state_machine_get_requested_state (DexStateMachine *state_machine); |
| 117 |
DEX_AVAILABLE_IN_1_2 |
| 118 |
guint dex_state_machine_get_state (DexStateMachine *state_machine); |
| 119 |
|
| 120 |
G_DEFINE_AUTOPTR_CLEANUP_FUNC (DexStateMachine, dex_unref) |
| 121 |
|
| 122 |
G_END_DECLS |