- Inherits from:
- Object
- Declared in:
- DFSM.h
Object
|
+---DFSM
Class Description
The DFSM class implements a (simple) finite state machine. The state machine is
built by creating a number of transitions for every state. After the state
machine is built, the processing is started by using the 'start' method.
From that moment on, events can be fed to the state machine by calling
'feed'. This method returns the current state. With the method 'try' an event
can be tested for the state machine, without changing the internal state of the
machine. There is one assumption: events are ints.
- Last modified:
- 31-Oct-2007 (DFSM.h)
Instance Variables
- private DFSMState *_current
- the current state
- private DFSMState *_previous
- the previous state
- private DList *_states
- all known states
- Constructors
- - (DFSM *) init
- Initialise an empty finite state machine
- Returns:
- the object
- Copy related methods
- - deepen
- Deepen the copy of the object
- Returns:
- the object
- - shallowCopy
- Do a shallow copy of the object
- Returns:
- the object
- Deconstructor
- - free
- (Deep) free the FSM (including the states)
- Returns:
- the object
- - shallowFree
- Free the FSM (but *NOT* the states)
- Returns:
- the object
- Member methods
- - (DFSMState *) current
- Get the current state
- Returns:
- the current state (or nil for no state)
- - (BOOL) isChanged
- Check if the state is changed during the last event
- Returns:
- is it ?
- - (DFSMState *) previous
- Get the previous state
- Returns:
- the previous state (or nil for no state)
- Create State machine network
- - (DFSM *) transition :(DFSMState *) origin :(DBitArray *) trigger :(DFSMState *) destination
- Add a transition to the state machine network. Special case: if trigger is
nil then this transition is activated if all other transitions fail for an
event (any-other-transition). Only one such transition is allowed. Note: trigger
will be freed when FSMState object is freed.
- Parameters:
- origin - the state that has this transition
trigger - the range of events that trigger the transition (or nil)
destination - the next state if the transition is triggered
- Returns:
- the object
- Using the state machine
- - (DFSMState *) feed :(int) event
- Feed an event to the state machine
- Parameters:
- event - the event for the state machine
- Returns:
- the current state (or nil for unexpected event)
- - (DFSMState *) start :(DFSMState *) state
- Start the state machine
- Parameters:
- state - the start state
- Returns:
- the current state (or nil if start event not found)
- - (DFSMState *) try :(int) event
- Try an event in the state machine; the state of the state machine is
NOT changed; only the state that will be reached if the event is fed, is
returned
- Parameters:
- event - the event for the state machine
- Returns:
- the state if the event is fed (or nil for unexpected event)
generated 05-Nov-2007 by ObjcDoc 3.0.0