User Manual, Developers Guide and API Documentation

wns::fsm::FSM< SIGNALS, VARIABLES > Class Template Reference

Finite State Machines for C++. More...

#include <fsm/FSM.hpp>

Inheritance diagram for wns::fsm::FSM< SIGNALS, VARIABLES >:

Inheritance graph
[legend]
Collaboration diagram for wns::fsm::FSM< SIGNALS, VARIABLES >:

Collaboration graph
[legend]

List of all members.

Public Types

typedef VARIABLES VariablesType
 Type of the Variables.

Public Member Functions

StateInterfacecreateState (const std::string &stateName)
 Creates the state the FSM shall change to.
template<typename NEWSTATE>
StateInterfacecreateState ()
 Creates the state the FSM shall change to.
 FSM (const VariablesType &v)
 Needs to be initialized with an object of VARIABLES.
std::string getStateName () const
 Returns the name of the current state.
VariablesTypegetVariables ()
 Returns a reference to the VARIABLES of the FSM.
void replaceState (SIGNALS *newState)
 Replaces the current state of the FSM.
virtual ~FSM ()
 Destructor.

Protected Member Functions

void changeState (SIGNALS *newState)
 Changes the state of the FSM (if necessary).
StateInterfacegetState () const
 Returns the current state.

Private Types

typedef FSMConfigCreator
< StateInterface
StateCreator
 StateFactory used for creation of states.
typedef wns::StaticFactory
< StateCreator
StateFactory

Private Attributes

StateInterfacecurrentState
 Current State of the FSM.
logger::Logger logger
 Logger.
bool stateCreated
 Helper variable.
VariablesType variables
 Variables of the FSM.

Classes

class  StateInterface
 Export the state interface to let others derive from this :). More...


Detailed Description

template<typename SIGNALS, typename VARIABLES>
class wns::fsm::FSM< SIGNALS, VARIABLES >

A Finite State Machine (FSM) is typically described by the signals it can receive, the variables it holds and possible states it might have at runtime. This template defines an FSM with two parameters: SIGNALS and VARIABLES

SIGNALS should be an abstract interface defining the signals the FSM can take. Each signal is represented by a method of the interface.

VARIABLES should be a struct/class containing the variables of the FSM.

The different states of this FSM are represented by different classes (or better objects of different classes).

See also:
How to write a Finite State Machine

Definition at line 66 of file FSM.hpp.


Member Typedef Documentation

template<typename SIGNALS, typename VARIABLES>
typedef FSMConfigCreator<StateInterface> wns::fsm::FSM< SIGNALS, VARIABLES >::StateCreator [private]

Definition at line 196 of file FSM.hpp.

template<typename SIGNALS, typename VARIABLES>
typedef wns::StaticFactory<StateCreator> wns::fsm::FSM< SIGNALS, VARIABLES >::StateFactory [private]

Definition at line 197 of file FSM.hpp.

template<typename SIGNALS, typename VARIABLES>
typedef VARIABLES wns::fsm::FSM< SIGNALS, VARIABLES >::VariablesType

Definition at line 72 of file FSM.hpp.


Constructor & Destructor Documentation

template<typename SIGNALS, typename VARIABLES>
wns::fsm::FSM< SIGNALS, VARIABLES >::FSM ( const VariablesType v  )  [inline, explicit]

Note:
VARIABLES v will be COPIED(!!) into the FSM.

Definition at line 160 of file FSM.hpp.

template<typename SIGNALS, typename VARIABLES>
virtual wns::fsm::FSM< SIGNALS, VARIABLES >::~FSM (  )  [inline, virtual]

Note:
If VARIABLES is a POINTER(!!) to a struct, it will not be deleted.

Definition at line 174 of file FSM.hpp.


Member Function Documentation

template<typename SIGNALS, typename VARIABLES>
void wns::fsm::FSM< SIGNALS, VARIABLES >::changeState ( SIGNALS newState  )  [inline, protected]

Definition at line 283 of file FSM.hpp.

template<typename SIGNALS, typename VARIABLES>
StateInterface* wns::fsm::FSM< SIGNALS, VARIABLES >::createState ( const std::string &  stateName  )  [inline]

Definition at line 204 of file FSM.hpp.

template<typename SIGNALS, typename VARIABLES>
template<typename NEWSTATE>
StateInterface* wns::fsm::FSM< SIGNALS, VARIABLES >::createState (  )  [inline]

Definition at line 184 of file FSM.hpp.

template<typename SIGNALS, typename VARIABLES>
StateInterface* wns::fsm::FSM< SIGNALS, VARIABLES >::getState (  )  const [inline, protected]

Definition at line 273 of file FSM.hpp.

template<typename SIGNALS, typename VARIABLES>
std::string wns::fsm::FSM< SIGNALS, VARIABLES >::getStateName (  )  const [inline]

May be used for testing purposes.

Definition at line 234 of file FSM.hpp.

template<typename SIGNALS, typename VARIABLES>
VariablesType& wns::fsm::FSM< SIGNALS, VARIABLES >::getVariables (  )  [inline]

This is to be used in the state objects in order to modify the variables of the FSM.

Definition at line 223 of file FSM.hpp.

template<typename SIGNALS, typename VARIABLES>
void wns::fsm::FSM< SIGNALS, VARIABLES >::replaceState ( SIGNALS newState  )  [inline]

Definition at line 243 of file FSM.hpp.


Member Data Documentation

template<typename SIGNALS, typename VARIABLES>
StateInterface* wns::fsm::FSM< SIGNALS, VARIABLES >::currentState [private]

Definition at line 314 of file FSM.hpp.

template<typename SIGNALS, typename VARIABLES>
logger::Logger wns::fsm::FSM< SIGNALS, VARIABLES >::logger [private]

Reimplemented in tcp::FiniteStateMachine.

Definition at line 324 of file FSM.hpp.

template<typename SIGNALS, typename VARIABLES>
bool wns::fsm::FSM< SIGNALS, VARIABLES >::stateCreated [private]

Definition at line 329 of file FSM.hpp.

template<typename SIGNALS, typename VARIABLES>
VariablesType wns::fsm::FSM< SIGNALS, VARIABLES >::variables [private]

Definition at line 319 of file FSM.hpp.


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

Generated on Sat May 26 03:32:54 2012 for openWNS by  doxygen 1.5.5