Boost Licence Version Build Status Build Status Codecov Github Issues


Introduction

[Boost::ext].SML (State Machine Language/Lite/Library)
Your scalable C++14 one header only State Machine Library with no dependencies (Try it online!) GitHub
  Download        Changelog        Tutorial        Examples

UML State Machine

Do I need a State Machine?

State Machine design pattern prevents you from creating and maintaining spaghetti code.

void some_function() {
    ...
    if ((is_running && !is_jumping) || just_started) {
        ...
    } else if (is_boss_level && extra_feature_enabled && !ab_test) {
        ...
    } else {
        ...
    }
}

If above code looks somewhat similar to your code base or if you like to avoid it [Boost].SML may suit you!

Real Life examples?

CPP(BTN) CPP(BTN) CPP(BTN) CPP(BTN)

 

Why [Boost].SML?

  • Boost.MSM - eUML is awesome, however it has a few huge limitations making it unusable on a large scale projects; [Boost].SML, therefore, is trying to address those issues.

Problems with Boost.MSM - eUML

  • Long compilation times (see Performance)
  • Huge resulting binaries (see Performance)
  • Based on too many macros
  • Long error messages (see Error Messages)
  • Sometimes hard to follow as not all actions might be seen on transition table (ex. initial states, state entry/exit actions)
  • A lot of boilerplate code with actions/guards (requires fsm, event, source state, target state)
  • Data in states makes it harder to share/encapsulate (UML compliant though)
  • Loosely coupled design is hard to achieve
  • Functional programming emulation
  • Huge complexity may overwhelm in the beginning
  • A lot of Boost dependencies

[Boost].SML design goals

  • Keep the Boost.MSM - eUML 'goodies'
    • Performance (see Performance)
    • Memory usage (see Performance)
    • eUML DSL (src_state + event [ guard ] / action -> dst_state)
    • UML standard compliant (As much as possible)
  • Eliminate Boost.MSM - eUML problems
    • Compilation times (see Performance)
    • Binary size (see Performance)
    • Reduce complexity by eliminating less used features
    • Short and informative error messages (see Error Messages)
    • Less boilerplate / no macros (see Hello World)
    • Improve visibility by having all actions on transition table (see States)
    • Allows loosely coupled design (see Dependency Injection)
    • Functional programming support using lamda expressions (see Action/Guards)
    • No dependencies / one header (2k LOC)

What 'lite' implies?

  • Guaranteed quick compilation times
  • Maximized performance
  • No dependencies
  • Easy/Intuitive to use

Supported UML features

Additional features

Acknowledgements