Main builder class for constructing FSMs with a fluent interface.
More...
#include <FSMBuilder.hpp>
|
using | Action = typename FSM< TEvent >::Action |
| Type alias for state actions.
|
|
template<typename TEvent>
class fsmgine::FSMBuilder< TEvent >
Main builder class for constructing FSMs with a fluent interface.
- Template Parameters
-
TEvent | The event type used for transitions |
FSMBuilder provides a fluent API for constructing finite state machines. It supports:
- Defining transitions between states
- Adding on-enter and on-exit actions to states
- Building complex state machines in a readable, declarative style
- Example
.onEnter("Idle", [](const MyEvent&) { std::cout << "Entering Idle\n"; })
.
onExit(
"Idle", [](
const MyEvent&) { std::cout <<
"Leaving Idle\n"; })
.predicate([](const MyEvent& e) { return e.type == "start"; })
.to("Running")
.predicate([](const MyEvent& e) { return e.type == "stop"; })
.to("Idle");
fsm.setInitialState(
"Idle");
FSMBuilder & onExit(const std::string &state, Action action)
Adds an action to execute when exiting a state.
Definition FSMBuilder.hpp:203
TransitionBuilder< TEvent > from(const std::string &state)
Starts building a transition from the specified state.
Definition FSMBuilder.hpp:186
A high-performance finite state machine implementation.
Definition FSM.hpp:94
Main namespace for the FSMgine library.
Definition FSM.hpp:23
◆ FSMBuilder()
template<typename TEvent >
Constructs a builder for the given FSM.
- Parameters
-
◆ from()
template<typename TEvent >
Starts building a transition from the specified state.
- Parameters
-
state | The source state for the transition |
- Returns
- A TransitionBuilder for defining the transition details
◆ onEnter()
template<typename TEvent >
Adds an action to execute when entering a state.
- Parameters
-
state | The state to add the action to |
action | The action to execute when entering the state |
- Returns
- Reference to this builder for method chaining
◆ onExit()
template<typename TEvent >
Adds an action to execute when exiting a state.
- Parameters
-
state | The state to add the action to |
action | The action to execute when exiting the state |
- Returns
- Reference to this builder for method chaining
The documentation for this class was generated from the following files: