|
| FSM ()=default |
| Default constructor.
|
|
| FSM (const FSM &)=delete |
|
FSM & | operator= (const FSM &)=delete |
|
| FSM (FSM &&other) noexcept |
| Move constructor.
|
|
FSM & | operator= (FSM &&other) noexcept |
| Move assignment operator.
|
|
FSMBuilder< TEvent > | get_builder () |
| Creates a builder for fluent FSM construction.
|
|
void | setInitialState (std::string_view state) |
| Sets the initial state of the FSM.
|
|
void | setCurrentState (std::string_view state) |
| Changes the current state of the FSM.
|
|
std::string_view | getCurrentState () const |
| Gets the name of the current state.
|
|
bool | process (const TEvent &event) |
| Processes an event and potentially transitions to a new state.
|
|
bool | process () |
| Processes a transition for event-less FSMs.
|
|
template<typename TEvent = std::monostate>
class fsmgine::FSM< TEvent >
A high-performance finite state machine implementation.
- Template Parameters
-
TEvent | The event type used for transitions (defaults to std::monostate for event-less FSMs) |
The FSM class provides a flexible and efficient state machine implementation with the following features:
- Type-safe state and event handling
- Support for guards (predicates) and actions on transitions
- On-enter and on-exit actions for states
- String interning for optimized state name storage
- Thread-safety when using the FSMgineMT library variant
- Thread Safety
- The thread-safety of FSM operations depends on which library variant you're using:
- FSMgine: No thread synchronization, optimal for single-threaded applications
- FSMgineMT: Full thread-safety with mutex protection on all operations
- Example
struct Event { std::string type; };
.from("Idle").to("Working").when([](const Event& e) { return e.type == "start"; })
.from("Working").to("Idle").when([](const Event& e) { return e.type == "stop"; })
.build("Idle");
A high-performance finite state machine implementation.
Definition FSM.hpp:94
bool process(const TEvent &event)
Processes an event and potentially transitions to a new state.
Definition FSM.hpp:294
FSMBuilder< TEvent > get_builder()
Creates a builder for fluent FSM construction.
Definition FSM.hpp:227