Guard

A guard is a functor that returns a bool value. It takes an event as parameter for evaluation. A guard provides the ability to control if a transition is enabled or not. A guard is evaluated if the source of the transition is active and the ID of the event matches one of the triggers of the transition. A transition is only executed when its guard evaluates to true. If no guard is given then the default is used which always evaluates to true.

The guard is represented by the "constraint" class in yasmine. It is used mostly as a unique pointer.

using constraint_uptr = std::unique_ptr< constraint >;

The default initialization value of a guard when adding a transition to a state machine is an empty functor. This means that no constraint will be created resulting in the transition's guard check always being evaluated as true.

using constraint_function = std::function< bool ( const event& ) >;