|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Object
|
+--jade.core.behaviours.Behaviour
|
+--jade.core.behaviours.ComplexBehaviour
An abstract superclass for behaviours composed by many parts. This
class holds inside a list of children behaviours,
to which elements can be aded or emoved dynamically.
When a ComplexBehaviour receives it execution quantum
from the agent scheduler, it executes one of its children according
to some policy. This class must be extended to provide the actual
scheduling policy to apply when running children behaviours.
SequentialBehaviour,
NonDeterministicBehaviour, Serialized Form| Inner Class Summary | |
protected class |
ComplexBehaviour.BehaviourList
Inner class to implement a list of behaviours. |
| Inner classes inherited from class jade.core.behaviours.Behaviour |
Behaviour.RunnableChangedEvent |
| Field Summary | |
protected ComplexBehaviour.BehaviourList |
subBehaviours
The children list for this behaviour. |
| Fields inherited from class jade.core.behaviours.Behaviour |
myAgent,
myEvent,
NOTIFY_DOWN,
NOTIFY_UP,
parent |
| Constructor Summary | |
ComplexBehaviour()
Default constructor, does not set the owner agent. |
|
ComplexBehaviour(Agent a)
This constructor sets the owner agent. |
|
| Method Summary | |
void |
action()
Executes this ComplexBehaviour. |
void |
addSubBehaviour(Behaviour b)
Adds a behaviour to the children list. |
protected abstract boolean |
bodyAction()
Abstract policy method for children execution. |
boolean |
done()
Checks whether this behaviour has terminated. |
protected void |
handle(Behaviour.RunnableChangedEvent rce)
Handle block/restart notifications. |
protected void |
postAction()
This method is just an empty placeholder for subclasses. |
protected void |
preAction()
This method is just an empty placeholders for subclasses. |
void |
removeSubBehaviour(Behaviour b)
Removes a behaviour from the children list. |
void |
reset()
Puts a ComplexBehaviour back in initial state. |
void |
restart()
Restarts this behaviour. |
| Methods inherited from class jade.core.behaviours.Behaviour |
block,
block,
isRunnable,
root |
| Methods inherited from class java.lang.Object |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait |
| Field Detail |
protected ComplexBehaviour.BehaviourList subBehaviours
| Constructor Detail |
public ComplexBehaviour()
public ComplexBehaviour(Agent a)
a - The agent this behaviour belongs to.| Method Detail |
protected void preAction()
ComplexBehaviour.protected abstract boolean bodyAction()
ComplexBehaviour with custom children scheduling. In
this case, the method must return true when the
composite behaviour has ended and false
otherwise. Typically, the value returned will be some function of
all termination statuses of children behaviours.true when done, false when
children behaviours still need to be run.SequentialBehaviour,
NonDeterministicBehaviourprotected void postAction()
ComplexBehaviour. Overriding this method,
application programmers can build fork()/join()
execution structures.
An useful idiom can be used to implement composite cyclic
behaviours (e.g. a behaviour that continuously follows a specific
interaction protocol): puttng a reset() call into
postAction() method makes a complex behaviour
restart as soon as it terminates, thereby turning it into a
cyclic composite behaviour.public final void action()
ComplexBehaviour. This method starts
by executing preAction(); then
bodyAction() is called once per scheduling turn
until it returns true. Eventually,
postAction() is called.public boolean done()
true if this ComplexBehaviour
has finished executing, falseotherwise.public void reset()
ComplexBehaviour back in initial state. The
internal state is cleaned up and reset() is
recursively called for each child behaviour.public void addSubBehaviour(Behaviour b)
b - The behaviour to add.public void removeSubBehaviour(Behaviour b)
b - The behaviour to remove. If it's not present in the
list, nothing happens.protected void handle(Behaviour.RunnableChangedEvent rce)
rce - The event to handlepublic void restart()
ComplexBehaviour blocks
just like its Behaviour superclass, but when
restart() is called all its children behaviours are
notified, too.
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||