36template<
typename TEvent>
74 void to(
const std::string& state);
78 std::string_view from_state_;
111template<
typename TEvent>
154template<
typename TEvent>
156 : fsm_(
fsm), from_state_(from_state) {
159template<
typename TEvent>
161 transition_.addPredicate(std::move(pred));
165template<
typename TEvent>
167 transition_.addAction(std::move(action));
171template<
typename TEvent>
175 auto interned_state = interner.intern(state);
176 transition_.setTargetState(interned_state);
177 fsm_.addTransition(from_state_, std::move(transition_));
181template<
typename TEvent>
185template<
typename TEvent>
189 auto interned_state = interner.intern(state);
193template<
typename TEvent>
197 auto interned_state = interner.intern(state);
198 fsm_.addOnEnterAction(interned_state, std::move(action));
202template<
typename TEvent>
206 auto interned_state = interner.intern(state);
207 fsm_.addOnExitAction(interned_state, std::move(action));
Core finite state machine implementation.
String interning utility for memory-efficient state name storage.
State transition representation with guards and actions.
Main builder class for constructing FSMs with a fluent interface.
Definition FSMBuilder.hpp:112
FSMBuilder & onEnter(const std::string &state, Action action)
Adds an action to execute when entering a state.
Definition FSMBuilder.hpp:194
FSMBuilder & operator=(FSMBuilder &&)=default
Move assignment operator (defaulted)
FSMBuilder & onExit(const std::string &state, Action action)
Adds an action to execute when exiting a state.
Definition FSMBuilder.hpp:203
FSMBuilder(FSMBuilder &&)=default
Move constructor (defaulted)
typename FSM< TEvent >::Action Action
Type alias for state actions.
Definition FSMBuilder.hpp:115
TransitionBuilder< TEvent > from(const std::string &state)
Starts building a transition from the specified state.
Definition FSMBuilder.hpp:186
FSMBuilder(FSM< TEvent > &fsm)
Constructs a builder for the given FSM.
Definition FSMBuilder.hpp:182
A high-performance finite state machine implementation.
Definition FSM.hpp:94
std::function< void(const TEvent &)> Action
Type alias for transition actions.
Definition FSM.hpp:102
std::function< bool(const TEvent &)> Predicate
Type alias for transition predicates.
Definition FSM.hpp:98
static StringInterner & instance()
Gets the singleton instance of StringInterner.
Builder for creating transitions with a fluent interface.
Definition FSMBuilder.hpp:37
TransitionBuilder(FSM< TEvent > &fsm, std::string_view from_state)
Constructs a transition builder for a specific source state.
Definition FSMBuilder.hpp:155
TransitionBuilder & action(Action action)
Adds an action to execute during the transition.
Definition FSMBuilder.hpp:166
TransitionBuilder(TransitionBuilder &&)=default
Move constructor (defaulted)
typename FSM< TEvent >::Action Action
Type alias for transition actions.
Definition FSMBuilder.hpp:43
TransitionBuilder & predicate(Predicate pred)
Adds a predicate (guard condition) to the transition.
Definition FSMBuilder.hpp:160
TransitionBuilder & operator=(TransitionBuilder &&)=default
Move assignment operator (defaulted)
void to(const std::string &state)
Completes the transition by specifying the target state.
Definition FSMBuilder.hpp:172
typename FSM< TEvent >::Predicate Predicate
Type alias for transition guard predicates.
Definition FSMBuilder.hpp:40
Represents a transition between states in a finite state machine.
Definition Transition.hpp:41
Main namespace for the FSMgine library.
Definition FSM.hpp:23