Code a minimal SMACC State Machine

In this initial example we will implement a simple state machine with a single state state that executes something at state entry and at state exit. That state machine is described in the following image:

SMACC StateMachines and SmaccStates are based on the c++ Curiously recurring template pattern so that the syntax may be strange for some developers but you will notice that it is very easy to follow. The advantage of using this kind of c++ pattern is that the definition of the state machine is correctly written.

The following chunk of code shows the minimal SMACC State machine you can create:

#include <smacc/smacc_state_machine_base.h>

struct SimpleStateMachine
    : public SmaccStateMachineBase<SimpleStateMachine,ToolSimpleState>
{
  using SmaccState::SmaccState;
  void onEntry()
  {
  }
};

Every SMACC State Machine must inherit from SmaccStateMachineBase. The first template parameter is the derived class type (SimpleStateMachine itself) according to the curiosuly recurring template pattern, and the second template parameter (ToolSimpleState) would be the class name of the initial Smacc State