CHSM  4.4.1
Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | List of all members
CHSM::transition Struct Reference

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...
 

Detailed Description

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.

Author
Paul J. Lucas

Member Typedef Documentation

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.

Parameters
triggerThe 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.

Parameters
triggerThe event that is causing the transition.
Returns
Returns true only if the condition evaluates to true.
typedef state*(machine::* CHSM::transition::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.

Parameters
triggerThe event that caused the transition.
Returns
Returns the state that the transition should go to or null to abort the transition.

Member Function Documentation

bool CHSM::transition::is_internal ( ) const
inline

Returns whether this transition is internal.

Returns
Returns true only if the transition is internal.

References target_, and to_id_.

bool CHSM::transition::is_legal ( state const *  s1,
state const *  s2 
)
static

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.

Parameters
s1One of the states.
s2The other state.
Returns
Returns true only if the transition is legal.

References CHSM::state::parent_of().

Member Data Documentation

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().


The documentation for this struct was generated from the following files: