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 CompositeBehaviour
java.lang.Object
  sajas.core.behaviours.Behaviour
      sajas.core.behaviours.CompositeBehaviour
All Implemented Interfaces:
jade.util.leap.Serializable, Serializable
Direct Known Subclasses:
ParallelBehaviour, SerialBehaviour

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

Nested classes/interfaces inherited from class sajas.core.behaviours.Behaviour
Behaviour.RunnableChangedEvent
Field Summary
protected boolean
currentExecuted
Fields inherited from class sajas.core.behaviours.Behaviour
myAgent, myEvent, NOTIFY_DOWN, NOTIFY_UP, parent, STATE_BLOCKED, STATE_READY, STATE_RUNNING
Constructor Summary
protected
CompositeBehaviour()
          Default constructor, does not set the owner agent.
protected
CompositeBehaviour(Agent a)
          This constructor sets the owner agent.
Method Summary
void
action()
          Executes this CompositeBehaviour.
protected abstract boolean
checkTermination(boolean currentDone, int currentResult)
          This methods is called after the execution of each child in order to check whether the CompositeBehaviour should terminate.
boolean
done()
          Checks whether this behaviour has terminated.
abstract jade.util.leap.Collection
getChildren()
          This method returns a Collection view of the children of this CompositeBehaviour
protected abstract Behaviour
getCurrent()
          This method returns the child behaviour currently scheduled for execution
protected void
handleBlockEvent()
          This method is used internally by the framework.
void
handleRestartEvent()
          This method is used internally by the framework.
protected void
registerAsChild(Behaviour b)
void
reset()
          Puts a CompositeBehaviour back in initial state.
protected void
resetChildren()
protected abstract void
scheduleFirst()
          This method schedules the first child to be executed
protected abstract void
scheduleNext(boolean currentDone, int currentResult)
          This method schedules the next child to be executed
void
setAgent(Agent a)
          Associates this behaviour with the agent it belongs to.
Methods inherited from class sajas.core.behaviours.Behaviour
actionWrapper, block, block, getAgent, getBehaviourName, getDataStore, getExecutionState, getParent, getRestartCounter, handle, 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
currentExecuted
protected boolean currentExecuted
Constructor Detail
CompositeBehaviour
protected CompositeBehaviour()
Default constructor, does not set the owner agent.

CompositeBehaviour
protected CompositeBehaviour(Agent a)
This constructor sets the owner agent.
Parameters:
a - The agent this behaviour belongs to.
Method Detail
action
public final void action()
Executes this CompositeBehaviour. This method executes children according to the scheduling policy defined by concrete subclasses that implements the scheduleFirst() and scheduleNext() methods.
Overrides:
action in class Behaviour

done
public final boolean done()
Checks whether this behaviour has terminated.
Overrides:
done in class Behaviour
Returns:
true if this CompositeBehaviour has finished executing, falseotherwise.

scheduleFirst
protected abstract void scheduleFirst()
This method schedules the first child to be executed

scheduleNext
protected abstract void scheduleNext(boolean currentDone,
                                     int currentResult)
This method schedules the next child to be executed
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)

checkTermination
protected abstract boolean checkTermination(boolean currentDone,
                                            int currentResult)
This methods is called after the execution of each child in order to check whether the CompositeBehaviour should terminate.
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.

getCurrent
protected abstract Behaviour getCurrent()
This method returns the child behaviour currently scheduled for execution

getChildren
public abstract jade.util.leap.Collection getChildren()
This method returns a Collection view of the children of this CompositeBehaviour

handleBlockEvent
protected void handleBlockEvent()
This method is used internally by the framework. Developer should not call or redefine it.
Overrides:
handleBlockEvent in class Behaviour

handleRestartEvent
public void handleRestartEvent()
This method is used internally by the framework. Developer should not call or redefine it.
Overrides:
handleRestartEvent in class Behaviour

reset
public void reset()
Puts a CompositeBehaviour back in initial state. The internal state is cleaned up and reset() is recursively called for each child behaviour.
Overrides:
reset in class Behaviour

resetChildren
protected void resetChildren()

setAgent
public void setAgent(Agent a)
Associates this behaviour with the agent it belongs to. Overrides the method in the base class to propagate the setting to all children.
Overrides:
setAgent in class Behaviour
Parameters:
a - The agent this behaviour belongs to.
See Also:
jade.core.behaviours.Behaviour.setAgent(Agent a)

registerAsChild
protected void registerAsChild(Behaviour b)

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