VR-Forces 4.0.4 Class Documentation
Public Member Functions | Protected Member Functions
DtSingleTaskControllerComponent Class Reference

This class provides a base class for all controllers that are capable of executing a DtSimTask, and can only execute a single DtSimTask at a time. More...

Inheritance diagram for DtSingleTaskControllerComponent:
Inheritance graph
[legend]

List of all members.

Public Member Functions

 DtSingleTaskControllerComponent (const DtString &name, DtVrfObject *owner, DtSimManager *simManager, DtComponentDescriptor *compDesc=0, DtReaderWriterRegistry *parentRegistry=0)
 (const DtString& name,
virtual ~DtSingleTaskControllerComponent ()
 destructor
virtual void postTick ()
 Override to check if we're tasked and we want to give up (only performs the check if we're in play mode (dT() > 0)).
virtual bool beginProcessingTask (const DtTaskMessage &task, DtSimTaskStatePtr taskState)
 Called by the task manager when this controller should start executing the specified task.
virtual void taskNotify (const DtSimTask &task)
 This is called to let us know when some other component receives a task In the case of this component, we don't care what the task actually is.
virtual void taskComplete (bool success=true)
 If we are currently tasked, this will cause us to notify the entity that we're done and delete the task.
virtual void clearTask ()
 If component is currently tasked, calls clearPendingSubtasks(), sets the tasked flag to false, and calls clearCurrentTaskMesage() to clear out the current task message.
virtual int sendSubtask (DtSimTask &task)
 Sends subtask to ourself.
virtual void clearSubtask (int subtaskId)
 Clears subtask with the given subtaskId (subtaskId is returned sendSubtask()).
virtual void addPendingSubtaskId (int subtaskId)
 Adds given subtask Id to list of pending subtasks.
virtual bool findPendingSubtaskId (int subtaskId)
 Checks to see if given subtaskId exists in our list of pending subtasks.
virtual void removePendingSubtaskId (int subtaskId)
 Removes pending subtask from list of subtasks for this component.
virtual void removeAllPendingSubtaskIds ()
 Clear all pending subtasks from our list of subtasks.
virtual std::vector< int > currentPendingSubstaskIds () const
 Returns the list of all currently pending subtask ids for this controller.
virtual void clearCurrentTaskMessage ()
 Returns the current subtask with the specified id.
virtual DtTaskMessagecurrentTaskMessage () const
 Get a pointer to the message that was used to task this entity.
virtual DtSimTaskStatePtr currentTaskState () const
virtual bool decideToGiveUpTask () const
 This function is used to determine if the controller should give up trying to execute the current task.
virtual void giveUpTask ()
 Called when controller is tasked and decideToGiveUp() returns true.
virtual bool taskActive (int taskId) const
 
virtual bool clearTopLevelTasks ()
 If this controller has any top level tasks (not subtasks), they are cleared.
virtual void clearConflictingTopLevelTasks (int conflictId)
 Clears any top level tasks on this controller that conflict with the conflictId.
virtual void clearTasksByType (int taskType)
 Clears any tasks of the specified type running in this controller.
virtual void clearTaskById (int taskId)
 Clears any task of the specified ID running in this controller.
virtual std::list
< DtTaskMessage * > 
currentTaskMessages () const
 
virtual DtTaskWithTaskStateListPtr topLevelTasks () const
 

Protected Member Functions

virtual void clearPendingSubtasks ()
 Iterates over collection of all pending subtasks for this controller, and calls clearSubtask() for each subtask type.
virtual void clearSubtasksByType (int taskType)
 Clear all subtasks of a given type.

Detailed Description

This class provides a base class for all controllers that are capable of executing a DtSimTask, and can only execute a single DtSimTask at a time.

This is the typical case for most task controllers, so most controllers will be derived from this class.


Constructor & Destructor Documentation

DtSingleTaskControllerComponent::DtSingleTaskControllerComponent ( const DtString name,
DtVrfObject owner,
DtSimManager simManager,
DtComponentDescriptor compDesc = 0,
DtReaderWriterRegistry parentRegistry = 0 
)

(const DtString& name,

Parameters:
nameReader writer name of this component.
ownerThe DtVrfObject that owns this component
simManagerThe simulation manager (provides access to terrain, message interface, simulation clock).
descThe component descriptor used to initialize this component.
parentRegistryPointer to the parent reader writer registry (the containing object that reads/writes this object).
(const DtString& name, DtVrfObject* owner, DtSimManager* simManager, DtComponentDescriptor* desc = 0, DtReaderWriterRegistry* parentRegistry = 0)

destructor


Member Function Documentation

virtual void DtSingleTaskControllerComponent::postTick ( ) [virtual]

Override to check if we're tasked and we want to give up (only performs the check if we're in play mode (dT() > 0)).

Calls decideToGiveUpTask() to determine if we should give up. If true, calls giveUpTask().

Reimplemented from DtTaskControllerComponent.

Called by the task manager when this controller should start executing the specified task.

Parameters:
taskStateUsed to convey at what point the task should begin execution. If taskState exists, execution of task may begin at some point other than the logical start of the task. If taskState is 0, begin processing at the logical start of the task.
Returns:
True if the controller can successfully start the task.
False if the controller is failing the task.

Reimplemented from DtTaskControllerComponent.

Reimplemented in DtRotaryWingFlightCommandController, and DtFixedWingFlightCommandController.

virtual void DtSingleTaskControllerComponent::taskNotify ( const DtSimTask task) [virtual]

This is called to let us know when some other component receives a task In the case of this component, we don't care what the task actually is.

Reimplemented from DtTaskControllerComponent.

virtual void DtSingleTaskControllerComponent::taskComplete ( bool  success = true) [virtual]

If we are currently tasked, this will cause us to notify the entity that we're done and delete the task.

To indicate that the task has failed (and is being abandoned) call this method with success set to false.

Reimplemented in DtFixedWingMoveToController, DtDIGuyController, DtTargetSelectionController, and DtLaunchExpendableResourceController.

virtual void DtSingleTaskControllerComponent::clearTask ( ) [virtual]
virtual int DtSingleTaskControllerComponent::sendSubtask ( DtSimTask task) [virtual]

Sends subtask to ourself.

Creates task message and sends task to ourself through radio. Adds subtask Id to list of pending subtasks. Returns subtask Id.

virtual void DtSingleTaskControllerComponent::clearSubtask ( int  subtaskId) [virtual]

Clears subtask with the given subtaskId (subtaskId is returned sendSubtask()).

Also removed the subtask ID from the pending subtask ID list.

virtual void DtSingleTaskControllerComponent::addPendingSubtaskId ( int  subtaskId) [virtual]

Adds given subtask Id to list of pending subtasks.

This is done automatically by sendSubtask (user should not typically have to call this directly).

virtual bool DtSingleTaskControllerComponent::findPendingSubtaskId ( int  subtaskId) [virtual]

Checks to see if given subtaskId exists in our list of pending subtasks.

Typically checked from within a task complete callback, to determine if given report corresponds to the specific subtask we issued.

virtual void DtSingleTaskControllerComponent::removePendingSubtaskId ( int  subtaskId) [virtual]

Removes pending subtask from list of subtasks for this component.

Users will typically call this from within a task complete callback, upon receipt of the specific subtasking task complete report they were waiting for.

Clear all pending subtasks from our list of subtasks.

Users should not typically have to call this.

virtual std::vector<int> DtSingleTaskControllerComponent::currentPendingSubstaskIds ( ) const [virtual]

Returns the list of all currently pending subtask ids for this controller.

Returns the current subtask with the specified id.

Also returns the controller that is responsible. If NULL, no task was found Clear the current task message.

Reimplemented in DtFixedWingLandingController, and DtEmbarkationController.

Get a pointer to the message that was used to task this entity.

Returns:
Current execution state of the task. At the base class level, returns 0. Derived classes that have tasks with DtTaskState (data associated with execution of the task) may return a new DtTaskState instance, filled out with the appropriate information about the current task execution state. Task controllers that do not need to return task state do not need to override this function.

Reimplemented in DtAggregatedMoveAlongController, DtDisaggregatedMoveAlongController, DtWaitController, DtDisaggregatedPatrolAlongController, DtDisaggregatedPatrolBetweenController, and DtAggregatedPatrolController.

This function is used to determine if the controller should give up trying to execute the current task.

Override this function to provide the test for determining if the task controller should give up. For example, a derived move-to-waypoint controller tasked to reach an unreachable waypoint might decide to give up after a certain amount of time, or after circling the point and failing to reach it. This function is called from within tick. If the controller is tasked and this function returns true, it calls giveUp(). The implementation in this class always returns false.

Reimplemented in DtFixedWingPilotController, DtGroundMoveToDestinationControllerComponent, DtSurfaceEntityPilotController, DtRailMovementController, DtGroundAutoControllerComponent, DtHumanMoveToController, DtGroundMoveAlongControllerComponent, DtHumanMoveAlongController, and DerivedMoveToController.

virtual void DtSingleTaskControllerComponent::giveUpTask ( ) [virtual]

Called when controller is tasked and decideToGiveUp() returns true.

Base class implementation calls clearTask(). Derived classes may override this function to perform some specific handling.

Reimplemented in DerivedMoveToController.

virtual bool DtSingleTaskControllerComponent::taskActive ( int  taskId) const [virtual]

Returns:
True if a task of this ID is current active in this controller.

Implements DtTaskControllerComponent.

If this controller has any top level tasks (not subtasks), they are cleared.

Returns:
True if any tasks were cleared.

Implements DtTaskControllerComponent.

virtual void DtSingleTaskControllerComponent::clearConflictingTopLevelTasks ( int  conflictId) [virtual]

Clears any top level tasks on this controller that conflict with the conflictId.

The task manager is used to determine what tasks conflict.

Implements DtTaskControllerComponent.

virtual void DtSingleTaskControllerComponent::clearTasksByType ( int  taskType) [virtual]

Clears any tasks of the specified type running in this controller.

Implements DtTaskControllerComponent.

virtual void DtSingleTaskControllerComponent::clearTaskById ( int  taskId) [virtual]

Clears any task of the specified ID running in this controller.

Implements DtTaskControllerComponent.

Returns:
A list of pointers to task messages currently being run on this controller.

Implements DtTaskControllerComponent.

Returns:
A list of all top level tasks currently in this controller along with their task state, if any.

Implements DtTaskControllerComponent.

virtual void DtSingleTaskControllerComponent::clearPendingSubtasks ( ) [protected, virtual]

Iterates over collection of all pending subtasks for this controller, and calls clearSubtask() for each subtask type.

virtual void DtSingleTaskControllerComponent::clearSubtasksByType ( int  taskType) [protected, virtual]

Clear all subtasks of a given type.

Should not normally be called (call clearSubtask(int subtaskId) to clear a given subtask instead). Provided as a utility function as an aid to backwards compatibility.


The documentation for this class was generated from the following file:

Document ID: Generated on Fri Jun 29 16:33:32 EDT 2012 from SVN revision 116588
Copyright © 2005-2012 VT MÄK Inc. All Rights Reserved (www.mak.com)