FSMgine
High-performance finite state machine library for C++17 with single-threaded and multi-threaded variants
Loading...
Searching...
No Matches
FSMgine.hpp File Reference

Main header file for the FSMgine library. More...

#include <variant>
#include "FSMgine/StringInterner.hpp"
#include "FSMgine/Transition.hpp"
#include "FSMgine/FSM.hpp"
#include "FSMgine/FSMBuilder.hpp"
Include dependency graph for FSMgine.hpp:

Go to the source code of this file.

Namespaces

namespace  fsm
 Convenience namespace alias for fsmgine.
 
namespace  fsmgine
 Main namespace for the FSMgine library.
 

Typedefs

using fsmgine::EventlessFSM = FSM<>
 Type alias for event-less finite state machines.
 

Detailed Description

Main header file for the FSMgine library.

Introduction

FSMgine is a high-performance finite state machine library for C++17, available in both single-threaded and multi-threaded variants.

Features

  • Type-safe state and event handling
  • Support for both event-driven and event-less FSMs
  • Compile-time optimizations with string interning
  • Two library variants: FSMgine (single-threaded) and FSMgineMT (multi-threaded)
  • Fluent builder API for easy FSM construction

Library Variants

FSMgine provides two library variants:

  • FSMgine: Single-threaded variant with no synchronization overhead
  • FSMgineMT: Multi-threaded variant with mutex-based thread safety

Choose the appropriate variant based on your application's threading requirements.

Basic Usage

// Event-less FSM example
turnstile.get_builder()
.from("Locked").predicate([](const auto&) { return true; }).to("Unlocked")
.from("Unlocked").predicate([](const auto&) { return true; }).to("Locked");
turnstile.setInitialState("Locked");
Main header file for the FSMgine library.
A high-performance finite state machine implementation.
Definition FSM.hpp:94
FSMBuilder< TEvent > get_builder()
Creates a builder for fluent FSM construction.
Definition FSM.hpp:227
void setInitialState(std::string_view state)
Sets the initial state of the FSM.
Definition FSM.hpp:232

Linking

# For single-threaded applications:
find_package(FSMgine REQUIRED)
target_link_libraries(my_app PRIVATE FSMgine::FSMgine)
# For multi-threaded applications:
find_package(FSMgineMT REQUIRED)
target_link_libraries(my_app PRIVATE FSMgine::FSMgineMT)

Modules