-
Notifications
You must be signed in to change notification settings - Fork 23
Transition Guards
A transition guard is a predicate that can be used to select a transition based on some condition. A true value enables the transition, false - prohibits it.
struct condition_a {
template < typename FSM, typename State, typename Event >
bool
operator()(FSM const&, State const&, Event const&)
{
return some_knowledge() ? true : false;
}
};
struct condition_b {
template < typename FSM, typename State >
bool
operator()(FSM const&, State const& )
{
return some_knowledge() ? true : false;
}
};
The guard's operator()
is passed const references to the immediate enclosing state machine and current state. Optionally it can accept const reference to the event handled. If there is ambiguity (both signatures are defined and both can be used), the operator accepting more parameters is selected.
The predicates can be negated by ::psst::meta::not_
template, e.g. not_<condition_a>
. The ::psst::meta::not_
has a type alias not_
defined inside ::afsm::def::state
and ::afsm::def::state_machine
templates.
Predicates can be combined by ::psst::meta::and_
and ::psst::meta::or_
templates, e.g. and_< condition_a, not_<condition_b> >
. Type aliases for those templates inside ::afsm::def::state
and ::afsm::def::state_machine
templates are and_
and or_
respectively.
- Home
- Tutorial
-
Concepts
- State Hierarchy
- Entry/Exit Actions
- Transition Actions
- Transition Guards
- Internal Transitions
- Default Transitions
- Event Deferring
- History
- Orthogonal Regions
- Event Priority
- Common Base
- Thread Safety
- Exception Safety Guarantees
- Under the Hood
- Event Processing
- Performance