Main Page | Modules | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members | Related Pages

FsmState Class Reference
[Finite State Machines]

#include <FsmState.h>

Inheritance diagram for FsmState:

CC_RootObject DC_AfsFsmState DC_DummyConfigurableFsmState DC_DummyFsmState DC_NestedFsmActivator DC_OCM_FsmState DC_SBY_PostSepFsmState DC_SBY_PreSepFsmState DC_SCM_FsmState DC_SM_PreSepFsmState DC_UnstableFsmState List of all members.

Detailed Description

Base class from which all FsmState classes are derived.

An FsmState class encapsulates a state of an finite state machine (FSM).

This is an abstract class that declares abstract methods to implement: the actions associated to the FsmState and the checks associated to the FsmState. Concrete methods are also defined to implement configuration operations.

An FsmState can execute three types of actions. An initialization action that is a punctual action performed immediately after the state is entered. A continuation action that is an action performed every time the state is activated. A termination action that is a punctual action that is performed immediately before the state is exited. This class provides default implementation for the initialization and termination actions that do not do anything.

An FsmState performs three types of checks. An initialization check that checks whether the state can be entered. A exit check that checks whether the state can be exited. A termination check that checks whether the state has terminated execution and is ready to perform an autonomous state transition. This class provides default implementations for the initialization and exit checks that always return true (check is passed).

An FsmState holds a reference to a next state. This represents the state to which the current state wants to perform an autonomous transition after it has performed all its actions. FsmStates however are "passive" objects and state transitions are under the control of the FSM. This class provides a default implementation that returns a null pointer for the next state signifying that there is no next state.

See also:
CC_FSM
Author:
Alessandro Pasetti (P&P Software GmbH)
Version:
1.0

Definition at line 63 of file FsmState.h.

Public Member Functions

 FsmState (void)
 Instantiate an FsmState object.

virtual bool canEnter (void)
 Perform the entry check and return false if a transition into this state would put the system in an inconsistent or otherwise undesirable condition.

virtual void doInit (void)
 Perform the initialization action associated to the FsmState.

virtual bool canExit (void)
 Perform the exit check and return false if performing a transition out of the this state would leave the system in an inconsistent or otherwise undesirable condition.

virtual void doContinue (void)=0
 Perform the continued action associated to this state.

virtual void doExit (void)
 Perform the exit action associated to this state.

virtual bool isFinished (void)
 Perform a termination check and return true if the continued action associated to this state has been completed and an autonomous transition to a next state should be performed.

void setNextState (FsmState *pNextState)
 Set the next state associated to this state.

FsmStategetNextState (void) const
 Return the next state associated to this state.


Constructor & Destructor Documentation

FsmState::FsmState void   ) 
 

Instantiate an FsmState object.

The next state is initialized to pNULL.

Definition at line 14 of file FsmState.cpp.


Member Function Documentation

bool FsmState::canEnter void   )  [virtual]
 

Perform the entry check and return false if a transition into this state would put the system in an inconsistent or otherwise undesirable condition.

Note that the ultimate decision as to whether the state is entered or not lies with the FSM that could decide to ignore the return value of canEnter(). This class provides a default implementation that returns true (state can be entered).

See also:
CC_FSM::activate
Returns:
true if the state can be safely entered.

Reimplemented in DC_DummyConfigurableFsmState.

Definition at line 18 of file FsmState.cpp.

bool FsmState::canExit void   )  [virtual]
 

Perform the exit check and return false if performing a transition out of the this state would leave the system in an inconsistent or otherwise undesirable condition.

Note that the ultimate decision as to whether the state is exited or not lies with the FSM that could decide to ignore the return value of canExit(). This class provides a default implementation that returns true (state can be exited).

See also:
CC_FSM::activate
Returns:
true if the manoeuvre can continue execution

Reimplemented in DC_DummyConfigurableFsmState, and DC_NestedFsmActivatorWithExitCheck.

Definition at line 26 of file FsmState.cpp.

virtual void FsmState::doContinue void   )  [pure virtual]
 

Perform the continued action associated to this state.

This method is intended to be called by the FSM every time it is activated when this state is the current state.

See also:
CC_FSM::activate

Implemented in DC_AfsFsmState, DC_DummyConfigurableFsmState, DC_DummyFsmState, DC_NestedFsmActivator, DC_OCM_FsmState, DC_SBY_PostSepFsmState, DC_SBY_PreSepFsmState, DC_SCM_FsmState, DC_SM_PreSepFsmState, and DC_UnstableFsmState.

void FsmState::doExit void   )  [virtual]
 

Perform the exit action associated to this state.

This method is intended to be called by the FSM object just before it exits this state. This class provides a default implementation that returns without doing anything.

See also:
CC_FSM::activate

Reimplemented in DC_AfsFsmState, DC_DummyConfigurableFsmState, and DC_SBY_PostSepFsmState.

Definition at line 30 of file FsmState.cpp.

void FsmState::doInit void   )  [virtual]
 

Perform the initialization action associated to the FsmState.

This method is intended to be called by the FSM immediately after the state has been entered. This class provides a default implementation that returns without doing anything.

See also:
CC_FSM::activate

Reimplemented in DC_AfsFsmState, DC_DummyConfigurableFsmState, DC_NestedFsmActivator, DC_OCM_FsmState, DC_SBY_PostSepFsmState, DC_SBY_PreSepFsmState, DC_SCM_FsmState, and DC_SM_PreSepFsmState.

Definition at line 22 of file FsmState.cpp.

FsmState * FsmState::getNextState void   )  const [inline]
 

Return the next state associated to this state.

If no next state is associated to this state, then the method return pNULL.

Returns:
the next state associated to the current state

Definition at line 17 of file FsmState_inl.h.

bool FsmState::isFinished void   )  [virtual]
 

Perform a termination check and return true if the continued action associated to this state has been completed and an autonomous transition to a next state should be performed.

This class provides a default implementation that always returns "not terminated".

See also:
CC_FSM::activate
Returns:
true if the continued action associated to this state has been terminated, false otherwise

Reimplemented in DC_DummyConfigurableFsmState, DC_NestedFsmActivatorWithEndState, DC_OCM_FsmState, DC_SBY_PostSepFsmState, DC_SBY_PreSepFsmState, DC_SCM_FsmState, DC_SM_PreSepFsmState, and DC_UnstableFsmState.

Definition at line 34 of file FsmState.cpp.

void FsmState::setNextState FsmState pNextState  )  [inline]
 

Set the next state associated to this state.

This method would normally be called only once during the application initialization phase. However, it is not formally classified as an initialization method in order to leave the option open to FsmState objects to dynamically set their next state on the basis of their termination status.

Parameters:
pNextState the next state associated to the current state

Definition at line 13 of file FsmState_inl.h.


The documentation for this class was generated from the following files:
Copyright 2003 P&P Software GmbH - All Rights Reserved