VR-Forces 4.7 Class Documentation
Home
Modules
Namespaces
Classes
Files
Examples
Behavior Models
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Properties
Friends
Macros
Groups
Pages
examples
decideToGiveUpTask
derivedMoveToController.h
Go to the documentation of this file.
1
/*******************************************************************************
2
** Copyright (c) 1999 MAK Technologies, Inc.
3
** All rights reserved.
4
*******************************************************************************/
5
/*******************************************************************************
6
** $RCSfile: derivedMoveToController.h,v $ $Revision: 1.5 $ $State: Exp $
7
*******************************************************************************/
8
9
//
10
//File: DerivedMoveToController.h
11
//
12
//Class: DerivedMoveToController
13
//
14
15
16
#ifndef DerivedMoveToController_H_
17
#define DerivedMoveToController_H_
18
19
20
#include "
vrfmodel/groundMoveToControllerComponent.h
"
21
22
//
23
//Class Description: DerivedMoveToController
24
//
25
//The purpose of this class is to demonstrate how to check for and handle
26
//a situation in which an entity is unable to carry out a given task behavior.
27
//In this particular example, it extends the DtGroundMoveToControllerComponent
28
//with the ability to determine when it should 'give up' trying to reach its
29
//waypoint. The criteria for determining it should give up trying to complete
30
//its task is that it should stop trying after 10 seconds. At that point, it
31
//sends a task complete report, indicating it has finished (although it may be
32
//no where near its destination).
33
//
34
//There are 2 required member functions that this class overrides to implement
35
//the 'give up' behavior:
36
//
37
//decideToGiveUpTask() : This is the function that looks at the current
38
//situation and decides if it should give up. It will be automatically called
39
//immediately following the entity's tick().
40
//
41
//giveUpTask() : This gets called when the decideToGiveUpTask() returns true.
42
//In this example, it calls taskComplete(), which results in a task complete
43
//report being sent and the controller put into a non-tasked state.
44
45
class
DerivedMoveToController
:
public
DtGroundMoveToControllerComponent
46
{
47
public
:
48
49
//constructor
50
DerivedMoveToController
(
const
DtString
&
name
,
51
DtVrfObject
* owner,
52
DtSimManager
*
simManager
,
53
DtComponentDescriptor
* desc = NULL,
54
DtReaderWriterRegistry
* parentRegistry = NULL);
55
56
//destructor
57
virtual
~DerivedMoveToController
();
58
59
//Override to initialize myTimeToGiveUp member to current time plus 10 seconds.
60
//We'll check this in decideToGiveUp(). Note that this function is only
61
//overridden for this particular time-based criteria for giving up. You would
62
//not in general have to override this to add a 'decide to give up' capability
63
//to a controller.
64
virtual
void
processMoveToTask
(
DtSimMessage
* msg);
65
66
//Creates and returns a new DerivedMoveToController
67
static
DtSimComponent
*
creator
(
const
DtString
& name,
68
DtVrfObject
* owner,
69
DtSimManager
* simManager,
70
DtComponentDescriptor
* desc = NULL,
71
DtReaderWriterRegistry
* parentRegistry = NULL);
72
73
protected
:
74
75
//Override to see if we should give up after 10 seconds (checks current
76
//simulation time against myTimeToGiveUp).
77
virtual
bool
decideToGiveUpTask
()
const
;
78
79
//Calls taskComplete(). This will result in a DtTaskComplete report being
80
//sent to whomever issued the task.
81
virtual
void
giveUpTask
();
82
83
private
:
84
//Default constructor; should not be called. Here because the compiler
85
//will generate an unprotected one otherwise.
86
DerivedMoveToController
();
87
88
//copy constructor; shallow; does not copy the ports.
89
DerivedMoveToController
(
const
DerivedMoveToController
&
90
orig);
91
92
//assignment operator; see comments on copy constructor!
93
const
DerivedMoveToController
&
operator=
(
const
94
DerivedMoveToController
& orig);
95
96
protected
:
97
98
//This is the time we decide we want to give up when the entity
99
//is executing a task.
100
DtTime
myTimeToGiveUp
;
101
};
102
103
#endif
104
105
106
Document ID: Generated on Fri Apr 26 21:53:14 EDT 2019 from SVN revision 197883
Copyright © 2005-2019 VT MAK. All Rights Reserved (
www.mak.com
)