wlmaker
Loading...
Searching...
No Matches
include
toolkit
fsm.h
Go to the documentation of this file.
1
/* ========================================================================= */
22
#ifndef __WLMTK_FSM_H__
23
#define __WLMTK_FSM_H__
24
25
#include <libbase/libbase.h>
26
#include <stdbool.h>
27
#include <stddef.h>
28
29
#ifdef __cplusplus
30
extern
"C"
{
31
#endif
// __cplusplus
32
34
typedef
struct
_wlmtk_fsm_t
wlmtk_fsm_t
;
35
37
typedef
struct
{
39
int
state
;
41
int
event
;
43
int
to_state
;
45
bool (*handler)(
wlmtk_fsm_t
*fsm_ptr,
void
*ud_ptr);
46
}
wlmtk_fsm_transition_t
;
47
49
struct
_wlmtk_fsm_t
{
51
const
wlmtk_fsm_transition_t
*
transitions
;
53
int
state
;
54
};
55
57
#define WLMTK_FSM_TRANSITION_SENTINEL { \
58
.state = -1, \
59
.event = -1, \
60
.to_state = -1, \
61
.handler = NULL, \
62
}
63
71
void
wlmtk_fsm_init
(
72
wlmtk_fsm_t
*fsm_ptr,
73
const
wlmtk_fsm_transition_t
*transitions,
74
int
initial_state);
75
90
bool
wlmtk_fsm_event
(
91
wlmtk_fsm_t
*fsm_ptr,
92
int
event,
93
void
*ud_ptr);
94
96
extern
const
bs_test_set_t
wlmtk_fsm_test_set
;
97
98
#ifdef __cplusplus
99
}
// extern "C"
100
#endif
// __cplusplus
101
102
#endif
/* __WLMTK_FSM_H__ */
103
/* == End of fsm.h ====================================================== */
wlmtk_fsm_event
bool wlmtk_fsm_event(wlmtk_fsm_t *fsm_ptr, int event, void *ud_ptr)
Definition
fsm.c:40
wlmtk_fsm_init
void wlmtk_fsm_init(wlmtk_fsm_t *fsm_ptr, const wlmtk_fsm_transition_t *transitions, int initial_state)
Definition
fsm.c:30
wlmtk_fsm_test_set
const bs_test_set_t wlmtk_fsm_test_set
Definition
fsm.c:71
_wlmtk_fsm_t
Definition
fsm.h:49
_wlmtk_fsm_t::state
int state
Definition
fsm.h:53
_wlmtk_fsm_t::transitions
const wlmtk_fsm_transition_t * transitions
Definition
fsm.h:51
wlmtk_fsm_transition_t
Definition
fsm.h:37
wlmtk_fsm_transition_t::event
int event
Definition
fsm.h:41
wlmtk_fsm_transition_t::to_state
int to_state
Definition
fsm.h:43
wlmtk_fsm_transition_t::state
int state
Definition
fsm.h:39
Generated by
1.9.8