Builder for creating transitions with a fluent interface.
More...
#include <FSMBuilder.hpp>
|
using | Predicate = typename FSM< TEvent >::Predicate |
| Type alias for transition guard predicates.
|
|
using | Action = typename FSM< TEvent >::Action |
| Type alias for transition actions.
|
|
template<typename TEvent>
class fsmgine::TransitionBuilder< TEvent >
Builder for creating transitions with a fluent interface.
- Template Parameters
-
TEvent | The event type used for transitions |
TransitionBuilder provides a fluent API for defining transitions between states. It supports adding predicates (guards) and actions to transitions.
- Note
- TransitionBuilder instances are created by FSMBuilder::from() and should not be constructed directly.
- Example
.from("StateA")
.predicate([](const Event& e) { return e.type == "trigger"; })
.
action([](
const Event& e) { std::cout <<
"Transitioning!"; })
TransitionBuilder & action(Action action)
Adds an action to execute during the transition.
Definition FSMBuilder.hpp:166
void to(const std::string &state)
Completes the transition by specifying the target state.
Definition FSMBuilder.hpp:172
Main namespace for the FSMgine library.
Definition FSM.hpp:23
◆ TransitionBuilder()
template<typename TEvent >
Constructs a transition builder for a specific source state.
- Parameters
-
fsm | The FSM this transition belongs to |
from_state | The source state for this transition |
◆ action()
template<typename TEvent >
Adds an action to execute during the transition.
- Parameters
-
action | A function to execute when this transition occurs |
- Returns
- Reference to this builder for method chaining
- Note
- Multiple actions can be added; they execute in the order added
◆ predicate()
template<typename TEvent >
Adds a predicate (guard condition) to the transition.
- Parameters
-
pred | A function that returns true if the transition should occur |
- Returns
- Reference to this builder for method chaining
- Note
- Multiple predicates can be added; all must pass for the transition to occur
◆ to()
template<typename TEvent >
Completes the transition by specifying the target state.
- Parameters
-
state | The target state for this transition |
- Note
- This method finalizes and adds the transition to the FSM
The documentation for this class was generated from the following files: