wlmaker
Loading...
Searching...
No Matches
src
toolkit
fsm.h
Go to the documentation of this file.
1
/* ========================================================================= */
21
#ifndef __WLMTK_FSM_H__
22
#define __WLMTK_FSM_H__
23
24
#include <stdbool.h>
25
#include <stddef.h>
26
#include <libbase/libbase.h>
27
28
#ifdef __cplusplus
29
extern
"C"
{
30
#endif
// __cplusplus
31
33
typedef
struct
_wlmtk_fsm_t
wlmtk_fsm_t
;
34
36
typedef
struct
{
38
int
state
;
40
int
event
;
42
int
to_state
;
44
bool (*handler)(
wlmtk_fsm_t
*fsm_ptr,
void
*ud_ptr);
45
}
wlmtk_fsm_transition_t
;
46
48
struct
_wlmtk_fsm_t
{
50
const
wlmtk_fsm_transition_t
*
transitions
;
52
int
state
;
53
};
54
56
#define WLMTK_FSM_TRANSITION_SENTINEL { \
57
.state = -1, \
58
.event = -1, \
59
.to_state = -1, \
60
.handler = NULL, \
61
}
62
70
void
wlmtk_fsm_init
(
71
wlmtk_fsm_t
*fsm_ptr,
72
const
wlmtk_fsm_transition_t
*transitions,
73
int
initial_state);
74
89
bool
wlmtk_fsm_event
(
90
wlmtk_fsm_t
*fsm_ptr,
91
int
event,
92
void
*ud_ptr);
93
95
extern
const
bs_test_case_t
wlmtk_fsm_test_cases
[];
96
97
#ifdef __cplusplus
98
}
// extern "C"
99
#endif
// __cplusplus
100
101
#endif
/* __WLMTK_FSM_H__ */
102
/* == End of fsm.h ====================================================== */
wlmtk_fsm_event
bool wlmtk_fsm_event(wlmtk_fsm_t *fsm_ptr, int event, void *ud_ptr)
Definition
fsm.c:37
wlmtk_fsm_test_cases
const bs_test_case_t wlmtk_fsm_test_cases[]
Definition
fsm.c:62
wlmtk_fsm_init
void wlmtk_fsm_init(wlmtk_fsm_t *fsm_ptr, const wlmtk_fsm_transition_t *transitions, int initial_state)
Definition
fsm.c:27
_wlmtk_fsm_t
Definition
fsm.h:48
_wlmtk_fsm_t::state
int state
Definition
fsm.h:52
_wlmtk_fsm_t::transitions
const wlmtk_fsm_transition_t * transitions
Definition
fsm.h:50
wlmtk_fsm_transition_t
Definition
fsm.h:36
wlmtk_fsm_transition_t::event
int event
Definition
fsm.h:40
wlmtk_fsm_transition_t::to_state
int to_state
Definition
fsm.h:42
wlmtk_fsm_transition_t::state
int state
Definition
fsm.h:38
Generated by
1.12.0