bdi4jade.plan.planbody

## Class ParallelActionPlanBody

- java.lang.Object
- - jade.core.behaviours.Behaviour
  - - jade.core.behaviours.CompositeBehaviour
    - - jade.core.behaviours.ParallelBehaviour
      - - bdi4jade.plan.planbody.ParallelActionPlanBody

- All Implemented Interfaces:
    GoalListener, PlanBody, java.io.Serializable, java.util.EventListener

      public class ParallelActionPlanBody
      extends jade.core.behaviours.ParallelBehaviour
      implements PlanBody

  This allows a plan body to inherit from both `AbstractPlanBody` and `ParallelBehaviour`.
  Author:
    Ingrid Nunes
  See Also:
    Serialized Form

- - ### Nested Class Summary

    - ### Nested classes/interfaces inherited from class jade.core.behaviours.Behaviour

      `jade.core.behaviours.Behaviour.RunnableChangedEvent`

  - ### Field Summary

    - ### Fields inherited from class jade.core.behaviours.ParallelBehaviour

      `WHEN_ALL, WHEN_ANY`

    - ### Fields inherited from class jade.core.behaviours.CompositeBehaviour

      `currentExecuted`

    - ### Fields inherited from class jade.core.behaviours.Behaviour

      `myAgent, myEvent, NOTIFY_DOWN, NOTIFY_UP, parent, STATE_BLOCKED, STATE_READY, STATE_RUNNING`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `ParallelActionPlanBody()`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `dispatchGoal(Goal goal)` Dispatches a goal to be achieved.
    `void` | `dispatchProtectedGoal(Goal goal)` Dispatches a goal to be achieved, using the capability (or its children capabilities) associated with the plan.
    `void` | `dispatchProtectedSubgoal(Goal subgoal)` Dispatches a subgoal to be achieved, using the capability (or its children capabilities) associated with the plan.
    `void` | `dispatchProtectedSubgoalAndListen(Goal subgoal)` Dispatches a subgoal to be achieved, using the capability (or its children capabilities) associated with the plan, and registers itself as a listener to receive a notification of the end of execution of the goal.
    `void` | `dispatchSubgoal(Goal subgoal)` Dispatches a subgoal to be achieved.
    `void` | `dispatchSubgoalAndListen(Goal subgoal)` Dispatches a subgoal to be achieved and registers itself as a listener to receive a notification of the end of execution of the goal.
    `BeliefBase` | `getBeliefBase()` Returns the belief base of the capability associated with the plan of this plan body.
    `Plan.EndState` | `getEndState()` Returns the end state of the execution of this plan.
    `Goal` | `getGoal()` Returns the goal to be achieved by this plan body.
    `GoalEvent` | `getGoalEvent()` Returns a goal event from the queue.
    `GoalEvent` | `getGoalEvent(boolean block)` Returns a goal event from the queue.
    `GoalEvent` | `getGoalEvent(long ms)` Returns a goal event from the queue.
    `Plan` | `getPlan()` Returns the `Plan` that is associated with this plan instance.
    `void` | `goalPerformed(GoalEvent event)` Notifies the listener that a goal that was performed.
    `void` | `init(Plan plan, Intention intention)` Initializes this plan body.
    `void` | `start()` Starts the execution of a plan body, a `Behaviour`, associated with this plan.
    `void` | `stop()` Stops the plan body, a `Behaviour`, associated with this plan.

    - ### Methods inherited from class jade.core.behaviours.ParallelBehaviour

      `addSubBehaviour, checkTermination, getChildren, getCurrent, getTerminatedChildren, handle, removeSubBehaviour, reset, scheduleFirst, scheduleNext`

    - ### Methods inherited from class jade.core.behaviours.CompositeBehaviour

      `action, done, handleBlockEvent, handleRestartEvent, registerAsChild, resetChildren, setAgent`

    - ### Methods inherited from class jade.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`

    - ### Methods inherited from interface bdi4jade.plan.planbody.PlanBody

      `onEnd, onStart, reset`

- - ### Constructor Detail

    - #### ParallelActionPlanBody

          public ParallelActionPlanBody()

  - ### Method Detail

    - #### dispatchGoal

          public void dispatchGoal(Goal goal)

      Description copied from interface: `PlanBody`
      Dispatches a goal to be achieved. It is added as a top level agent goal, that is, the dispatched goal is independent of the goal that this plan body is trying to achieve.
      Specified by:
        `dispatchGoal` in interface `PlanBody`
      Parameters:
        `goal` - the goal to be dispatched.

    - #### dispatchProtectedGoal

          public void dispatchProtectedGoal(Goal goal)

      Description copied from interface: `PlanBody`
      Dispatches a goal to be achieved, using the capability (or its children capabilities) associated with the plan.
      Specified by:
        `dispatchProtectedGoal` in interface `PlanBody`
      Parameters:
        `goal` - the goal to be dispatched.

    - #### dispatchProtectedSubgoal

          public void dispatchProtectedSubgoal(Goal subgoal)

      Description copied from interface: `PlanBody`
      Dispatches a subgoal to be achieved, using the capability (or its children capabilities) associated with the plan.
      Specified by:
        `dispatchProtectedSubgoal` in interface `PlanBody`
      Parameters:
        `subgoal` - the subgoal to be dispatched.

    - #### dispatchProtectedSubgoalAndListen

          public void dispatchProtectedSubgoalAndListen(Goal subgoal)

      Description copied from interface: `PlanBody`
      Dispatches a subgoal to be achieved, using the capability (or its children capabilities) associated with the plan, and registers itself as a listener to receive a notification of the end of execution of the goal.
      Specified by:
        `dispatchProtectedSubgoalAndListen` in interface `PlanBody`
      Parameters:
        `subgoal` - the subgoal to be dispatched.

    - #### dispatchSubgoal

          public void dispatchSubgoal(Goal subgoal)

      Description copied from interface: `PlanBody`
      Dispatches a subgoal to be achieved. Dispatched subgoals are goals of an agent as long as the plan body that dispatched it is being executed.
      Specified by:
        `dispatchSubgoal` in interface `PlanBody`
      Parameters:
        `subgoal` - the subgoal to be dispatched.

    - #### dispatchSubgoalAndListen

          public void dispatchSubgoalAndListen(Goal subgoal)

      Description copied from interface: `PlanBody`
      Dispatches a subgoal to be achieved and registers itself as a listener to receive a notification of the end of execution of the goal.
      Specified by:
        `dispatchSubgoalAndListen` in interface `PlanBody`
      Parameters:
        `subgoal` - the subgoal to be dispatched.

    - #### getBeliefBase

          public BeliefBase getBeliefBase()

      Description copied from interface: `PlanBody`
      Returns the belief base of the capability associated with the plan of this plan body.
      Specified by:
        `getBeliefBase` in interface `PlanBody`
      Returns:
        the belief base containing the capability beliefs.

    - #### getEndState

          public Plan.EndState getEndState()

      Description copied from interface: `PlanBody`
      Returns the end state of the execution of this plan.
      Specified by:
        `getEndState` in interface `PlanBody`
      Returns:
        the end state of this plan, or null if it has not finished yet.

    - #### getGoal

          public Goal getGoal()

      Description copied from interface: `PlanBody`
      Returns the goal to be achieved by this plan body.
      Specified by:
        `getGoal` in interface `PlanBody`
      Returns:
        the goal.

    - #### getGoalEvent

          public GoalEvent getGoalEvent()

      Description copied from interface: `PlanBody`
      Returns a goal event from the queue. If the queue is empty, the behavior associated with this plan instance is blocked.
      Specified by:
        `getGoalEvent` in interface `PlanBody`
      Returns:
        the goal event or null if the queue is empty.

    - #### getGoalEvent

          public GoalEvent getGoalEvent(boolean block)

      Description copied from interface: `PlanBody`
      Returns a goal event from the queue. If the queue is empty, the behavior associated with this plan instance is going to be blocked if the parameter passed to this method is true.
      Specified by:
        `getGoalEvent` in interface `PlanBody`
      Parameters:
        `block` - true if the behavior must be blocked if the queue is empty.
      Returns:
        the goal event or null if the queue is empty.

    - #### getGoalEvent

          public GoalEvent getGoalEvent(long ms)

      Description copied from interface: `PlanBody`
      Returns a goal event from the queue. If the queue is empty, the behavior associated with this plan instance is going to be blocked for the specified milliseconds.
      Specified by:
        `getGoalEvent` in interface `PlanBody`
      Parameters:
        `ms` - the maximum amount of time that the behavior must be blocked.
      Returns:
        the goal event or null if the queue is empty.

    - #### getPlan

          public Plan getPlan()

      Description copied from interface: `PlanBody`
      Returns the `Plan` that is associated with this plan instance.
      Specified by:
        `getPlan` in interface `PlanBody`
      Returns:
        the plan.

    - #### goalPerformed

          public void goalPerformed(GoalEvent event)

      Description copied from interface: `GoalListener`
      Notifies the listener that a goal that was performed.
      Specified by:
        `goalPerformed` in interface `GoalListener`
      Parameters:
        `event` - the goal event that occurred.

    - #### init

          public void init(Plan plan,
                  Intention intention)
                    throws PlanInstantiationException

      Description copied from interface: `PlanBody`
      Initializes this plan body. It associates this plan body with a plan definition (`Plan`) and an `Intention`. If this plan body has already been initialized, this method throws a `PlanInstantiationException`.
      Specified by:
        `init` in interface `PlanBody`
      Parameters:
        `plan` - the plan associated this this plan body.
        `intention` - the intention that this plan instance have to achieve.
      Throws:
        `PlanInstantiationException` - if this plan body has already been initialized.

    - #### start

          public void start()

      Description copied from interface: `PlanBody`
      Starts the execution of a plan body, a `Behaviour`, associated with this plan.
      Specified by:
        `start` in interface `PlanBody`

    - #### stop

          public void stop()

      Description copied from interface: `PlanBody`
      Stops the plan body, a `Behaviour`, associated with this plan. If the body implements the `DisposablePlanBody`, it invokes the method to about the plan body, so it can perform finalizations.
      Specified by:
        `stop` in interface `PlanBody`