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

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

Inheritance diagram for DtMultiTaskControllerComponent:
Inheritance graph
[legend]

List of all members.

Public Member Functions

 DtMultiTaskControllerComponent (const DtString &name, DtVrfObject *owner, DtSimManager *simManager, DtComponentDescriptor *compDesc=0, DtReaderWriterRegistry *parentRegistry=0)
 (const DtString& name,
virtual ~DtMultiTaskControllerComponent ()
 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 taskComplete (int taskId, bool success)
 This indicates that the specified task is complete.
virtual void clearTask (int taskId)
 Clears the specified task out, includes any related subtasks.
virtual DtTaskMessagecurrentTaskMessage (int taskId)
virtual DtSimTaskStatePtr currentTaskState (int taskId) const
virtual int sendSubtask (DtSimTask &task, int taskId)
 Sends subtask to ourself.
virtual void clearSubtask (int subtaskId, int taskId)
 Clears subtask with the given subtaskId (subtaskId is returned sendSubtask()).
virtual void addPendingSubtaskId (int subtaskId, int taskId)
 Adds given subtask Id to list of pending subtasks.
virtual bool findPendingSubtaskId (int subtaskId, int taskId)
 Checks to see if given subtaskId exists in our list of pending subtasks.
virtual void removePendingSubtaskId (int subtaskId, int taskId)
 Removes pending subtask from list of subtasks for this component.
virtual void removeAllPendingSubtaskIds (int taskId)
 Clear all pending subtasks from our list of subtasks for taskId.
virtual std::vector< int > currentPendingSubstaskIds (int taskId) const
 Returns the list of all currently pending subtask ids for this controller.
virtual bool decideToGiveUpTask () const
 The DtMultiTaskControllerComponent does not current support decideToGiveUp.
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 addCurrentTaskMessage (const DtTaskMessage *taskMessage)
 Adds a new task message to the list of current tasks for this controller.
virtual void clearCurrentTaskMessage (int taskId)
 Removes task with the specified task ID from the list of current tasks for this controller.
virtual void clearPendingSubtasks (int taskId)
 Iterates over collection of all pending subtasks for this controller, and calls clearSubtask() for each subtask type.
virtual void clearSubtasksByType (int taskType, int taskId)
 Clear all subtasks of a given type.
virtual int taskIdWhichStartedSubtask (int subtaskId)

Detailed Description

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

This is a special case for some controllers. Typeically, task controllers will be derived from DtSingleTaskControllerComponent.


Constructor & Destructor Documentation

DtMultiTaskControllerComponent::DtMultiTaskControllerComponent ( 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 DtMultiTaskControllerComponent::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.

virtual bool DtMultiTaskControllerComponent::beginProcessingTask ( const DtTaskMessage task,
DtSimTaskStatePtr  taskState 
) [virtual]

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.

virtual void DtMultiTaskControllerComponent::taskComplete ( int  taskId,
bool  success 
) [virtual]

This indicates that the specified task is complete.

This will kick off a series of events in the task manager to clean up this task and notify anyone relevant of the state change. To indicate that the task has failed (and is being abandoned) call this method with success set to false.

virtual void DtMultiTaskControllerComponent::clearTask ( int  taskId) [virtual]

Clears the specified task out, includes any related subtasks.

Returns:
Pointer to the current task message with the specified id.
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.
virtual int DtMultiTaskControllerComponent::sendSubtask ( DtSimTask task,
int  taskId 
) [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 DtMultiTaskControllerComponent::clearSubtask ( int  subtaskId,
int  taskId 
) [virtual]

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

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

Parameters:
taskIdIs the task ID of the task which owns this subtask.
virtual void DtMultiTaskControllerComponent::addPendingSubtaskId ( int  subtaskId,
int  taskId 
) [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 DtMultiTaskControllerComponent::findPendingSubtaskId ( int  subtaskId,
int  taskId 
) [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 DtMultiTaskControllerComponent::removePendingSubtaskId ( int  subtaskId,
int  taskId 
) [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.

virtual void DtMultiTaskControllerComponent::removeAllPendingSubtaskIds ( int  taskId) [virtual]

Clear all pending subtasks from our list of subtasks for taskId.

Users should not typically have to call this.

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

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

The DtMultiTaskControllerComponent does not current support decideToGiveUp.

This function always returns false.

virtual void DtMultiTaskControllerComponent::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.

virtual bool DtMultiTaskControllerComponent::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 DtMultiTaskControllerComponent::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 DtMultiTaskControllerComponent::clearTasksByType ( int  taskType) [virtual]

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

Implements DtTaskControllerComponent.

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

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

Implements DtTaskControllerComponent.

virtual std::list<DtTaskMessage*> DtMultiTaskControllerComponent::currentTaskMessages ( ) const [virtual]

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 DtMultiTaskControllerComponent::addCurrentTaskMessage ( const DtTaskMessage taskMessage) [protected, virtual]

Adds a new task message to the list of current tasks for this controller.

virtual void DtMultiTaskControllerComponent::clearCurrentTaskMessage ( int  taskId) [protected, virtual]

Removes task with the specified task ID from the list of current tasks for this controller.

virtual void DtMultiTaskControllerComponent::clearPendingSubtasks ( int  taskId) [protected, virtual]

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

virtual void DtMultiTaskControllerComponent::clearSubtasksByType ( int  taskType,
int  taskId 
) [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.

virtual int DtMultiTaskControllerComponent::taskIdWhichStartedSubtask ( int  subtaskId) [protected, virtual]
Returns:
The task Id of the task which started the subtask with the specified id.

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)