![]() |
nomlib
|
A transition table keyed by active state, event, and stack top. More...
#include <StateMachine.hpp>
Public Types | |
| using | Callback = std::function<Transition(const IState& active, EventSymbol event, StateSymbol stack_top)> |
| Function signature for fallback transition resolution. | |
Public Member Functions | |
| void | add (StateSymbol active, EventSymbol event, StateSymbol stack_top, const Transition &transition) |
| Add an exact transition. | |
| void | add (StateSymbol active, EventSymbol event, const Transition &transition) |
| Add a transition that ignores the stack top. | |
| Transition | query (StateSymbol active, EventSymbol event, StateSymbol stack_top) const |
| Query the table for a transition. | |
| Transition | resolve (const IState &active, EventSymbol event, StateSymbol stack_top) const |
| Resolve a transition with optional fallback. | |
| void | set_fallback (Callback callback) |
| Install a fallback resolver. | |
Private Attributes | |
| std::map< std::tuple< StateSymbol, EventSymbol, StateSymbol >, Transition > | transitions_ |
| Exact-match transitions. | |
| std::map< std::pair< StateSymbol, EventSymbol >, Transition > | wildcards_ |
| Wildcard transitions (stack top ignored). | |
| Callback | fallback_ |
| Optional fallback resolver. | |
A transition table keyed by active state, event, and stack top.
Definition at line 121 of file StateMachine.hpp.
| using nom::TransitionTable::Callback = std::function<Transition(const IState& active, EventSymbol event, StateSymbol stack_top)> |
Function signature for fallback transition resolution.
Definition at line 125 of file StateMachine.hpp.
| void nom::TransitionTable::add | ( | StateSymbol | active, |
| EventSymbol | event, | ||
| const Transition & | transition ) |
Add a transition that ignores the stack top.
Wildcards are checked after exact matches.
| void nom::TransitionTable::add | ( | StateSymbol | active, |
| EventSymbol | event, | ||
| StateSymbol | stack_top, | ||
| const Transition & | transition ) |
Add an exact transition.
The transition is used only when (active_symbol, event_symbol, stack_top_symbol) matches exactly.
| Transition nom::TransitionTable::query | ( | StateSymbol | active, |
| EventSymbol | event, | ||
| StateSymbol | stack_top ) const |
Query the table for a transition.
Exact matches take precedence over wildcards. No fallback is invoked.
| Transition nom::TransitionTable::resolve | ( | const IState & | active, |
| EventSymbol | event, | ||
| StateSymbol | stack_top ) const |
Resolve a transition with optional fallback.
Performs exact and wildcard lookups; if neither matches and a fallback resolver was installed, it is called with the active state, event, and stack-top symbol.
| void nom::TransitionTable::set_fallback | ( | Callback | callback | ) |
Install a fallback resolver.
Called when no exact or wildcard transition exists.
|
private |
Optional fallback resolver.
Definition at line 166 of file StateMachine.hpp.
|
private |
Exact-match transitions.
Definition at line 160 of file StateMachine.hpp.
|
private |
Wildcard transitions (stack top ignored).
Definition at line 163 of file StateMachine.hpp.