public abstract class StateMachine extends ThreadedVerySimpleTask
doState(int)
when you want pass to an other stateModifier and Type | Field and Description |
---|---|
private int |
head
Head of waiting states queue
|
private int |
numberMaxOfWaitingState
Maximum number of waiting state in queue
|
private int |
queue
Queue of waiting state queue
|
private int |
state
Actual playing state
|
private int[] |
waitingStates
Waiting states queue
|
Constructor and Description |
---|
StateMachine()
Create a new instance of StateMachine
|
StateMachine(int numberMaxOfWaitingState)
Create a new instance of StateMachine
|
Modifier and Type | Method and Description |
---|---|
boolean |
canDoMoreState()
Indicates if the waiting state queue has more place or not
|
protected abstract boolean |
canPass(int actualState,
int futureState)
Called when want check if the passing to a state to an other one is legal
|
protected void |
doState(int state)
Call this method to pass to an other state
|
protected void |
doVerySimpleAction()
Called when a state have to be played
Parent documentation: Do the very simple task in its own thread |
protected int |
getState()
Actual state
|
protected abstract void |
playState(int state)
Called when a state have to play
|
protected abstract void |
reportIllegalState(int actualState,
int futureState)
Called each time a state to an other one is not allowed.
|
doSimpleAction
doThreadAction
cancel, canceled, doProgress, postProgress, setResult
private int head
private final int numberMaxOfWaitingState
private int queue
private int state
private final int[] waitingStates
public StateMachine()
public StateMachine(int numberMaxOfWaitingState)
numberMaxOfWaitingState
- Number maximum of waiting stateprotected abstract boolean canPass(int actualState, int futureState)
actualState
- Actual statefutureState
- State that want to gotrue
if it is authorize to got from actual state to future stateprotected final void doState(int state)
state
- State to goprotected final void doVerySimpleAction()
doVerySimpleAction
in class ThreadedVerySimpleTask
ThreadedVerySimpleTask.doVerySimpleAction()
protected final int getState()
protected abstract void playState(int state)
state
- State to playprotected abstract void reportIllegalState(int actualState, int futureState)
actualState
- Actual statefutureState
- Desired statepublic final boolean canDoMoreState()
true
if the waiting state queue has more place