jade.core.behaviours
Class ParallelBehaviour
java.lang.Object
|
+--jade.core.behaviours.Behaviour
|
+--jade.core.behaviours.CompositeBehaviour
|
+--jade.core.behaviours.ParallelBehaviour
- public class ParallelBehaviour
- extends CompositeBehaviour
Composite behaviour with concurrent children scheduling.
It is a CompositeBehaviour
that executes its children
behaviours concurrently, and it terminates when a
particular condition on its sub-behaviours is met i.e. when
all children are done, N children are done or any
child is done.
- Version:
- $Date: 2002/06/04 08:26:56 $ $Revision: 1.5 $
- Author:
- Giovanni Rimassa - Universita` di Parma, Giovanni Caire - Telecom Italia Lab
- See Also:
- Serialized Form
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. |
Constructor Summary |
ParallelBehaviour(Agent a,
int endCondition)
Construct a ParallelBehaviour setting the
owner agent. |
ParallelBehaviour(int endCondition)
Construct a ParallelBehaviour without setting the
owner agent. |
Methods inherited from class java.lang.Object |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait |
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.
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.
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
-
WHEN_ALL
to terminate this ParallelBehaviour
when all its children are done.
-
WHEN_ANY
to terminate this ParallelBehaviour
when any of its child is done.
-
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
-
WHEN_ALL
to terminate this ParallelBehaviour
when all its children are done.
-
WHEN_ANY
to terminate this ParallelBehaviour
when any of its child is done.
-
a positive
int
value n to terminate this
ParallelBehaviour
when n of its children are done.
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)
- This method
schedules children behaviours one at a time, in a round robin
fashion.
- Overrides:
- scheduleNext in class CompositeBehaviour
- See Also:
CompositeBehaviour.scheduleNext(boolean, int)
checkTermination
protected boolean checkTermination(boolean currentDone,
int currentResult)
- Check whether this
ParallelBehaviour
must terminate.
- Overrides:
- checkTermination in class CompositeBehaviour
- 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
ParallelBehaviour
- Overrides:
- getChildren in class CompositeBehaviour
- See Also:
CompositeBehaviour.getChildren()
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.