Overview  Package   Class  Tree  Deprecated  Index  Help 
PREV CLASS   NEXT CLASS FRAMES    NO FRAMES    All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD DETAIL: FIELD | CONSTR | METHOD

sajas.core.behaviours
Class ParallelBehaviour
java.lang.Object
  sajas.core.behaviours.Behaviour
      sajas.core.behaviours.CompositeBehaviour
          sajas.core.behaviours.ParallelBehaviour
All Implemented Interfaces:
jade.util.leap.Serializable, Serializable

public class ParallelBehaviour
extends CompositeBehaviour
Author:
hlc
See Also:
jade.core.behaviours.ParallelBehaviour

Nested classes/interfaces inherited from class sajas.core.behaviours.Behaviour
Behaviour.RunnableChangedEvent
Field Summary
static int
WHEN_ALL
          Predefined constant to be used in the constructor to create a ParallelBehaviour that terminates when all its children are done.
static int
WHEN_ANY
          Predefined constant to be used in the constructor to create a ParallelBehaviour that terminates when any of its child is done.
Fields inherited from class sajas.core.behaviours.CompositeBehaviour
currentExecuted
Fields inherited from class sajas.core.behaviours.Behaviour
myAgent, myEvent, NOTIFY_DOWN, NOTIFY_UP, parent, STATE_BLOCKED, STATE_READY, STATE_RUNNING
Constructor Summary
ParallelBehaviour()
          Construct a ParallelBehaviour without setting the owner agent, and using the default termination condition (i.e.
ParallelBehaviour(int endCondition)
          Construct a ParallelBehaviour without setting the owner agent.
ParallelBehaviour(Agent a, int endCondition)
          Construct a ParallelBehaviour setting the owner agent.
Method Summary
void
addSubBehaviour(Behaviour b)
          Add a sub behaviour to this ParallelBehaviour
protected boolean
checkTermination(boolean currentDone, int currentResult)
          Check whether this ParallelBehaviour must terminate.
jade.util.leap.Collection
getChildren()
          Return a Collection view of the children of this ParallelBehaviour
protected Behaviour
getCurrent()
          Get the current child
jade.util.leap.Collection
getTerminatedChildren()
          Return a Collection view of the children of this ParallelBehaviour that have already completed.
protected void
handle(Behaviour.RunnableChangedEvent rce)
          Handle block/restart notifications.
void
removeSubBehaviour(Behaviour b)
          Remove a sub behaviour from this ParallelBehaviour
void
reset()
          Resets this behaviour.
protected void
scheduleFirst()
          Prepare the first child for execution
protected void
scheduleNext(boolean currentDone, int currentResult)
          This method schedules children behaviours one at a time, in a round robin fashion.
Methods inherited from class sajas.core.behaviours.CompositeBehaviour
action, done, handleBlockEvent, handleRestartEvent, registerAsChild, resetChildren, setAgent
Methods inherited from class sajas.core.behaviours.Behaviour
actionWrapper, block, block, getAgent, getBehaviourName, getDataStore, getExecutionState, getParent, getRestartCounter, isRunnable, onEnd, onStart, restart, root, setBehaviourName, setDataStore, setExecutionState
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Field Detail
WHEN_ALL
public static final int WHEN_ALL
Predefined constant to be used in the constructor to create a ParallelBehaviour that terminates when all its children are done.
See Also:
Constant Field Values

WHEN_ANY
public static final int WHEN_ANY
Predefined constant to be used in the constructor to create a ParallelBehaviour that terminates when any of its child is done.
See Also:
Constant Field Values
Constructor Detail
ParallelBehaviour
public ParallelBehaviour()
Construct a ParallelBehaviour without setting the owner agent, and using the default termination condition (i.e. the parallel behaviour terminates as soon as all its children behaviours terminate.

ParallelBehaviour
public ParallelBehaviour(int endCondition)
Construct a ParallelBehaviour without setting the owner agent.
Parameters:
endCondition - this value defines the termination condition for this ParallelBehaviour. Use
  1. WHEN_ALL to terminate this ParallelBehaviour when all its children are done.
  2. WHEN_ANY to terminate this ParallelBehaviour when any of its child is done.
  3. a positive int value n to terminate this ParallelBehaviour when n of its children are done.

ParallelBehaviour
public ParallelBehaviour(Agent a,
                         int endCondition)
Construct a ParallelBehaviour setting the owner agent.
Parameters:
a - the agent this ParallelBehaviour belongs to.
endCondition - this value defines the termination condition for this ParallelBehaviour. Use
  1. WHEN_ALL to terminate this ParallelBehaviour when all its children are done.
  2. WHEN_ANY to terminate this ParallelBehaviour when any of its child is done.
  3. a positive int value n to terminate this ParallelBehaviour when n of its children are done.
Method Detail
scheduleFirst
protected void scheduleFirst()
Prepare the first child for execution
Overrides:
scheduleFirst in class CompositeBehaviour
See Also:
jade.core.behaviours.CompositeBehaviour.scheduleFirst()

scheduleNext
protected void scheduleNext(boolean currentDone,
                            int currentResult)
This method schedules children behaviours one at a time, in a round robin fashion.
Overrides:
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:
jade.core.behaviours.CompositeBehaviour.scheduleNext(boolean, int)

checkTermination
protected boolean checkTermination(boolean currentDone,
                                   int currentResult)
Check whether this ParallelBehaviour must terminate.
Overrides:
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 if the CompositeBehaviour should terminate. false otherwise.
See Also:
jade.core.behaviours.CompositeBehaviour.checkTermination(boolean, int)

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

getChildren
public jade.util.leap.Collection getChildren()
Return a Collection view of the children of this ParallelBehaviour
Overrides:
getChildren in class CompositeBehaviour
See Also:
jade.core.behaviours.CompositeBehaviour.getChildren()

getTerminatedChildren
public jade.util.leap.Collection getTerminatedChildren()
Return a Collection view of the children of this ParallelBehaviour that have already completed.

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

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

reset
public void reset()
Resets this behaviour. This methods puts a ParallelBehaviour back in initial state, besides calling reset() on each child behaviour recursively.
Overrides:
reset in class CompositeBehaviour

handle
protected void handle(Behaviour.RunnableChangedEvent rce)
Handle block/restart notifications. A ParallelBehaviour object is blocked only when all its children behaviours are blocked and becomes ready to run as soon as any of its children is runnable. This method takes care of the various possibilities.
Overrides:
handle in class Behaviour
Parameters:
rce - The event to handle.

Overview  Package   Class  Tree  Deprecated  Index  Help 
PREV CLASS   NEXT CLASS FRAMES    NO FRAMES    All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD DETAIL: FIELD | CONSTR | METHOD

Java API documentation generated with DocFlex/Doclet 1.6.1 using JavadocPro template set.
DocFlex/Doclet is both a multi-format Javadoc doclet and a free edition of DocFlex/Javadoc, which is a template-driven programming tool for rapid development of any Javadoc-based Java API documentation generators (i.e. doclets). If you need to customize your Javadoc without writing a full-blown doclet from scratch, DocFlex/Javadoc may be the only tool able to help you! Find out more at www.docflex.com