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, java.io.Serializable

public class SequentialBehaviour
extends SerialBehaviour

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: 2005-09-16 15:54:46 +0200 (ven, 16 set 2005) $ $Revision: 5780 $
Author:
Giovanni Rimassa - Universita` di Parma, Giovanni Caire - Telecom Italia Lab
See Also:
Serialized Form

Field Summary
 
Fields inherited from class jade.core.behaviours.Behaviour
myAgent
 
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
 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.
 
Methods inherited from class jade.core.behaviours.CompositeBehaviour
action, block, done, reset, resetChildren, restart, setAgent
 
Methods inherited from class jade.core.behaviours.Behaviour
block, getBehaviourName, getDataStore, getParent, isRunnable, onEnd, onStart, 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

Specified by:
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.

Specified by:
scheduleNext in class CompositeBehaviour
Parameters:
currentDone - a flag indicating whether the just executed child has completed or not.
currentResult - the termination value (as returned by onEnd()) 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 this SequentialBehaviour must terminate.

Specified by:
checkTermination in class CompositeBehaviour
Parameters:
currentDone - a flag indicating whether the just executed child has completed or not.
currentResult - the termination value (as returned by onEnd()) 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:
getCurrent in class CompositeBehaviour
See Also:
CompositeBehaviour.getCurrent()

getChildren

public Collection getChildren()
Return a Collection view of the children of this SequentialBehaviour

Specified by:
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



JADE