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