|
infinite_state_machine 1.0.0
Infinite State Machine Library
|
Stack-based hierarchical (potentially unbounded logical) state machine implementation. More...

Go to the source code of this file.
Functions | |
| void | infinite_state_machine_init (struct infinite_state_machine *machine) |
Initialises the infinite state machine. The machine is reset to its initial state. It has an initial depth of 0. All its states are cleared to NULL for safety. | |
| void | infinite_state_machine_goto (struct infinite_state_machine *machine, struct infinite_state *state) |
| Goes to a state in the infinite state machine. | |
| void | infinite_state_machine_jump (struct infinite_state_machine *machine, struct infinite_state *state) |
| Jumps to a state in the infinite state machine. | |
| int | infinite_state_machine_in (struct infinite_state_machine *machine, struct infinite_state *state) |
| Checks if a state is currently active in the infinite state machine. | |
| struct infinite_state * | infinite_state_machine_top (const struct infinite_state_machine *machine) |
| Gets the top state of the infinite state machine. | |
Stack-based hierarchical (potentially unbounded logical) state machine implementation.
Provides push and pop (enter and exit) semantics plus goto that performs least–common–ancestor optimisation: only differing tail states are exited or entered.
Invariants:
NULL (after init or pop).Notes:
Definition in file infinite_state_machine.c.
| void infinite_state_machine_goto | ( | struct infinite_state_machine * | machine, |
| struct infinite_state * | state | ||
| ) |
Goes to a state in the infinite state machine.
| machine | The infinite state machine. |
| state | The state to enter. |
Going to a state in the infinite state machine transitions the machine to the new state. This will push the current state onto the stack and transition to the new state. If the new state is the same as the current state, no action is taken; likewise, if the new state is a NULL pointer, no action is taken. Otherwise, all the exit actions for the current state are run, and the new state is entered by running all enter actions.
Definition at line 66 of file infinite_state_machine.c.
| int infinite_state_machine_in | ( | struct infinite_state_machine * | machine, |
| struct infinite_state * | state | ||
| ) |
Checks if a state is currently active in the infinite state machine.
| machine | The infinite state machine. |
| state | The state to check. |
Definition at line 99 of file infinite_state_machine.c.
| void infinite_state_machine_init | ( | struct infinite_state_machine * | machine | ) |
Initialises the infinite state machine. The machine is reset to its initial state. It has an initial depth of 0. All its states are cleared to NULL for safety.
| machine | The infinite state machine to initialise. |
Definition at line 60 of file infinite_state_machine.c.
| void infinite_state_machine_jump | ( | struct infinite_state_machine * | machine, |
| struct infinite_state * | state | ||
| ) |
Jumps to a state in the infinite state machine.
| machine | The infinite state machine. |
| state | The state to jump to. |
Jumping to a state in the infinite state machine resets the machine to its initial state and then transitions to the specified state. This is useful for resetting the machine to a known state without going through the normal entry and exit actions.
Definition at line 93 of file infinite_state_machine.c.
| struct infinite_state * infinite_state_machine_top | ( | const struct infinite_state_machine * | machine | ) |
Gets the top state of the infinite state machine.
| machine | The infinite state machine. |
NULL if the machine is empty. Definition at line 157 of file infinite_state_machine.c.