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 #define DtLineWidthFromAppearance(theAppr) ((theAppr >> 28) & 0x0000000F)
21 #define DtLineWidthToAppearance(theLineWidth) (theLineWidth << 28)
22 #define DtLineStyleFromAppearance(theAppr) ((theAppr >> 8) & 0x0000000F)
23 #define DtLineStyleToAppearance(theLineStyle) (theLineStyle << 8)
24 #define DtFillStyleFromAppearance(theAppr) ((theAppr >> 12) & 0x0000000F)
25 #define DtFillStyleToAppearance(theFillStyle) (theFillStyle << 12)
26 
27 namespace makVrf
28 {
29  DT_DLL_vrfStateData extern Legion::AttributeSetId theVrfEnvironmentRecordSetType;
30 
32  {
34  : myUUID(DtUUID::nullUUID())
35  , myIsLocal(false)
36  , myCheckForNameReservation(true)
37  , myPhysicalLineHeight(0.)
38  , myPhysicalLineWidth(0.)
39  , myCeilingHeight(0.)
40  , myTickPeriod(-1)
41  {};
42 
44  {
45  myPhysicalLineHeight = orig.myPhysicalLineHeight;
46  myPhysicalLineWidth = orig.myPhysicalLineWidth;
47  myCeilingHeight = orig.myCeilingHeight;
48  myGlobalId = orig.myGlobalId;
49  myUUID = orig.myUUID;
50  myMarkingText = orig.myMarkingText;
51  myEntityId = orig.myEntityId;
52  myIsLocal = orig.myIsLocal;
53  myCheckForNameReservation = orig.myCheckForNameReservation;
54  myTickPeriod = orig.myTickPeriod;
55  myUserData = orig.myUserData;
56  }
57 
59  {
60  myPhysicalLineHeight = orig.myPhysicalLineHeight;
61  myPhysicalLineWidth = orig.myPhysicalLineWidth;
62  myGlobalId = orig.myGlobalId;
63  myUUID = orig.myUUID;
64  myMarkingText = orig.myMarkingText;
65  myEntityId = orig.myEntityId;
66  myIsLocal = orig.myIsLocal;
67  myCheckForNameReservation = orig.myCheckForNameReservation;
68  myCeilingHeight = orig.myCeilingHeight;
69  myTickPeriod = orig.myTickPeriod;
70  myUserData = orig.myUserData;
71 
72  return *this;
73  }
74 
75  DEFINE_ACCESSOR_MUTATOR(double, physicalLineHeight, PhysicalLineHeight)
76  DEFINE_ACCESSOR_MUTATOR(double, physicalLineWidth, PhysicalLineWidth)
77  DEFINE_ACCESSOR_MUTATOR(double, ceilingHeight, CeilingHeight)
78  DEFINE_ACCESSOR_MUTATOR(DtString, globalId, GlobalId)
79  DEFINE_ACCESSOR_MUTATOR(DtEntityIdentifier, entityId, EntityId)
80  DEFINE_ACCESSOR_MUTATOR(DtUUID, uuid, UUID)
81  DEFINE_ACCESSOR_MUTATOR(DtString, markingText, MarkingText)
82  DEFINE_ACCESSOR_MUTATOR(bool, isLocal, IsLocal)
83  DEFINE_ACCESSOR_MUTATOR(bool, checkForNameReservation, CheckForNameReservation)
84  DEFINE_ACCESSOR_MUTATOR(int, tickPeriod, TickPeriod)
85  DEFINE_ACCESSOR_MUTATOR(unsigned long long, userData, UserData)
86 
87  protected:
88  double myPhysicalLineHeight;
89  double myPhysicalLineWidth;
90  double myCeilingHeight;
91  unsigned long long myUserData = 0;
92  DtString myGlobalId;
93  DtString myMarkingText;
94  DtEntityIdentifier myEntityId;
95  DtUUID myUUID;
96  bool myIsLocal;
97  bool myCheckForNameReservation;
98  int myTickPeriod;
99  };
100 
104  {
105  public:
107 
109  : DtSimulatedObjectStateComponent(storage)
110  , myUUIDColumn(0xFFFFFFFF)
111  , myMarkingTextColumn(0xFFFFFFFF)
112  , myForceTypeColumn(0xFFFFFFFF)
113  , myEntityIdColumn(0xFFFFFFFF)
114  , myAppearanceBitsColumn(0xFFFFFFFF)
115  , myObjectTypeColumn(0xFFFFFFFF)
116  {
117  }
118 
119  UNDEFINED_RETURNVALUE_ACCESSOR_MUTATOR(int, tickPeriod, TickPeriod)
120  UNDEFINED_RETURNVALUE_ACCESSOR_MUTATOR(int, color, Color)
122  UNDEFINED_RETURNREF_ACCESSOR_MUTATOR(double, physicalLineHeight, PhysicalLineHeight)
123  UNDEFINED_RETURNREF_ACCESSOR_MUTATOR(double, physicalLineWidth, PhysicalLineWidth)
124  UNDEFINED_RETURNREF_ACCESSOR_MUTATOR(double, ceilingHeight, CeilingHeight)
125  UNDEFINED_RETURNVALUE_ACCESSOR(int, penStyle)
126  UNDEFINED_RETURNVALUE_ACCESSOR(int, fillStyle)
127  UNDEFINED_RETURNVALUE_ACCESSOR(int, lineWidth)
128 
129  virtual double intelAreaModifierForForce(int forceType) const { throw DtUnimplementedMethod("intelAreaModifierForForce(int) is not implemented for this class"); };
130 
132  virtual int recordCount() const { throw DtUnimplementedMethod("recordCount is not implemented for this class."); };
133 
135  virtual std::vector<UInt64> records() const { throw DtUnimplementedMethod("records is not implemented for this class."); };
136 
138  virtual void addRecord(Legion::WriteStateInstance) { throw DtUnimplementedMethod("addRecord is not implemented for this class."); };
139 
141  virtual void removeRecord(Legion::WriteStateInstance) { throw DtUnimplementedMethod("addRecord is not implemented for this class."); };
142 
144  virtual UInt64 instanceHandle() const { throw DtUnimplementedMethod("instanceHandle is not implemented for this class."); };
145 
146  protected:
147  UInt32 myUUIDColumn;
153  };
154 
157  {
158  public:
160  virtual ~DtEnvironmentalStateComponentNextFrame() override;
161 
163  const DtEnvironmentalStateComponentData& frameState() const { return myData; };
165 
166  virtual const int penStyle() const override;
167  virtual const int fillStyle() const override;
168  virtual const int lineWidth() const override;
169 
170  virtual const bool& isLocal() const override;
171  virtual void setIsLocal(const bool&) override;
172 
173  virtual const unsigned long long orbatId() const override { return 0; };
174  virtual void setOrbatId(const unsigned long long&) override {}
175 
176  virtual const bool& checkForNameReservation() const override;
177  virtual void setCheckForNameReservation(const bool&) override;
178 
179  virtual const DtString& globalId() const override;
180  virtual void setGlobalId(const DtString&) override;
181 
182  virtual const DtUUID& uuid() const override;
183  virtual void setUUID(const DtUUID&) override;
184 
185  virtual const DtString& markingText() const override;
186  virtual void setMarkingText(const DtString&) override;
187 
188  virtual const DtForceType forceType() const override;
189  virtual void setForceType(const DtForceType&) override;
190 
191  virtual const UInt32 appearanceBits() const override;
192  virtual void setAppearanceBits(const UInt32&) override;
193  void setAppearance(const DtAppearance&);
194 
195  virtual const DtEntityType entityType() const override { return objectType(); };
196  virtual const DtEntityType objectType() const override;
197  virtual void setEntityType(const DtEntityType& t) override;
198 
199  virtual const DtSimulationAddress simEngineAddress() const override;
200 
201  virtual const unsigned long long userLongLongData() const override;
202  virtual void setUserLongLongData(const unsigned long long&) override;
203 
204  virtual const DtEntityIdentifier& entityId() const override;
205  virtual void setEntityId(const DtEntityIdentifier&) override;
206 
207  virtual const int tickPeriod() const override;
208  virtual void setTickPeriod(const int&) override;
209 
210  virtual const int color() const override;
211  virtual void setColor(const int&) override;
212 
213  virtual const DtString userData() const override;
214  virtual void setUserData(const DtString&) override;
215 
216  virtual const double& physicalLineHeight() const override;
217  virtual void setPhysicalLineHeight(const double&) override;
218 
219  virtual const double& ceilingHeight() const override;
220  virtual void setCeilingHeight(const double&) override;
221 
222  virtual const double& physicalLineWidth() const override;
223  virtual void setPhysicalLineWidth(const double&) override;
224 
226  double floor() const;
227 
229  virtual void makeWritable() override;
230 
232  virtual void makeReadOnly() override;
233 
234  virtual int recordCount() const override;
235 
237  virtual std::vector<UInt64> records() const override;
238 
240  virtual void addRecord(Legion::WriteStateInstance) override;
241 
243  virtual void removeRecord(Legion::WriteStateInstance) override;
244 
246  virtual UInt64 instanceHandle() const override;
247 
248  void updateVrfStateComponentParameters();
249 
250  protected:
251  void updatePhysicalLineHeightInformation();
252  void updateCeilingInformation();
253  void updatePhysicalLineWidthInformation();
254 
255  protected:
256  LOM::WriteEnvironmentProcessRepository myWriteEnvironmentProcessRepository;
257  VRF::WriteVrfEnvironmentRecordRepository myWriteVrfEnvironmentRecordRepository;
259  };
260 
263  {
264  public:
266  virtual ~DtEnvironmentalStateComponentCurrentFrame() override;
267 
269  const DtEnvironmentalStateComponentData& frameState() const { return myData; };
270 
271  virtual const bool& isLocal() const override;
272  virtual const bool& checkForNameReservation() const override;
273  virtual const DtString& globalId() const override;
274  virtual const DtUUID& uuid() const override;
275  virtual const DtString& markingText() const override;
276  virtual const DtForceType forceType() const override;
277  virtual const DtEntityType entityType() const override { return objectType(); };
278  virtual const DtEntityType objectType() const override;
279  virtual const DtEntityIdentifier& entityId() const override;
280  virtual const UInt32 appearanceBits() const override;
281  virtual const int tickPeriod() const override;
282  virtual const int color() const override;
283  virtual const DtString userData() const override;
284  virtual const double& physicalLineHeight() const override;
285  virtual const double& physicalLineWidth() const override;
286  virtual const double& ceilingHeight() const override;
287  virtual double intelAreaModifierForForce(int forceType) const override;
288  virtual const unsigned long long userLongLongData() const override;
289  virtual const unsigned long long orbatId() const override { return 0; };
290  virtual const DtSimulationAddress simEngineAddress() const override;
291 
292  virtual const int penStyle() const override;
293  virtual const int fillStyle() const override;
294  virtual const int lineWidth() const override;
295 
296  bool readComponentValid() const;
297 
298  bool findReadComponent();
299 
300  virtual int recordCount() const override;
301 
303  virtual std::vector<UInt64> records() const override;
304 
306  virtual UInt64 instanceHandle() const override;
307 
308  bool checkForUpdatedItems();
309 
310  protected:
311  const DtUUID _uuid() const;
312  const DtString _markingText() const;
313  const DtEntityIdentifier _entityId() const;
314 
315  void completeSetup();
316  void updateVrfStateComponentParameters();
317 
318  void updatePhysicalLineHeightInformation();
319  void updateCeilingInformation();
320  void updatePhysicalLineWidthInformation();
321 
322  void handleDataUpdated(const std::vector<UInt32>& attributesUpdated);
323  bool checkUUIDChanged();
324  bool checkForceChanged();
325  bool checkMarkingTextChanged();
326  bool checkEntityIdChanged();
327 
330  {
331  myData = data;
332  }
333 
334  protected:
335  boost::signals2::scoped_connection myVrfStateComponentChangedConnection;
337  LOM::ReadEnvironmentProcessRepository myReadEnvironmentProcessRepository;
338  VRF::ReadVrfEnvironmentRecordRepository myReadVrfEnvironmentRecordRepository;
339  unsigned int myCallbackHandle;
340  unsigned int myDataCallbackHandle;
344  std::string myMarkingText;
345 
347  };
348 
352  {
353  public:
356 
357  bool isDoubleBuffered() { return true; };
358  virtual const DtFrameStateInterface* currentFrameState() const override { return &myCurrentFrameState; }
359  virtual DtFrameStateInterface* nextFrameState() override { return &myNextFrameState; };
360  virtual const DtFrameStateInterface* nextFrameState() const override { return &myNextFrameState; };
361 
363  virtual bool forceAdvance() override;
364  static void addAdditionalTableColumns(Legion::SimulationDatabase* db);
365 
366  virtual void updateDataStorage() override
367  {
368  if (!myFoundComponent)
369  {
370  myFoundComponent = myCurrentFrameState.findReadComponent();
371  }
372 
373  if (myNextFrameState.isWritable())
374  {
375  myNextFrameState.updateVrfStateComponentParameters();
376  myCurrentFrameState.advanceFrame(myNextFrameState.frameState());
377  }
378 
379  myCurrentFrameState.checkForUpdatedItems();
380  myCurrentFrameState.emitComponentUpdated();
381  }
382 
383  virtual void updateStateData(DtStateData* sd) override
384  {
385  myCurrentFrameState.updateStateData(sd);
386  myNextFrameState.updateStateData(sd);
387  }
388 
390  virtual void convertToRemote() override;
391 
393  virtual void convertToLocal() override;
394 
395  virtual Legion::WriteStateInstance writeStateInstance() override { return myWriteEnvironmentProcessRepository; };
396 
397  virtual void addAdditionalStateComponents() override;
398 
400  virtual void firstFrameAdvance() override;
401 
402  virtual void aboutToBeDeleted() override
403  {
405  myCurrentFrameState.aboutToBeDeleted();
406  myNextFrameState.aboutToBeDeleted();
407  }
408 
409  protected:
412  LOM::WriteEnvironmentProcessRepository myWriteEnvironmentProcessRepository;
415  boost::signals2::scoped_connection myVrfStateComponentChangedConnection;
416  };
417 
421 }
UUID is a unique ID wrapper class.
Definition: uuid.h:59
bool myFoundComponent
Definition: environmentalStateComponent.h:413
double myPhysicalLineHeight
Definition: environmentalStateComponent.h:88
UInt32 myCenterPointColumn
Definition: environmentalStateComponent.h:341
DtEnvironmentalStateComponentData & operator=(const DtEnvironmentalStateComponentData &orig)
Definition: environmentalStateComponent.h:58
4) Define the state component that will contain the wrappers to the next and current frame states tha...
Definition: environmentalStateComponent.h:351
DtEnvironmentalStateComponentData & frameState()
Definition: environmentalStateComponent.h:164
Definition: stateDataTypes.h:23
virtual Legion::WriteStateInstance writeStateInstance() override
Definition: environmentalStateComponent.h:395
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:163
virtual std::vector< UInt64 > records() const
Returns instance handles to all the records in this environmental.
Definition: environmentalStateComponent.h:135
LOM::WriteEnvironmentProcessRepository myWriteEnvironmentProcessRepository
Definition: environmentalStateComponent.h:412
DtEnvironmentalStateComponentData(const DtEnvironmentalStateComponentData &orig)
Definition: environmentalStateComponent.h:43
virtual void aboutToBeDeleted() override
Definition: environmentalStateComponent.h:402
unsigned int myCallbackHandle
Definition: environmentalStateComponent.h:339
bool isDoubleBuffered()
Definition: environmentalStateComponent.h:357
DtEnvironmentalStateComponentData myData
Definition: environmentalStateComponent.h:346
unsigned int UInt32
Definition: stateDataTypes.h:18
Definition: stateComponent.h:269
virtual void setOrbatId(const unsigned long long &) override
Definition: environmentalStateComponent.h:174
UInt32 myOrientationColumn
Definition: environmentalStateComponent.h:342
The DtSimulatedObjectStateComponent is an interface that all main components (those that are consider...
Definition: simulatedObjectStateComponent.h:21
double myCeilingHeight
Definition: environmentalStateComponent.h:90
std::string myMarkingText
Definition: environmentalStateComponent.h:344
DtEnvironmentalStateComponentCurrentFrame myCurrentFrameState
Definition: environmentalStateComponent.h:410
VRF::ReadVrfEnvironmentRecordRepository myReadVrfEnvironmentRecordRepository
Definition: environmentalStateComponent.h:338
#define UNDEFINED_RETURNVALUE_ACCESSOR(ReturnType, Member)
Definition: doubleBufferedDataStorage.h:31
virtual DtFrameStateInterface * nextFrameState() override
Definition: environmentalStateComponent.h:359
virtual int recordCount() const
Number of additional records.
Definition: environmentalStateComponent.h:132
DtEnvironmentalStateComponentData()
Definition: environmentalStateComponent.h:33
unsigned long long UInt64
Definition: stateDataTypes.h:17
UInt32 myMarkingTextColumn
Definition: environmentalStateComponent.h:148
void advanceFrame(const DtEnvironmentalStateComponentData &data)
Definition: environmentalStateComponent.h:329
DtStateComponentCreator< DtEnvironmentalStateComponentImplementation > DtEnvironmentalStateComponentCreator
5) Define the creator. This will need to be registered with the REGISTER_STATE_COMPONENT macro in the...
Definition: environmentalStateComponent.h:420
VRF::WriteVrfEnvironmentRecordRepository myWriteVrfEnvironmentRecordRepository
Definition: environmentalStateComponent.h:257
DtRwIntelCollectionArea * myIntelCollectionAreaInformation
Definition: environmentalStateComponent.h:336
virtual void updateDataStorage() override
Implement to update data storage. Called from advanceFrame.
Definition: environmentalStateComponent.h:366
UInt32 myAppearanceBitsColumn
Definition: environmentalStateComponent.h:151
virtual const unsigned long long orbatId() const override
Definition: environmentalStateComponent.h:289
The overall structure of the DtStateData mechanism is: The DtStateData contains a list of double buff...
Definition: stateData.h:398
2) Define the next frame class. This will be used for write access.
Definition: environmentalStateComponent.h:156
#define DEFINE_STATE_COMPONENT_TYPE(CreatedComponent)
Definition: stateComponent.h:231
int myTickPeriod
Definition: environmentalStateComponent.h:98
LOM::ReadEnvironmentProcessRepository myReadEnvironmentProcessRepository
Definition: environmentalStateComponent.h:337
bool myCheckForNameReservation
Definition: environmentalStateComponent.h:97
virtual const unsigned long long orbatId() const override
Definition: environmentalStateComponent.h:173
Subclass from this to indicate that this will be a double buffered state component.
Definition: stateComponent.h:384
DtString myMarkingText
Definition: environmentalStateComponent.h:93
bool myCheckedForVrfStateComponent
Definition: environmentalStateComponent.h:414
3) Define the current frame class. This will be used for read access.
Definition: environmentalStateComponent.h:262
unsigned int myDataCallbackHandle
Definition: environmentalStateComponent.h:340
DtEnvironmentalStateComponentNextFrame myNextFrameState
Definition: environmentalStateComponent.h:411
#define UNDEFINED_RETURNVALUE_ACCESSOR_MUTATOR(Type, Member, Set)
Definition: doubleBufferedDataStorage.h:53
Definition: environmentalStateComponent.h:31
virtual void aboutToBeDeleted()
UInt32 myForceTypeColumn
Definition: environmentalStateComponent.h:149
boost::signals2::scoped_connection myVrfStateComponentChangedConnection
Definition: environmentalStateComponent.h:415
virtual const DtFrameStateInterface * nextFrameState() const override
Definition: environmentalStateComponent.h:360
const DtEnvironmentalStateComponentData & frameState() const
Current frame state only can access current frame buffers. This ensures thread safety.
Definition: environmentalStateComponent.h:269
class DtRwIntelCollectionArea:
Definition: rwIntelCollectionArea.h:22
#define UNDEFINED_RETURNREF_ACCESSOR_MUTATOR(Type, Member, Set)
Definition: doubleBufferedDataStorage.h:57
UInt32 myObjectTypeColumn
Definition: environmentalStateComponent.h:152
#define DEFINE_ACCESSOR_MUTATOR(ReturnType, Accessor, Mutator)
Definition: doubleBufferedDataStorage.h:23
int myForceId
Definition: environmentalStateComponent.h:343
double myPhysicalLineWidth
Definition: environmentalStateComponent.h:89
virtual const DtEntityType entityType() const override
Definition: environmentalStateComponent.h:195
DtEntityIdentifier myEntityId
Definition: environmentalStateComponent.h:94
virtual const DtEntityType entityType() const override
Definition: environmentalStateComponent.h:277
LOM::WriteEnvironmentProcessRepository myWriteEnvironmentProcessRepository
Definition: environmentalStateComponent.h:256
virtual void removeRecord(Legion::WriteStateInstance)
Removes a record from this environmental (this must be an instance handle)
Definition: environmentalStateComponent.h:141
#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:96
virtual void updateStateData(DtStateData *sd) override
Implement to update data storage to the new state data.
Definition: environmentalStateComponent.h:383
DtUUID myUUID
Definition: environmentalStateComponent.h:95
DtString myGlobalId
Definition: environmentalStateComponent.h:92
UInt32 myEntityIdColumn
Definition: environmentalStateComponent.h:150
This is a simple base class that will be used to return a pointer to current or next frame state...
Definition: stateComponent.h:294
DtEnvironmentalStateComponentData myData
Definition: environmentalStateComponent.h:258
virtual const DtFrameStateInterface * currentFrameState() const override
Definition: environmentalStateComponent.h:358
unsigned long long myUserData
Definition: environmentalStateComponent.h:91
virtual void addRecord(Legion::WriteStateInstance)
Adds a new record to this environmental (this must be an instance handle)
Definition: environmentalStateComponent.h:138
boost::signals2::scoped_connection myVrfStateComponentChangedConnection
Definition: environmentalStateComponent.h:335
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:103

Document ID: Generated on Thu Oct 23 22:29:17 EDT 2025 from SVN revision 280951
Copyright © 2005-2024 MAK Technologies. All Rights Reserved (www.mak.com)