Go to the source code of this file.
|
struct | smf_state |
| General state that can be used in multiple state machines. More...
|
|
struct | smf_ctx |
| Defines the current context of the state machine. More...
|
|
|
#define | SMF_CREATE_STATE(_entry, _run, _exit) |
| Macro to create a flat state.
|
|
#define | SMF_CTX(o) ((struct smf_ctx *)o) |
| Macro to cast user defined object to state machine context.
|
|
|
typedef void(* | state_execution) (void *obj) |
| Function pointer that implements a portion of a state.
|
|
◆ SMF_CREATE_STATE
#define SMF_CREATE_STATE |
( |
|
_entry, |
|
|
|
_run, |
|
|
|
_exit |
|
) |
| |
Value:{ \
.entry = _entry, \
.run = _run, \
.exit = _exit \
}
Macro to create a flat state.
- Parameters
-
_entry | State entry function |
_run | State run function |
_exit | State exit function |
◆ SMF_CTX
#define SMF_CTX |
( |
|
o | ) |
((struct smf_ctx *)o) |
Macro to cast user defined object to state machine context.
- Parameters
-
o | A pointer to the user defined object |
◆ state_execution
typedef void(* state_execution) (void *obj) |
Function pointer that implements a portion of a state.
- Parameters
-
obj | pointer user defined object |
◆ smf_run_state()
Runs one iteration of a state machine (including any parent states)
- Parameters
-
- Returns
- A non-zero value should terminate the state machine. This non-zero value could represent a terminal state being reached or the detection of an error that should result in the termination of the state machine.
◆ smf_set_initial()
void smf_set_initial |
( |
struct smf_ctx * |
ctx, |
|
|
const struct smf_state * |
init_state |
|
) |
| |
Initializes the state machine and sets its initial state.
- Parameters
-
ctx | State machine context |
init_state | Initial state the state machine starts in. |
◆ smf_set_state()
Changes a state machines state.
This handles exiting the previous state and entering the target state. A common parent state will not exited nor be re-entered.
- Parameters
-
ctx | State machine context |
new_state | State to transition to (NULL is valid and exits all states) |
◆ smf_set_terminate()
Terminate a state machine.
- Parameters
-
ctx | State machine context |
val | Non-Zero termination value that's returned by the smf_run_state function. |