Transition between a state and another state. More...
#include <stateMachine.h>
Public Attributes | |
int | eventType |
The event that will trigger this transition. | |
void * | condition |
Condition that event must fulfil. | |
bool(* | guard )(void *condition, struct event *event) |
Check if data passed with event fulfils a condition. | |
void(* | action )(struct event *event) |
Function containing tasks to be performed during the transition. | |
struct state * | nextState |
The next state. |
Transition between a state and another state.
All states that are not final must have at least one transition. Transitions are triggered by events. If a state has more than one transition with the same type of event (and the same condition), the first transition in the array will be run. A transition may optionally run a function action, which will have the triggering event passed to it as an argument.
It is perfectly valid for a transition to return to the state it belongs to. Such a transition will not call the state's state::entryAction or state::exitAction.
coordinateWithinLimits
checks whether the coordinate in the mouse event is within the limits of the "box".Function containing tasks to be performed during the transition.
The transition may optionally do some work in this function before entering the next state. May be NULL.
event | the event passed to the state machine. |
void* transition::condition |
Condition that event must fulfil.
This variable will be passed to guard (if guard is non-NULL) and may be used as a condition that the incoming event's data must fulfil in order for the transition to be performed. By using this variable, the number of guard functions can be minimized by making them more general.
Check if data passed with event fulfils a condition.
A transition may be conditional. If so, this function, if non-NULL, will be called. Its first argument will be supplied with condition, which can be compared againts event. The user may choose to use this argument or not. Only if the result is true, the transition will take place.
condition | event (data) to compare the incoming event against. |
event | the event passed to the state machine. |
true | if the event's data fulfils the condition, otherwise false. |
struct state* transition::nextState |
The next state.
This must point to the next state that will be entered. It cannot be NULL, but if it is, the state machine will detect it and enter the error state.