Boost C++ Libraries

...one of the most highly regarded and expertly designed C++ library projects in the world. Herb Sutter and Andrei Alexandrescu, C++ Coding Standards

Chapter 3. Tutorial

Table of Contents

Design
Basic front-end
A simple example
Transition table
Defining states with entry/exit actions
What do you actually do inside actions / guards?
Defining a simple state machine
Defining a submachine
Orthogonal regions, terminate state, event deferring
History
Completion (anonymous) transitions
Internal transitions
more row types
Explicit entry / entry and exit pseudo-state / fork
Flags
Event Hierarchy
Customizing a state machine / Getting more speed
Choosing the initial event
Containing state machine (deprecated)
Functor front-end
Transition table
Defining states with entry/exit actions
What do you actually do inside actions / guards (Part 2)?
Defining a simple state machine
Anonymous transitions
Internal transitions
Kleene (any) event
PUML (C++-20), experimental
PlantUML basics
Composite State Machines
eUML
Transition table
A simple example: rewriting only our transition table
Defining events, actions and states with entry/exit actions
Wrapping up a simple state machine and first complete examples
Defining a submachine
Attributes / Function call
Orthogonal regions, flags, event deferring
Customizing a state machine / Getting more speed
Completion / Anonymous transitions
Internal transitions
Kleene(any) event)
Other state types
Helper functions
Phoenix-like STL support
Writing actions with Boost.Phoenix (in development)
Back-end
Creation
Starting and stopping a state machine
Event dispatching
Active state(s)
Upper State Machine (msm::back11 only)
Serialization
Base state type
Visitor
Flags
Getting a state
State machine constructor with arguments
Trading run-time speed for better compile-time / multi-TU compilation (msm::back only)
Compile-time state machine analysis
Enqueueing events for later processing
Customizing the message queues
Policy definition with Boost.Parameter
Choosing when to switch active states

Design

MSM is divided between front–ends and back-ends. At the moment, there is just one back-end. On the front-end side, you will find three of them which are as many state machine description languages, with many more possible. For potential language writers, this document contains a description of the interface between front-end and back-end.

The first front-end is an adaptation of the example provided in the MPL book with actions defined as pointers to state or state machine methods. The second one is based on functors. The third, eUML (embedded UML) is an experimental language based on Boost.Proto and Boost.Typeof and hiding most of the metaprogramming to increase readability. Both eUML and the functor front-end also offer a functional library (a bit like Boost.Phoenix) for use as action language (UML defining none).