jade.core.behaviours
Class SequentialBehaviour

java.lang.Object
  |
  +--jade.core.behaviours.Behaviour
        |
        +--jade.core.behaviours.CompositeBehaviour
              |
              +--jade.core.behaviours.SequentialBehaviour

public class SequentialBehaviour
extends CompositeBehaviour

Composite behaviour with sequential children scheduling. It is a CompositeBehaviour that executes its children behaviours in sequential order, and terminates when its last child has ended.

Version:
$Date: 2002/06/06 14:33:47 $ $Revision: 2.7 $
Author:
Giovanni Rimassa - Universita` di Parma, Giovanni Caire - Telecom Italia Lab
See Also:
Serialized Form

Inner classes inherited from class jade.core.behaviours.Behaviour
Behaviour.RunnableChangedEvent
 
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
SequentialBehaviour()
          Default constructor.
SequentialBehaviour(Agent a)
          This constructor sets the owner agent for this behaviour.
 
Method Summary
 void addSubBehaviour(Behaviour b)
          Add a sub behaviour to this SequentialBehaviour
protected  boolean checkTermination(boolean currentDone, int currentResult)
          Check whether this SequentialBehaviour must terminate.
 Collection getChildren()
          Return a Collection view of the children of this SequentialBehaviour
protected  Behaviour getCurrent()
          Get the current child
protected  void handle(Behaviour.RunnableChangedEvent rce)
          Handle block/restart notifications.
 void removeSubBehaviour(Behaviour b)
          Remove a sub behaviour from this SequentialBehaviour
protected  void scheduleFirst()
          Prepare the first child for execution
protected  void scheduleNext(boolean currentDone, int currentResult)
          Sequential policy for children scheduling.
 void skipNext()
           
 
Methods inherited from class jade.core.behaviours.CompositeBehaviour
action, block, done, onEnd, onStart, reset, restart, setAgent
 
Methods inherited from class jade.core.behaviours.Behaviour
actionWrapper, block, getBehaviourName, getDataStore, isRunnable, root, setBehaviourName, setDataStore
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

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
Overrides:
scheduleFirst in class CompositeBehaviour
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.
Overrides:
scheduleNext in class CompositeBehaviour
See Also:
CompositeBehaviour.scheduleNext(boolean, int)

checkTermination

protected boolean checkTermination(boolean currentDone,
                                   int currentResult)
Check whether this SequentialBehaviour must terminate.
Overrides:
checkTermination in class CompositeBehaviour
Returns:
true when the last child has terminated. false otherwise
See Also:
CompositeBehaviour.checkTermination(boolean, int)

getCurrent

protected Behaviour getCurrent()
Get the current child
Overrides:
getCurrent in class CompositeBehaviour
See Also:
CompositeBehaviour.getCurrent()

getChildren

public Collection getChildren()
Return a Collection view of the children of this SequentialBehaviour
Overrides:
getChildren in class CompositeBehaviour
See Also:
CompositeBehaviour.getChildren()

addSubBehaviour

public void addSubBehaviour(Behaviour b)
Add a sub behaviour to this SequentialBehaviour

removeSubBehaviour

public void removeSubBehaviour(Behaviour b)
Remove a sub behaviour from this SequentialBehaviour

handle

protected void handle(Behaviour.RunnableChangedEvent rce)
Handle block/restart notifications. A SequentialBehaviour is blocked only when its currently active child is blocked, and becomes ready again when its current child is ready. This method takes care of the various possibilities.
Overrides:
handle in class Behaviour
Parameters:
rce - The event to handle.

skipNext

public void skipNext()