VR-Forces Developer's Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
environmentalStateComponent.h
Go to the documentation of this file.
1 /*******************************************************************************
2 ** Copyright (c) 2020 MAK Technologies, Inc.
3 ** All rights reserved.
4 *******************************************************************************/
5 
6 #pragma once
7 
10 #include <legionStandardOM/sets/readEnvironmentProcessRepository.hpp>
11 #include <legionStandardOM/sets/writeEnvironmentProcessRepository.hpp>
12 #include "vrfOM/sets/writeVrfEnvironmentRecordRepository.hpp"
13 #include "vrfOM/sets/readVrfEnvironmentRecordRepository.hpp"
14 #include <boost/signals2.hpp>
15 
16 #include <vlutil/vlString.h>
17 
19 
20 namespace makVrf
21 {
22  DT_DLL_vrfStateData extern Legion::AttributeSetId theVrfEnvironmentRecordSetType;
23 
25  {
27  : myUUID(DtUUID::nullUUID())
28  , myIsLocal(false)
29  , myCheckForNameReservation(true)
30  , myPhysicalLineHeight(0.)
31  , myPhysicalLineWidth(0.)
32  , myCeilingHeight(0.)
33  , myTickPeriod(-1)
34  {};
35 
37  {
38  myPhysicalLineHeight = orig.myPhysicalLineHeight;
39  myPhysicalLineWidth = orig.myPhysicalLineWidth;
40  myCeilingHeight = orig.myCeilingHeight;
41  myGlobalId = orig.myGlobalId;
42  myUUID = orig.myUUID;
43  myMarkingText = orig.myMarkingText;
44  myEntityId = orig.myEntityId;
45  myIsLocal = orig.myIsLocal;
46  myCheckForNameReservation = orig.myCheckForNameReservation;
47  myTickPeriod = orig.myTickPeriod;
48  }
49 
51  {
52  myPhysicalLineHeight = orig.myPhysicalLineHeight;
53  myPhysicalLineWidth = orig.myPhysicalLineWidth;
54  myGlobalId = orig.myGlobalId;
55  myUUID = orig.myUUID;
56  myMarkingText = orig.myMarkingText;
57  myEntityId = orig.myEntityId;
58  myIsLocal = orig.myIsLocal;
59  myCheckForNameReservation = orig.myCheckForNameReservation;
60  myCeilingHeight = orig.myCeilingHeight;
61  myTickPeriod = orig.myTickPeriod;
62 
63  return *this;
64  }
65 
66  DEFINE_ACCESSOR_MUTATOR(double, physicalLineHeight, PhysicalLineHeight)
67  DEFINE_ACCESSOR_MUTATOR(double, physicalLineWidth, PhysicalLineWidth)
68  DEFINE_ACCESSOR_MUTATOR(double, ceilingHeight, CeilingHeight)
69  DEFINE_ACCESSOR_MUTATOR(DtString, globalId, GlobalId)
70  DEFINE_ACCESSOR_MUTATOR(DtEntityIdentifier, entityId, EntityId)
71  DEFINE_ACCESSOR_MUTATOR(DtUUID, uuid, UUID)
72  DEFINE_ACCESSOR_MUTATOR(DtString, markingText, MarkingText)
73  DEFINE_ACCESSOR_MUTATOR(bool, isLocal, IsLocal)
74  DEFINE_ACCESSOR_MUTATOR(bool, checkForNameReservation, CheckForNameReservation)
75  DEFINE_ACCESSOR_MUTATOR(int, tickPeriod, TickPeriod)
76 
77  protected:
78  double myPhysicalLineHeight;
79  double myPhysicalLineWidth;
80  double myCeilingHeight;
81  DtString myGlobalId;
82  DtString myMarkingText;
83  DtEntityIdentifier myEntityId;
84  DtUUID myUUID;
85  bool myIsLocal;
86  bool myCheckForNameReservation;
87  int myTickPeriod;
88  };
89 
93  {
94  public:
96 
98  : DtSimulatedObjectStateComponent(storage)
99  , myUUIDColumn(0xFFFFFFFF)
100  , myMarkingTextColumn(0xFFFFFFFF)
101  , myForceTypeColumn(0xFFFFFFFF)
102  , myEntityIdColumn(0xFFFFFFFF)
103  , myAppearanceBitsColumn(0xFFFFFFFF)
104  , myObjectTypeColumn(0xFFFFFFFF)
105  {
106  }
107 
108  UNDEFINED_RETURNVALUE_ACCESSOR_MUTATOR(int, tickPeriod, TickPeriod)
109  UNDEFINED_RETURNVALUE_ACCESSOR_MUTATOR(int, color, Color)
111  UNDEFINED_RETURNREF_ACCESSOR_MUTATOR(double, physicalLineHeight, PhysicalLineHeight)
112  UNDEFINED_RETURNREF_ACCESSOR_MUTATOR(double, physicalLineWidth, PhysicalLineWidth)
113  UNDEFINED_RETURNREF_ACCESSOR_MUTATOR(double, ceilingHeight, CeilingHeight)
114 
115  virtual double intelAreaModifierForForce(int forceType) const { throw DtUnimplementedMethod("intelAreaModifierForForce(int) is not implemented for this class"); };
116 
118  virtual int recordCount() const { throw DtUnimplementedMethod("recordCount is not implemented for this class."); };
119 
121  virtual std::vector<UInt64> records() const { throw DtUnimplementedMethod("records is not implemented for this class."); };
122 
124  virtual void addRecord(Legion::WriteStateInstance) { throw DtUnimplementedMethod("addRecord is not implemented for this class."); };
125 
127  virtual void removeRecord(Legion::WriteStateInstance) { throw DtUnimplementedMethod("addRecord is not implemented for this class."); };
128 
130  virtual UInt64 instanceHandle() const { throw DtUnimplementedMethod("instanceHandle is not implemented for this class."); };
131 
132  protected:
133  UInt32 myUUIDColumn;
139  };
140 
143  {
144  public:
147 
149  const DtEnvironmentalStateComponentData& frameState() const { return myData; };
151 
152  const bool& isLocal() const;
153  void setIsLocal(const bool&);
154 
155  const bool& checkForNameReservation() const;
156  void setCheckForNameReservation(const bool&);
157 
158  const DtString& globalId() const;
159  void setGlobalId(const DtString&);
160 
161  const DtUUID& uuid() const;
162  void setUUID(const DtUUID&);
163 
164  const DtString& markingText() const;
165  void setMarkingText(const DtString&);
166 
167  const DtForceType forceType() const;
168  void setForceType(const DtForceType&);
169 
170  const UInt32 appearanceBits() const;
171  void setAppearanceBits(const UInt32&);
172  void setAppearance(const DtAppearance&);
173 
174  const DtEntityType entityType() const { return DtEntityType(objectType()); };
175  const DtObjectType objectType() const;
176  void setEntityType(const DtEntityType& t);
177 
178  const DtEntityIdentifier& entityId() const;
179  void setEntityId(const DtEntityIdentifier&);
180 
181  const int tickPeriod() const;
182  void setTickPeriod(const int&);
183 
184  const int color() const;
185  void setColor(const int&);
186 
187  const DtString userData() const;
188  void setUserData(const DtString&);
189 
190  const double& physicalLineHeight() const;
191  void setPhysicalLineHeight(const double&);
192 
193  const double& ceilingHeight() const;
194  void setCeilingHeight(const double&);
195 
196  const double& physicalLineWidth() const;
197  void setPhysicalLineWidth(const double&);
198 
200  double floor() const;
201 
203  virtual void makeWritable();
204 
206  virtual void makeReadOnly();
207 
208  int recordCount() const;
209 
211  std::vector<UInt64> records() const;
212 
214  void addRecord(Legion::WriteStateInstance);
215 
217  void removeRecord(Legion::WriteStateInstance);
218 
220  UInt64 instanceHandle() const;
221 
222  void updateVrfStateComponentParameters();
223 
224  protected:
225  void updatePhysicalLineHeightInformation();
226  void updateCeilingInformation();
227  void updatePhysicalLineWidthInformation();
228 
229  protected:
230  LOM::WriteEnvironmentProcessRepository myWriteEnvironmentProcessRepository;
231  VRF::WriteVrfEnvironmentRecordRepository myWriteVrfEnvironmentRecordRepository;
234  };
235 
238  {
239  public:
242 
244  const DtEnvironmentalStateComponentData& frameState() const { return myData; };
245 
246  const bool& isLocal() const;
247  const bool& checkForNameReservation() const;
248  const DtString& globalId() const;
249  const DtUUID& uuid() const;
250  const DtString& markingText() const;
251  const DtForceType forceType() const;
252  const DtEntityType entityType() const { return DtEntityType(objectType()); };
253  const DtObjectType objectType() const;
254  const DtEntityIdentifier& entityId() const;
255  const UInt32 appearanceBits() const;
256  const int tickPeriod() const;
257  const int color() const;
258  const DtString userData() const;
259  const double& physicalLineHeight() const;
260  const double& physicalLineWidth() const;
261  const double& ceilingHeight() const;
262  double intelAreaModifierForForce(int forceType) const;
263 
264  bool readComponentValid() const;
265 
266  bool findReadComponent();
267 
268  virtual int recordCount() const;
269 
271  virtual std::vector<UInt64> records() const;
272 
274  UInt64 instanceHandle() const;
275 
276  bool checkForUpdatedItems();
277 
278  protected:
279  const DtUUID _uuid() const;
280  const DtString _markingText() const;
281  const DtEntityIdentifier _entityId() const;
282 
283  void completeSetup();
284  void updateVrfStateComponentParameters();
285 
286  void updatePhysicalLineHeightInformation();
287  void updateCeilingInformation();
288  void updatePhysicalLineWidthInformation();
289 
290  void handleDataUpdated(const std::vector<UInt32>& attributesUpdated);
291  bool checkUUIDChanged();
292  bool checkForceChanged();
293  bool checkMarkingTextChanged();
294  bool checkEntityIdChanged();
295 
298  {
299  myData = data;
300  }
301 
302  protected:
303  boost::signals2::scoped_connection myVrfStateComponentChangedConnection;
305  LOM::ReadEnvironmentProcessRepository myReadEnvironmentProcessRepository;
306  VRF::ReadVrfEnvironmentRecordRepository myReadVrfEnvironmentRecordRepository;
307  unsigned int myCallbackHandle;
308  unsigned int myDataCallbackHandle;
312  std::string myMarkingText;
313 
316  };
317 
321  {
322  public:
325 
326  bool isDoubleBuffered() { return true; };
327  const DtFrameStateInterface* currentFrameState() const { return &myCurrentFrameState; }
328  virtual DtFrameStateInterface* nextFrameState() { return &myNextFrameState; };
329  virtual const DtFrameStateInterface* nextFrameState() const { return &myNextFrameState; };
330 
332  virtual bool forceAdvance();
333  static void addAdditionalTableColumns(Legion::SimulationDatabase* db);
334 
336  {
337  if (!myFoundComponent)
338  {
339  myFoundComponent = myCurrentFrameState.findReadComponent();
340  }
341 
342  if (myNextFrameState.isWritable())
343  {
344  myNextFrameState.updateVrfStateComponentParameters();
345  myCurrentFrameState.advanceFrame(myNextFrameState.frameState());
346  }
347 
348  myCurrentFrameState.checkForUpdatedItems();
349  myCurrentFrameState.emitComponentUpdated();
350  }
351 
353  {
354  myCurrentFrameState.updateStateData(sd);
355  myNextFrameState.updateStateData(sd);
356  }
357 
359  virtual void convertToRemote();
360 
362  virtual void convertToLocal();
363 
364  Legion::WriteStateInstance writeStateInstance() override { return myWriteEnvironmentProcessRepository; };
365 
366  virtual void addAdditionalStateComponents() override;
367 
369  virtual void firstFrameAdvance() override;
370 
371  virtual void aboutToBeDeleted() override
372  {
374  myCurrentFrameState.aboutToBeDeleted();
375  myNextFrameState.aboutToBeDeleted();
376  }
377 
378  protected:
381  LOM::WriteEnvironmentProcessRepository myWriteEnvironmentProcessRepository;
384  boost::signals2::scoped_connection myVrfStateComponentChangedConnection;
385  };
386 
390 }
UUID is a unique ID wrapper class.
Definition: uuid.h:59
bool myFoundComponent
Definition: environmentalStateComponent.h:382
double myPhysicalLineHeight
Definition: environmentalStateComponent.h:78
UInt32 myCenterPointColumn
Definition: environmentalStateComponent.h:309
unsigned int UInt32
Definition: stateDataTypes.h:18
DtEnvironmentalStateComponentData & operator=(const DtEnvironmentalStateComponentData &orig)
Definition: environmentalStateComponent.h:50
4) Define the state component that will contain the wrappers to the next and current frame states tha...
Definition: environmentalStateComponent.h:320
DtEnvironmentalStateComponentData & frameState()
Definition: environmentalStateComponent.h:150
Definition: stateDataTypes.h:23
DT_DLL_vrfStateData Legion::AttributeSetId theVrfEnvironmentRecordSetType
const DtEnvironmentalStateComponentData & frameState() const
Next frame access write access. Ensure this is only used in a single thread (i.e.a controller thread)...
Definition: environmentalStateComponent.h:149
virtual std::vector< UInt64 > records() const
Returns instance handles to all the records in this environmental.
Definition: environmentalStateComponent.h:121
LOM::WriteEnvironmentProcessRepository myWriteEnvironmentProcessRepository
Definition: environmentalStateComponent.h:381
DtEnvironmentalStateComponentData(const DtEnvironmentalStateComponentData &orig)
Definition: environmentalStateComponent.h:36
virtual void aboutToBeDeleted() override
Definition: environmentalStateComponent.h:371
unsigned int myCallbackHandle
Definition: environmentalStateComponent.h:307
bool isDoubleBuffered()
Definition: environmentalStateComponent.h:326
DtEnvironmentalStateComponentData myData
Definition: environmentalStateComponent.h:315
Definition: stateComponent.h:266
UInt32 myOrientationColumn
Definition: environmentalStateComponent.h:310
The DtSimulatedObjectStateComponent is an interface that all main components (those that are consider...
Definition: simulatedObjectStateComponent.h:21
double myCeilingHeight
Definition: environmentalStateComponent.h:80
std::string myMarkingText
Definition: environmentalStateComponent.h:312
DtEnvironmentalStateComponentCurrentFrame myCurrentFrameState
Definition: environmentalStateComponent.h:379
VRF::ReadVrfEnvironmentRecordRepository myReadVrfEnvironmentRecordRepository
Definition: environmentalStateComponent.h:306
virtual int recordCount() const
Number of additional records.
Definition: environmentalStateComponent.h:118
DtEnvironmentalStateComponentData()
Definition: environmentalStateComponent.h:26
UInt32 myMarkingTextColumn
Definition: environmentalStateComponent.h:134
void advanceFrame(const DtEnvironmentalStateComponentData &data)
Definition: environmentalStateComponent.h:297
DtStateComponentCreator< DtEnvironmentalStateComponentImplementation > DtEnvironmentalStateComponentCreator
5) Define the creator. This will need to be registered with the REGISTER_STATE_COMPONENT macro in the...
Definition: environmentalStateComponent.h:389
VRF::WriteVrfEnvironmentRecordRepository myWriteVrfEnvironmentRecordRepository
Definition: environmentalStateComponent.h:231
DtRwIntelCollectionArea * myIntelCollectionAreaInformation
Definition: environmentalStateComponent.h:304
UInt32 myAppearanceBitsColumn
Definition: environmentalStateComponent.h:137
The overall structure of the DtStateData mechanism is: The DtStateData contains a list of double buff...
Definition: stateData.h:339
2) Define the next frame class. This will be used for write access.
Definition: environmentalStateComponent.h:142
#define DEFINE_STATE_COMPONENT_TYPE(CreatedComponent)
Definition: stateComponent.h:228
int myTickPeriod
Definition: environmentalStateComponent.h:87
LOM::ReadEnvironmentProcessRepository myReadEnvironmentProcessRepository
Definition: environmentalStateComponent.h:305
void updateStateData(DtStateData *sd)
Implement to update data storage to the new state data.
Definition: environmentalStateComponent.h:352
bool myCheckForNameReservation
Definition: environmentalStateComponent.h:86
Subclass from this to indicate that this will be a double buffered state component.
Definition: stateComponent.h:379
DtString myMarkingText
Definition: environmentalStateComponent.h:82
bool myCheckedForVrfStateComponent
Definition: environmentalStateComponent.h:383
3) Define the current frame class. This will be used for read access.
Definition: environmentalStateComponent.h:237
const DtEntityType entityType() const
Definition: environmentalStateComponent.h:174
unsigned int myDataCallbackHandle
Definition: environmentalStateComponent.h:308
DtEnvironmentalStateComponentNextFrame myNextFrameState
Definition: environmentalStateComponent.h:380
#define UNDEFINED_RETURNVALUE_ACCESSOR_MUTATOR(Type, Member, Set)
Definition: doubleBufferedDataStorage.h:53
unsigned long long UInt64
Definition: stateDataTypes.h:17
Definition: environmentalStateComponent.h:24
virtual void aboutToBeDeleted()
virtual DtFrameStateInterface * nextFrameState()
Definition: environmentalStateComponent.h:328
UInt32 myForceTypeColumn
Definition: environmentalStateComponent.h:135
boost::signals2::scoped_connection myVrfStateComponentChangedConnection
Definition: environmentalStateComponent.h:384
const DtEnvironmentalStateComponentData & frameState() const
Current frame state only can access current frame buffers. This ensures thread safety.
Definition: environmentalStateComponent.h:244
class DtRwIntelCollectionArea:
Definition: rwIntelCollectionArea.h:22
#define UNDEFINED_RETURNREF_ACCESSOR_MUTATOR(Type, Member, Set)
Definition: doubleBufferedDataStorage.h:57
Legion::WriteStateInstance writeStateInstance() override
Definition: environmentalStateComponent.h:364
UInt32 myObjectTypeColumn
Definition: environmentalStateComponent.h:138
#define DEFINE_ACCESSOR_MUTATOR(ReturnType, Accessor, Mutator)
Definition: doubleBufferedDataStorage.h:23
int myForceId
Definition: environmentalStateComponent.h:311
double myPhysicalLineWidth
Definition: environmentalStateComponent.h:79
DtEntityIdentifier myEntityId
Definition: environmentalStateComponent.h:83
LOM::WriteEnvironmentProcessRepository myWriteEnvironmentProcessRepository
Definition: environmentalStateComponent.h:230
virtual void removeRecord(Legion::WriteStateInstance)
Removes a record from this environmental (this must be an instance handle)
Definition: environmentalStateComponent.h:127
#define DT_DLL_vrfStateData
This file is used to determine how to build Disable inconsistent dll linkage warning Visual Studio 6...
Definition: vrfStateDataDefines.h:26
bool myIsLocal
Definition: environmentalStateComponent.h:85
DtStateData * myStateData
Definition: environmentalStateComponent.h:232
DtUUID myUUID
Definition: environmentalStateComponent.h:84
virtual const DtFrameStateInterface * nextFrameState() const
Definition: environmentalStateComponent.h:329
const DtEntityType entityType() const
Definition: environmentalStateComponent.h:252
const DtFrameStateInterface * currentFrameState() const
Definition: environmentalStateComponent.h:327
DtString myGlobalId
Definition: environmentalStateComponent.h:81
UInt32 myEntityIdColumn
Definition: environmentalStateComponent.h:136
This is a simple base class that will be used to return a pointer to current or next frame state...
Definition: stateComponent.h:291
DtStateData * myStateData
Definition: environmentalStateComponent.h:314
DtEnvironmentalStateComponentData myData
Definition: environmentalStateComponent.h:233
virtual void addRecord(Legion::WriteStateInstance)
Adds a new record to this environmental (this must be an instance handle)
Definition: environmentalStateComponent.h:124
boost::signals2::scoped_connection myVrfStateComponentChangedConnection
Definition: environmentalStateComponent.h:303
1) Define the interface class that will be used to represent the next and curent frames. The UNDEFINED_ macros are convenience macros that will define methods that throw exceptions (until they are implemented)
Definition: environmentalStateComponent.h:92
void updateDataStorage()
Implement to update data storage. Called from advanceFrame.
Definition: environmentalStateComponent.h:335

Document ID: Generated on Tue Sep 24 19:28:17 EDT 2024 from SVN revision 269799
Copyright © 2005-2024 MAK Technologies. All Rights Reserved (www.mak.com)