Package jade.core.behaviours
Class SequentialBehaviour
- java.lang.Object
-
- jade.core.behaviours.Behaviour
-
- jade.core.behaviours.CompositeBehaviour
-
- jade.core.behaviours.SerialBehaviour
-
- jade.core.behaviours.SequentialBehaviour
-
- All Implemented Interfaces:
Serializable,Serializable
public class SequentialBehaviour extends SerialBehaviour
Composite behaviour with sequential children scheduling. It is aCompositeBehaviourthat executes its children behaviours in sequential order, and terminates when its last child has ended.- Version:
- $Date$ $Revision$
- Author:
- Giovanni Rimassa - Universita` di Parma, Giovanni Caire - Telecom Italia Lab
- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class jade.core.behaviours.Behaviour
Behaviour.RunnableChangedEvent
-
-
Field Summary
-
Fields inherited from class jade.core.behaviours.CompositeBehaviour
currentExecuted
-
Fields inherited from class jade.core.behaviours.Behaviour
myAgent, myEvent, NOTIFY_DOWN, NOTIFY_UP, parent, STATE_BLOCKED, STATE_READY, STATE_RUNNING
-
-
Constructor Summary
Constructors Constructor Description SequentialBehaviour()Default constructor.SequentialBehaviour(Agent a)This constructor sets the owner agent for this behaviour.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddSubBehaviour(Behaviour b)Add a sub behaviour to thisSequentialBehaviourprotected booleancheckTermination(boolean currentDone, int currentResult)Check whether thisSequentialBehaviourmust terminate.CollectiongetChildren()Return a Collection view of the children of thisSequentialBehaviourprotected BehaviourgetCurrent()Get the current childvoidremoveSubBehaviour(Behaviour b)Remove a sub behaviour from thisSequentialBehaviourvoidreset()Puts aCompositeBehaviourback in initial state.protected voidscheduleFirst()Prepare the first child for executionprotected voidscheduleNext(boolean currentDone, int currentResult)Sequential policy for children scheduling.voidskipNext()-
Methods inherited from class jade.core.behaviours.SerialBehaviour
handle
-
Methods inherited from class jade.core.behaviours.CompositeBehaviour
action, done, handleBlockEvent, handleRestartEvent, registerAsChild, resetChildren, setAgent
-
Methods inherited from class jade.core.behaviours.Behaviour
actionWrapper, block, block, getAgent, getBehaviourName, getDataStore, getExecutionState, getParent, getRestartCounter, isRunnable, onEnd, onStart, restart, root, setBehaviourName, setDataStore, setExecutionState
-
-
-
-
Constructor Detail
-
SequentialBehaviour
public SequentialBehaviour()
Default constructor. It does not set the owner agent for this behaviour.
-
SequentialBehaviour
public SequentialBehaviour(Agent a)
This constructor sets the owner agent for this behaviour.- Parameters:
a- The agent this behaviour belongs to.
-
-
Method Detail
-
scheduleFirst
protected void scheduleFirst()
Prepare the first child for execution- Specified by:
scheduleFirstin classCompositeBehaviour- See Also:
CompositeBehaviour.scheduleFirst()
-
scheduleNext
protected void scheduleNext(boolean currentDone, int currentResult)Sequential policy for children scheduling. This method schedules children behaviours one at a time, in a FIFO fashion.- Specified by:
scheduleNextin classCompositeBehaviour- Parameters:
currentDone- a flag indicating whether the just executed child has completed or not.currentResult- the termination value (as returned byonEnd()) of the just executed child in the case this child has completed (otherwise this parameter is meaningless)- See Also:
CompositeBehaviour.scheduleNext(boolean, int)
-
checkTermination
protected boolean checkTermination(boolean currentDone, int currentResult)Check whether thisSequentialBehaviourmust terminate.- Specified by:
checkTerminationin classCompositeBehaviour- Parameters:
currentDone- a flag indicating whether the just executed child has completed or not.currentResult- the termination value (as returned byonEnd()) of the just executed child in the case this child has completed (otherwise this parameter is meaningless)- Returns:
- true when the last child has terminated. false otherwise
- See Also:
CompositeBehaviour.checkTermination(boolean, int)
-
getCurrent
protected Behaviour getCurrent()
Get the current child- Specified by:
getCurrentin classCompositeBehaviour- See Also:
CompositeBehaviour.getCurrent()
-
getChildren
public Collection getChildren()
Return a Collection view of the children of thisSequentialBehaviour- Specified by:
getChildrenin classCompositeBehaviour- See Also:
CompositeBehaviour.getChildren()
-
addSubBehaviour
public void addSubBehaviour(Behaviour b)
Add a sub behaviour to thisSequentialBehaviour
-
removeSubBehaviour
public void removeSubBehaviour(Behaviour b)
Remove a sub behaviour from thisSequentialBehaviour
-
reset
public void reset()
Description copied from class:CompositeBehaviourPuts aCompositeBehaviourback in initial state. The internal state is cleaned up andreset()is recursively called for each child behaviour.- Overrides:
resetin classCompositeBehaviour
-
skipNext
public void skipNext()
-
-