VR-Forces 5.0.1 Developer's Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
spawnController.h
Go to the documentation of this file.
1 /*******************************************************************************
2 ** Copyright (c) 2012 MAK Technologies, Inc.
3 ** All rights reserved.
4 *******************************************************************************/
5 
8 
9 #pragma once
10 
13 
18 #include <vrfmsgs/rwSpawnData.h>
19 
20 class DtString;
22 class DtVrfObjectMessage;
23 class DtRwObjectTypeInfo;
24 class DtSimMessage;
26 
31 
37 {
38 public:
39 
40 //****************************************************************************
42 //****************************************************************************
43  DtSpawnController(const DtString& name,
44  DtLocalObject* owner,
45  DtSimulationServices* simManager,
46  DtComponentDescriptor* desc = 0,
47  DtReaderWriterRegistry* parentRegistry = 0);
48 
50  virtual ~DtSpawnController();
51 
52  virtual const char* type() const;
53 
57  static DtSimComponent * creator(const DtString& name,
58  DtLocalObject* owner,
59  DtSimulationServices* simManager,
60  DtComponentDescriptor* desc = 0,
61  DtReaderWriterRegistry* parentRegistry = 0);
62 
64  const DtString& templateName() const;
65 
66 //****************************************************************************
68 //****************************************************************************
69  static void settingConsumerCallback(const DtSettingsObject* settingsObject,
70  void* usr);
71 
73 
75  virtual void registerTaskMsgCallbacks();
77 
79  virtual void unregisterTaskMsgCallbacks();
80 
81  virtual bool init();
82  virtual void refreshSpawnTemplateData();
83 
84 protected:
85  virtual void processSetting(const DtBoolSetting* setting);
86 
87  virtual DtSpawnControllerPSR* createPSR();
88 
90  virtual DtCollisionDetector* createCollisionDetector();
91 
92 //****************************************************************************
94 //****************************************************************************
95  static void requestSpawnPtDataCallback(const DtVrfObjectMessage * msg,
96  void* usr);
97  virtual void processRequestSpawnPtDataCallback(const DtVrfObjectMessage * msg);
98 
99  static void setTemplateUUIDCallback(const DtVrfObjectMessage * msg, void* usr);
100  virtual void processSetTemplateUUIDCallback(const DtVrfObjectMessage * msg);
101 
102  virtual void processSimObjectDeleted(DtSimObjectReference ref);
103 
107  virtual void embarkIfSpawnAttached(DtVrfLocalObjectCreateInformation& info);
108 
109 //****************************************************************************
111 //****************************************************************************
112 public:
118  virtual void preFirstTickInit();
119 
121  virtual void tick();
122 
123 protected:
124 
125 //****************************************************************************
127 //****************************************************************************
130  virtual std::list<DtSimObjectReference> testAndSinkTraffic();
133  virtual bool shouldSinkObject(const DtSimObject* trafficObject,
134  const DtSimObject* sinkPoint) const;
136  virtual void deleteObjects(const std::list<DtSimObjectReference>& objectList);
137 
149  virtual bool canCreateNow(DtTime timeNow, DtRwSpawnData* spawnData) const;
150 
152  virtual DtUUID findSinkPoint();
153 
157  virtual DtTime nextCreationTime(DtTime timeNow, DtRwSpawnData* spawnData);
158 
159  virtual DtCreateObjectHandle createObject(const DtUUID& spawnObjectUUID, const DtSimObject* sinkPoint, const DtRwSpawnData* spawnData,
160  bool& dataAvailable, const DtPlan& entityPlan);
162  virtual DtVector creationLocationAndOrientation(double& heading,
163  const DtSimObject* sinkPoint, const DtRwSpawnData* spawnData, bool& dataAvailable);
164 
167  virtual DtPlan createDefaultPlan(const DtUUID& objectUUID, const DtUUID& sinkPoint, DtRwSpawnData* spawnData);
168 
171  virtual double trafficSpeed(DtRwSpawnData* spawnData);
172 
176  virtual bool trafficObjectType(DtRwObjectTypeInfo& objType, const DtRwSpawnData* spawnData);
177 
179  void findClosestRoadSpawnPoints();
180 
181  static void clearTemplatesCallback(void* user);
182  virtual void processClearTemplates();
183 
184  static void refreshSpawnTemplateDataCallback(void* user);
185  virtual void processRefreshSpawnTemplateData();
186 
189  virtual bool startLocationTaken(const DtSimObject*, const DtVector& geocentricLocation);
190  virtual bool startLocationTaken(const DtObjectType&, const DtVector& geocentricLocation);
191 
192 protected:
193 
194  virtual DtRwSpawnData* lookupSpawnTemplateData();
195 
196 private:
199 
202 
204  const DtSpawnController & operator=(const DtSpawnController & orig);
205 
206 
207 protected:
208 
213 
219 
222 
227  //DtRwSpawnData* mySpawnTemplateData;
228 
231 
233 
234  boost::signals2::scoped_connection mySimObjectDeletedConnection;
235 };
UUID is a unique ID wrapper class.
Definition: rwUUID.h:226
DtPoint myClosestRoadEdgeA
Definition: spawnController.h:217
#define DT_DLL_vrfmodel
This file is used to determine how to build.
Definition: vrfmodelDefines.h:24
bool myShowRoadDistanceWarning
Definition: spawnController.h:220
const DtControllerComponent & operator=(const DtControllerComponent &orig)
assignment operator
Handle returned from Create Object Service calls.
Definition: createObjectHandle.h:12
Definition: boolSetting.h:30
This controller is part of the traffic spawn system. It creates new entities at a defined interval an...
Definition: spawnController.h:36
DtPoint myClosestRoadEdgeB
Definition: spawnController.h:218
virtual void preFirstTickInit()
This function can be overridden to initialize a component before it is ticked for the first time...
virtual const char * type() const =0
This returns a string from compTypes.h, and identifies the type of component.
The DtSimObjectReference is a shared pointer that can be used amongst many object for access to the u...
Definition: simObjectReference.h:26
bool myWarnedSinkOnce
Definition: spawnController.h:226
A readable, writable type whose name is the name of a component and that has a list of component name...
Definition: componentDescriptor.h:49
Descriptor for DtSpawnController.
Definition: spawnControllerDescriptor.h:21
Definition: readerWriterRegistry.h:39
The DtLocalObjectCreateInformation class is a subset of the information used in the DtIfCreateVrfObje...
Definition: vrfLocalObjectCreateInformation.h:26
virtual bool init()
Calls setRadio()
DtCollisionDetector * myCollisionDetector
Definition: spawnController.h:230
Definition: settingsObject.h:27
bool myWarnedOnce
Definition: spawnController.h:225
boost::signals2::scoped_connection mySimObjectDeletedConnection
Definition: spawnController.h:234
DtPoint myCachedLocation
Definition: spawnController.h:214
Definition: objectType.h:27
Process state repository used to store runtime state of the DtSpawnController.
Definition: spawnControllerPSR.h:23
bool myDrivingOnLeftEnabled
Definition: spawnController.h:211
int myAwaitingToBeCreated
Count of number of objects that are pending to be created due to data not being available.
Definition: spawnController.h:224
Base library for data that is used to control how spawn points generate entities. This data structure...
Definition: rwSpawnData.h:37
File: simMsg.h.
Definition: simMessage.h:35
virtual void tick()
This gives the thread of control to the component. The component is ticked once each simulation from ...
DtRwObjectTypeInfo holds a display name and force number along with the type enumeration. Used in spawn data messages.
Definition: rwObjectTypeInfo.h:28
The DtCollisionDetector is a class used to detect collisions between a specified list of obstructions...
Definition: collisionDetector.h:54
The base class for all messages to/from a specific DtVrfObject. Various subclasses of this class will...
Definition: vrfObjectMessage.h:30
DtVrfOverlayObjectStateRepository * myStateRepository
Definition: spawnController.h:229
DtReal mySinkPointRadiusSq
Definition: spawnController.h:212
End User Description: DtControllerComponent is the base class for all controllers components...
Definition: controllerComponent.h:31
class DtPlan:
Definition: plan.h:92
const DtSpawnControllerDescriptor * myTrafficSourceDescriptor
Definition: spawnController.h:210
float myScaleFactor
Definition: spawnController.h:232
DtPoint myClosestRoadPoint
Definition: spawnController.h:216
Central access point of all non-object-specific the services and managers that are available for use ...
Definition: simulationServices.h:89
bool myFoundRoadPoints
Definition: spawnController.h:215
The DtSimComponent class is the base class for the entire simulation model component hierarchy...
Definition: simComponent.h:70
Represents a single simulation object in the exercise. Object may be VRF simulation, or non-VRF simulated, and may be simulated by the local sim engine, or by a remote sim engine. Only public (external) state of the object is available. All data is read-only. All access to data of the object is thread safe within the simulation frame.
Definition: simObject.h:79
Definition: vrfOverlayObjectStateRepository.h:30
bool myDataReady
Definition: spawnController.h:221
DtSpawnControllerPSR * myProcessState
Definition: spawnController.h:209
Definition: point.h:34
A locally simulated VRF object. Holds all internal and external data for the object, and provides access to both the current frame and next frame state data for the object. All current frame data is read-only, and next-frame data can be written to. No thread safety guarantees are made on this object during the simulation frame and it should only be accessed by the thread that is simulating the object.
Definition: localObject.h:86

Document ID: Generated on Mon Jun 20 00:38:30 EDT 2022 from SVN revision 244029
Copyright © 2005-2021 MAK Technologies. All Rights Reserved (www.mak.com)