CHSM
4.4.1
|
A transition is a simple struct
containing information for a transition from one state to another in a machine.
More...
#include <chsm.h>
Public Types | |
typedef void(machine::* | action )(event const &trigger) |
An action is a function to be executed upon performing a transition from one state to another. More... | |
typedef bool(machine::* | condition )(event const &trigger) |
A condition is a function to be evaluated prior to a transition being performed. More... | |
typedef state *(machine::* | target )(event const &trigger) |
A target is a function to be evaluated prior to a transition being performed to determine the state to transition to. More... | |
Public Member Functions | |
bool | is_internal () const |
Returns whether this transition is internal. More... | |
Static Public Member Functions | |
static bool | is_legal (state const *s1, state const *s2) |
Checks whether a transition between the two given statess would be legal. More... | |
Public Attributes | |
action | action_ |
The action to be performed, if any. More... | |
condition | condition_ |
The condition to be evaluated prior to a transition being performed, if any. More... | |
state::id | from_id_ |
The state this transition is transitioning from. More... | |
target | target_ |
The target function to be evaluated prior to a transition being performed to determine the state to transition to, if any. More... | |
state::id | to_id_ |
The state this transition is transitioning to. More... | |
A transition is a simple struct
containing information for a transition from one state to another in a machine.
The information contains whether the transition has an associated condition to test prior to taking it, the "from" and "to" states, and an optional action to be performed.
All the data members ideally should be declared const
. In the code emitted by the CHSM-to-C++ compiler, we want to be able to use aggregate initialization, but C++ does not permit aggregates to have const
data members (see section 8.5.1 of the ANSI/ISO C++ reference manual), so we leave the const
out. However, the code emitted declares the aggregate as a whole to be const
, so it amounts to the same thing.
typedef void(machine::* CHSM::transition::action)(event const &trigger) |
An action is a function to be executed upon performing a transition from one state to another.
trigger | The event that caused the transition. |
typedef bool(machine::* CHSM::transition::condition)(event const &trigger) |
A condition is a function to be evaluated prior to a transition being performed.
The transition is performed only if the function returns true
.
trigger | The event that is causing the transition. |
true
only if the condition evaluates to true
. A target is a function to be evaluated prior to a transition being performed to determine the state to transition to.
trigger | The event that caused the transition. |
null
to abort the transition.
|
inline |
Checks whether a transition between the two given statess would be legal.
A transition is illegal only if the two states' nearest common ancestor is a CHSM::set.
s1 | One of the states. |
s2 | The other state. |
true
only if the transition is legal. References CHSM::state::parent_of().
action CHSM::transition::action_ |
The action to be performed, if any.
condition CHSM::transition::condition_ |
The condition to be evaluated prior to a transition being performed, if any.
state::id CHSM::transition::from_id_ |
The state this transition is transitioning from.
target CHSM::transition::target_ |
The target function to be evaluated prior to a transition being performed to determine the state to transition to, if any.
Referenced by is_internal().
state::id CHSM::transition::to_id_ |
The state this transition is transitioning to.
Referenced by is_internal().