StateMachine Class Reference

#include <StateMachine.h>

Inheritance diagram for StateMachine:
ListenerObject

# Public Member Functions

void constructor (void *owner)
 Class' constructor.
override bool handleMessage (Telegram telegram)
bool transitionTo (State state, int16 command)
void swapState (State newState)
void pushState (State newState)
void popState ()
 Pop the top most state in the stack.
void popAllStates ()
 Pop all the states in the stack and leave it empty.
State update ()
 Updates the state at the top of the stack.
bool isInState (State state)
bool hasStateInTheStack (State state)
VirtualList getStateStack ()
State getCurrentState ()
State getNextState ()
State getPreviousState ()
int32 getStackSize ()

# Protected Attributes

void * owner
 Owner of this instance.
VirtualList stateStack
 Linked list of states.
State currentState
 State at the top of the stack of states.
State previousState
 Previous state at the top of the stack of states.
State nextState
 State to push on top of the stack of states.
int16 transition
 Enum that determines the next state transition.

# Additional Inherited Members

- Private Member Functions inherited from ListenerObject
void constructor ()
 Class' constructor.
void destructor ()
 Class' destructor.
void addEventListener (ListenerObject listener, uint16 eventCode)
void removeEventListener (ListenerObject listener, uint16 eventCode)
void removeEventListeners (uint16 eventCode)
void removeAllEventListeners ()
 Remove all listener objects.
bool hasActiveEventListeners ()
void fireEvent (uint16 eventCode)
void sendMessageTo (ListenerObject receiver, uint32 message, uint32 delay, uint32 randomDelay)
void sendMessageToSelf (uint32 message, uint32 delay, uint32 randomDelay)
void discardAllMessages ()
 Discard all messages, both to be sent and to be received.
void discardMessages (uint32 message)
virtual bool onEvent (ListenerObject eventFirer, uint16 eventCode)
- Private Attributes inherited from ListenerObject
VirtualList events
 List of registered events.
int8 eventFirings
 Counter that keeps track of the number of fired events to prevent race conditions in nested firings.

# Detailed Description

Class StateMachine

Inherits from ListenerObject

Implements a behavioral model of finite states.

Definition at line 49 of file StateMachine.h.

# Member Function Documentation

# constructor()

void StateMachine::constructor ( void * owner)

Class' constructor.

Definition at line 33 of file StateMachine.c.

# getCurrentState()

State StateMachine::getCurrentState ( )

Retrieve the state at the top of the stack.

Returns
State at the top of the stack of states

Definition at line 244 of file StateMachine.c.

# getNextState()

State StateMachine::getNextState ( )

Retrieve the state that the machine is pending transition to.

Returns
State that the machine has to transition to

Definition at line 251 of file StateMachine.c.

# getPreviousState()

State StateMachine::getPreviousState ( )

Retrieve the state that was before at the top of the stack.

Returns
State: the state that was previously at the top of the stack

Definition at line 258 of file StateMachine.c.

# getStackSize()

int32 StateMachine::getStackSize ( )

Retrieve the number of states in the stack.

Returns
Number of states in the stack

Definition at line 274 of file StateMachine.c.

# getStateStack()

VirtualList StateMachine::getStateStack ( )

Retrieve the stack of states.

Returns
Linked list of states

Definition at line 237 of file StateMachine.c.

# handleMessage()

bool StateMachine::handleMessage ( Telegram telegram)
virtual

Process a Telegram.

Parameters
telegramTelegram to process
Returns
True if the Telegram was processed

Reimplemented from ListenerObject.

Definition at line 73 of file StateMachine.c.

# hasStateInTheStack()

bool StateMachine::hasStateInTheStack ( State state)

Check if the provided state is in the stack.

Parameters
stateState to check
Returns
true if the provided state is in the stack

Definition at line 230 of file StateMachine.c.

# isInState()

bool StateMachine::isInState ( State state)

Check if the top most state in the stack is the provided one.

Parameters
stateState to compare against the state at the top of the stack
Returns
true if the provided state is the top most state in the stack

Definition at line 223 of file StateMachine.c.

# popAllStates()

void StateMachine::popAllStates ( )

Pop all the states in the stack and leave it empty.

Definition at line 200 of file StateMachine.c.

# popState()

void StateMachine::popState ( )

Pop the top most state in the stack.

Definition at line 169 of file StateMachine.c.

# pushState()

void StateMachine::pushState ( State newState)

Push the provided state at the top of the stack.

Parameters
newStateState to push at the top of the stack

Definition at line 141 of file StateMachine.c.

# swapState()

void StateMachine::swapState ( State newState)

Swap the state at the top of the stack by the provided state.

Parameters
newStateState to put at the top of the stack

Definition at line 105 of file StateMachine.c.

# transitionTo()

bool StateMachine::transitionTo ( State state,
int16 command )

Instructs the machine to change to the provided state by the transition specified by command

Parameters
stateState to transition to
commandEnum that specifies the type of transition defined in StateOperations
Returns
true if the machine is not scheduled for a transition already, false otherwise

Definition at line 85 of file StateMachine.c.

# update()

State StateMachine::update ( )

Updates the state at the top of the stack.

Definition at line 207 of file StateMachine.c.

# Member Data Documentation

# currentState

State StateMachine::currentState
protected

State at the top of the stack of states.

Definition at line 60 of file StateMachine.h.

# nextState

State StateMachine::nextState
protected

State to push on top of the stack of states.

Definition at line 66 of file StateMachine.h.

# owner

void* StateMachine::owner
protected

Owner of this instance.

Definition at line 54 of file StateMachine.h.

# previousState

State StateMachine::previousState
protected

Previous state at the top of the stack of states.

Definition at line 63 of file StateMachine.h.

# stateStack

VirtualList StateMachine::stateStack
protected

Linked list of states.

Definition at line 57 of file StateMachine.h.

# transition

int16 StateMachine::transition
protected

Enum that determines the next state transition.

Definition at line 69 of file StateMachine.h.


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