18 #ifndef __igstkStateMachine_h
19 #define __igstkStateMachine_h
50 template<
class TClass>
151 void Print(std::ostream& os, itk::Indent indent)
const;
156 void PrintSelf( std::ostream& os, itk::Indent indent )
const;
185 bool m_InitialStateSelected;
188 typedef std::map< StateIdentifierType, StateDescriptorType > StatesContainer;
189 typedef typename StatesContainer::iterator StatesIterator;
190 typedef typename StatesContainer::const_iterator StatesConstIterator;
193 StatesContainer m_States;
206 typedef std::map< InputIdentifierType, InputDescriptorType > InputsContainer;
207 typedef typename InputsContainer::iterator InputIterator;
208 typedef typename InputsContainer::const_iterator InputConstIterator;
209 typedef std::queue< InputIdentifierType > InputsQueueContainer;
212 InputsContainer m_Inputs;
216 class StateActionPair
221 this->m_StateIdentifier = 0;
226 this->m_StateIdentifier = state;
227 this->m_Action = action;
229 StateActionPair(
const StateActionPair & in )
231 this->m_StateIdentifier = in.m_StateIdentifier;
232 this->m_Action = in.m_Action;
234 const StateActionPair & operator=(
const StateActionPair & in )
236 this->m_StateIdentifier = in.m_StateIdentifier;
237 this->m_Action = in.m_Action;
242 return m_StateIdentifier;
256 typedef std::map< InputIdentifierType, StateActionPair >
257 TransitionsPerInputContainer;
258 typedef std::map< StateIdentifierType, TransitionsPerInputContainer * >
260 typedef typename TransitionContainer::iterator TransitionIterator;
263 typedef typename TransitionContainer::const_iterator TransitionConstIterator;
264 typedef typename TransitionsPerInputContainer::iterator
265 TransitionsPerInputIterator;
266 typedef typename TransitionsPerInputContainer::const_iterator
267 TransitionsPerInputConstIterator;
269 TransitionContainer m_Transitions;
270 InputsQueueContainer m_QueuedInputs;
274 template<
class TClass>
275 std::ostream& operator<<(std::ostream& os, const StateMachine<TClass>& o);
280 #ifndef IGSTK_MANUAL_INSTANTIATION
281 #include "igstkStateMachine.txx"
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...
InputType::IdentifierType InputIdentifierType
Type used to represent the unique identifier of the inputs.
~StateMachine()
Destructor.
void(TClass::* TMemberFunctionPointer)()
Type of the action member funtion of TClass to be invoked at the end of a state transition.
void ExportDescription(OutputStreamType &ostr, bool skipLoops) const
Export the schematic description of the state machine to a stream.
std::ostream OutputStreamType
This extra typedef is necessary for preventing an Internal Compiler Error in Microsoft Visual C++ 6...
void AddState(const StateType &state, const StateDescriptorType &description)
Set the descriptor of a state.
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...
StateMachine(TClass *)
Constructor.
StateMachineState< TClass > StateType
Type used to represent the codes of the states.
TMemberFunctionPointer ActionType
Type for the Action to be taken.
void Print(std::ostream &os, itk::Indent indent) const
Print out the content of the class.
defines standard system-wide macros, constants, and other common parameters in the IGSTK Library...
void AddInput(const InputType &input, const InputDescriptorType &description)
Set the descriptor of an input.
Generic implementation of the State Machine model.
void ExportDescriptionToSCXML(OutputStreamType &ostr, bool skipLoops) const
Export the schematic description of the state machine to a stream.
void PrintSelf(std::ostream &os, itk::Indent indent) const
Print the object information in a stream.
std::string StateDescriptorType
Type for the description of the States.
void SetReadyToRun()
This method terminates the programming mode in which AddTransition() can be invoked and pass to the r...
StateType::IdentifierType StateIdentifierType
Type used to represent the unique identifier of the states.
std::string InputDescriptorType
Type for the description of the Inputs.
StateMachineInput< TClass > InputType
Type used to represent the codes of the inputs.
void ProcessInputs()
Perform the state transition and invoke the corresponding action for every pending input stored in th...
unsigned long IdentifierType
Type used to represent the codes of the inputs.
Generic implementation of the State in a State Machine model.
void SelectInitialState(const StateType &initialState)
Select Initial state.
void PushInput(const InputType &input)
Push a new input in the queue of inputs to be processed.
void ExportDescriptionToLTS(OutputStreamType &ostr, bool skipLoops) const
Export the schematic description of the state machine to a stream.
void ProcessInput(const InputIdentifierType &input)
Perform the state transition, invoke the corresponding action.