IGSTK
Public Types | Public Member Functions | Protected Member Functions
igstk::StateMachine< TClass > Class Template Reference

Generic implementation of the State Machine model. More...

#include <igstkStateMachine.h>

List of all members.

Public Types

typedef StateMachineState< TClass > StateType
 Type used to represent the codes of the states.
typedef StateType::IdentifierType StateIdentifierType
 Type used to represent the unique identifier of the states.
typedef StateMachineInput< TClass > InputType
 Type used to represent the codes of the inputs.
typedef InputType::IdentifierType InputIdentifierType
 Type used to represent the unique identifier of the inputs.
typedef std::string StateDescriptorType
 Type for the description of the States.
typedef std::string InputDescriptorType
 Type for the description of the Inputs.
typedef void(TClass::* TMemberFunctionPointer )()
 Type of the action member funtion of TClass to be invoked at the end of a state transition.
typedef TMemberFunctionPointer ActionType
 Type for the Action to be taken.
typedef std::ostream OutputStreamType
 This extra typedef is necessary for preventing an Internal Compiler Error in Microsoft Visual C++ 6.0.

Public Member Functions

 StateMachine (TClass *)
 Constructor.
 ~StateMachine ()
 Destructor.
void PushInput (const InputType &input)
 Push a new input in the queue of inputs to be processed.
void PushInputBoolean (bool condition, const InputType &inputIfTrue, const InputType &inputIfFalse)
 Push one of two inputs onto the queue, according two whether a condition is true or false.
void ProcessInputs ()
 Perform the state transition and invoke the corresponding action for every pending input stored in the input queue.
void AddTransition (const StateType &state, const InputType &input, const StateType &newstate, const ActionType &action)
 Set the new state to be assume as a reaction to receiving the input code while the StateMachine is in state.
void SetReadyToRun ()
 This method terminates the programming mode in which AddTransition() can be invoked and pass to the runnin mode where ProcessInput() can be called.
void AddState (const StateType &state, const StateDescriptorType &description)
 Set the descriptor of a state.
void AddInput (const InputType &input, const InputDescriptorType &description)
 Set the descriptor of an input.
void ExportDescription (OutputStreamType &ostr, bool skipLoops) const
 Export the schematic description of the state machine to a stream.
void ExportDescriptionToLTS (OutputStreamType &ostr, bool skipLoops) const
 Export the schematic description of the state machine to a stream.
void ExportDescriptionToSCXML (OutputStreamType &ostr, bool skipLoops) const
 Export the schematic description of the state machine to a stream.
void SelectInitialState (const StateType &initialState)
 Select Initial state.
void Print (std::ostream &os, itk::Indent indent) const
 Print out the content of the class.

Protected Member Functions

void PrintSelf (std::ostream &os, itk::Indent indent) const
 Print the object information in a stream.
void ProcessInput (const InputIdentifierType &input)
 Perform the state transition, invoke the corresponding action.

Detailed Description

template<class TClass>
class igstk::StateMachine< TClass >

Generic implementation of the State Machine model.

This class provides a generic implementation of a state machine that can be instantiated as member of any other class.

A state machine is defined by a set of states, a set of inputs and a transition matrix that defines for each pair of (state,input) what is the next state to assume.

See also:
StateMachineState
StateMachineInput
StateMachineAction

Definition at line 51 of file igstkStateMachine.h.


Member Typedef Documentation

template<class TClass >
typedef StateMachineState<TClass> igstk::StateMachine< TClass >::StateType

Type used to represent the codes of the states.

Definition at line 57 of file igstkStateMachine.h.

template<class TClass >
typedef StateType::IdentifierType igstk::StateMachine< TClass >::StateIdentifierType

Type used to represent the unique identifier of the states.

Definition at line 60 of file igstkStateMachine.h.

template<class TClass >
typedef StateMachineInput<TClass> igstk::StateMachine< TClass >::InputType

Type used to represent the codes of the inputs.

Definition at line 63 of file igstkStateMachine.h.

template<class TClass >
typedef InputType::IdentifierType igstk::StateMachine< TClass >::InputIdentifierType

Type used to represent the unique identifier of the inputs.

Definition at line 66 of file igstkStateMachine.h.

template<class TClass >
typedef std::string igstk::StateMachine< TClass >::StateDescriptorType

Type for the description of the States.

Definition at line 69 of file igstkStateMachine.h.

template<class TClass >
typedef std::string igstk::StateMachine< TClass >::InputDescriptorType

Type for the description of the Inputs.

Definition at line 72 of file igstkStateMachine.h.

template<class TClass >
typedef void(TClass::* igstk::StateMachine< TClass >::TMemberFunctionPointer)()

Type of the action member funtion of TClass to be invoked at the end of a state transition.

Definition at line 76 of file igstkStateMachine.h.

template<class TClass >
typedef TMemberFunctionPointer igstk::StateMachine< TClass >::ActionType

Type for the Action to be taken.

This is a pointer to a method of the class that will own the State Machine

Definition at line 80 of file igstkStateMachine.h.

template<class TClass >
typedef std::ostream igstk::StateMachine< TClass >::OutputStreamType

This extra typedef is necessary for preventing an Internal Compiler Error in Microsoft Visual C++ 6.0.

This typedef is not needed for any other compiler.

Definition at line 129 of file igstkStateMachine.h.


Constructor & Destructor Documentation

template<class TClass >
igstk::StateMachine< TClass >::StateMachine ( TClass *  )

Constructor.

It initialize all the transitions to the start state.

template<class TClass >
igstk::StateMachine< TClass >::~StateMachine ( )

Destructor.


Member Function Documentation

template<class TClass >
void igstk::StateMachine< TClass >::PushInput ( const InputType input)

Push a new input in the queue of inputs to be processed.

template<class TClass >
void igstk::StateMachine< TClass >::PushInputBoolean ( bool  condition,
const InputType inputIfTrue,
const InputType inputIfFalse 
)

Push one of two inputs onto the queue, according two whether a condition is true or false.

template<class TClass >
void igstk::StateMachine< TClass >::ProcessInputs ( )

Perform the state transition and invoke the corresponding action for every pending input stored in the input queue.

template<class TClass >
void igstk::StateMachine< TClass >::AddTransition ( const StateType state,
const InputType input,
const StateType newstate,
const ActionType action 
)

Set the new state to be assume as a reaction to receiving the input code while the StateMachine is in state.

The action is a member method of the TClass that will be invoked just before changing the state. The AddTransition() method is the mechanism used for programming the state machine. This method should never be invoked while the state machine is running. Unless you want to debug a self-modifying machine or an evolutionary machine.

template<class TClass >
void igstk::StateMachine< TClass >::SetReadyToRun ( )

This method terminates the programming mode in which AddTransition() can be invoked and pass to the runnin mode where ProcessInput() can be called.

template<class TClass >
void igstk::StateMachine< TClass >::AddState ( const StateType state,
const StateDescriptorType description 
)

Set the descriptor of a state.

template<class TClass >
void igstk::StateMachine< TClass >::AddInput ( const InputType input,
const InputDescriptorType description 
)

Set the descriptor of an input.

template<class TClass >
void igstk::StateMachine< TClass >::ExportDescription ( OutputStreamType ostr,
bool  skipLoops 
) const

Export the schematic description of the state machine to a stream.

This method use the format required as input by the "dot" tool from graphviz.

template<class TClass >
void igstk::StateMachine< TClass >::ExportDescriptionToLTS ( OutputStreamType ostr,
bool  skipLoops 
) const

Export the schematic description of the state machine to a stream.

This method use the format required as input by the "LTSA" analysis tools. LTSA (Labeled Transition Systems Analyzer) available from http://www-dse.doc.ic.ac.uk/concurrency.

template<class TClass >
void igstk::StateMachine< TClass >::ExportDescriptionToSCXML ( OutputStreamType ostr,
bool  skipLoops 
) const

Export the schematic description of the state machine to a stream.

This method use the "SCXML" format.

template<class TClass >
void igstk::StateMachine< TClass >::SelectInitialState ( const StateType initialState)

Select Initial state.

template<class TClass >
void igstk::StateMachine< TClass >::Print ( std::ostream &  os,
itk::Indent  indent 
) const

Print out the content of the class.

template<class TClass >
void igstk::StateMachine< TClass >::PrintSelf ( std::ostream &  os,
itk::Indent  indent 
) const [protected]

Print the object information in a stream.

template<class TClass >
void igstk::StateMachine< TClass >::ProcessInput ( const InputIdentifierType input) [protected]

Perform the state transition, invoke the corresponding action.

This is the method that is systematically executed when the state machine is running


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