-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhfsm_stack.h
49 lines (39 loc) · 1.27 KB
/
hfsm_stack.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#ifndef HFSM_STACK_H
#define HFSM_STACK_H
#include <stdint.h>
#include <stdbool.h>
#include <assert.h>
#include <hfsm.h>
typedef struct hfsm hfsm;
typedef int (*state_handler)(hfsm* me, hfsm_event event, int(** super_state)());
struct hfsm
{
state_handler current_state;
};
int hfsm_init(hfsm* h, state_handler initial_state);
/*
Supported transitions limited to the following:
- peer states (within the same top-level state).
- super state transitioning to another peer state (all sub-states will exit).
*/
int hfsm_transition_peer(hfsm* h, state_handler source_state, state_handler destination_state);
/*
Supported transitions limited to the following:
- peer state transitioning to first-level inner state.
- super state transitioning to another first-level inner state.
*/
int hfsm_transition_substate(
hfsm* h,
state_handler source_state,
state_handler destination_state);
/*
Supported transitions limited to the following:
- peer state transitioning to first-level inner state.
- super state transitioning to another first-level inner state.
*/
int hfsm_transition_superstate(
hfsm* h,
state_handler source_state,
state_handler destination_state);
int hfsm_post_event(hfsm* h, hfsm_event event);
#endif //!HFSM_STACK_H