Public Member Functions | Private Attributes
StateMachine< StateEnumT > Class Template Reference

Generic state machine implementation. More...

#include <StateMachine.h>

List of all members.

Public Member Functions

void addState (StateEnumT state, std::string name)
 Register a new state id and its description. Used by ADD_MACHINE_STATE()
StateEnumT historyState (unsigned steps)
std::string info ()
void setHistoryLength (unsigned historyLength)
 Set maximal number of entries in state history.
void setLastState ()
 Reverse state to previous one.
void setName (std::string name)
 Set machine name.
void setState (StateEnumT state)
 Change the machine's state.
StateEnumT state ()
 StateMachine ()
 The constructor.
std::string stateString ()
std::string stateString (StateEnumT state)
unsigned timeSinceStateChange ()
 Milliseconds since last state change.
 ~StateMachine ()
 The destructor.

Private Attributes

unsigned m_HistoryLength
unsigned m_LastStateChange
std::string m_Name
StateEnumT m_State
std::deque< StateEnumT > m_StateHistory
std::map< StateEnumT, std::string > m_StateNames

Detailed Description

template<typename StateEnumT>
class StateMachine< StateEnumT >

Generic state machine implementation.

Author:
David Gossow (RX)

Definition at line 31 of file StateMachine.h.


Constructor & Destructor Documentation

template<typename StateEnumT >
StateMachine< StateEnumT >::StateMachine ( )

The constructor.

Definition at line 96 of file StateMachine.h.

template<typename StateEnumT >
StateMachine< StateEnumT >::~StateMachine ( )

The destructor.

Definition at line 105 of file StateMachine.h.


Member Function Documentation

template<typename StateEnumT >
void StateMachine< StateEnumT >::addState ( StateEnumT  state,
std::string  name 
) [inline]

Register a new state id and its description. Used by ADD_MACHINE_STATE()

Definition at line 48 of file StateMachine.h.

template<typename StateEnumT >
StateEnumT StateMachine< StateEnumT >::historyState ( unsigned  steps)
Returns:
previous state (starting at index 0)

Definition at line 122 of file StateMachine.h.

template<typename StateEnumT >
std::string StateMachine< StateEnumT >::info ( )
Returns:
extensive information about the machine's properties, history etc.

Definition at line 182 of file StateMachine.h.

template<typename StateEnumT >
void StateMachine< StateEnumT >::setHistoryLength ( unsigned  historyLength) [inline]

Set maximal number of entries in state history.

Definition at line 45 of file StateMachine.h.

template<typename StateEnumT >
void StateMachine< StateEnumT >::setLastState ( )

Reverse state to previous one.

Definition at line 168 of file StateMachine.h.

template<typename StateEnumT >
void StateMachine< StateEnumT >::setName ( std::string  name) [inline]

Set machine name.

Definition at line 42 of file StateMachine.h.

template<typename StateEnumT >
void StateMachine< StateEnumT >::setState ( StateEnumT  state)

Change the machine's state.

Definition at line 139 of file StateMachine.h.

template<typename StateEnumT >
StateEnumT StateMachine< StateEnumT >::state ( ) [inline]
Returns:
current machine state

Definition at line 51 of file StateMachine.h.

template<typename StateEnumT >
std::string StateMachine< StateEnumT >::stateString ( ) [inline]
Returns:
textual description of machine name and current state

Definition at line 57 of file StateMachine.h.

template<typename StateEnumT >
std::string StateMachine< StateEnumT >::stateString ( StateEnumT  state)
Returns:
textual description of given state

Definition at line 110 of file StateMachine.h.

template<typename StateEnumT >
unsigned StateMachine< StateEnumT >::timeSinceStateChange ( )

Milliseconds since last state change.

Definition at line 90 of file StateMachine.h.


Member Data Documentation

template<typename StateEnumT >
unsigned StateMachine< StateEnumT >::m_HistoryLength [private]

Definition at line 85 of file StateMachine.h.

template<typename StateEnumT >
unsigned StateMachine< StateEnumT >::m_LastStateChange [private]

Definition at line 82 of file StateMachine.h.

template<typename StateEnumT >
std::string StateMachine< StateEnumT >::m_Name [private]

Definition at line 80 of file StateMachine.h.

template<typename StateEnumT >
StateEnumT StateMachine< StateEnumT >::m_State [private]

Definition at line 76 of file StateMachine.h.

template<typename StateEnumT >
std::deque<StateEnumT> StateMachine< StateEnumT >::m_StateHistory [private]

Definition at line 84 of file StateMachine.h.

template<typename StateEnumT >
std::map< StateEnumT, std::string > StateMachine< StateEnumT >::m_StateNames [private]

Definition at line 78 of file StateMachine.h.


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


robbie_architecture
Author(s): Viktor Seib
autogenerated on Mon Oct 6 2014 02:53:09