VR-Forces Developer's Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
stateDataWrapper.h
Go to the documentation of this file.
1 /****************************************************************************
2  * Copyright (c) 2021 MAK Technologies, Inc.
3  * All rights reserved.
4  ****************************************************************************/
5 
6 #pragma once
7 
15 #include <boost/signals2.hpp>
16 #include <matrix/vlVector.h>
17 #include <geometry/extent.h>
18 #include <vrfutil/rwUUID.h>
19 #include <vlpi/appearance.h>
20 #include <vlpi/disEnums.h>
21 #include <matrix/vlDcm.h>
22 #include <matrix/vlTaitBryan.h>
23 #include <map>
24 #include <list>
25 #include <tbb/spin_rw_mutex.h>
26 
27 class DtRwProperties;
28 
29 namespace makVrf
30 {
31  class DtIffStateComponent;
32  class DtLaserDesignatorStateComponent;
33  class DtExternalCurrentFrameState;
34  class DtStatePropertiesStateComponent;
35  class DtStateData;
36  class DtStateDataManager;
37  class DtVrfObjectGeometry;
38  class DtRwVrfKinematicState;
39 
50  {
51  private:
54 
55  public:
59  explicit DtStateDataWrapper(const DtStateDataManager* simManager, const DtUUID& uuid);
60  explicit DtStateDataWrapper(const DtStateDataManager* simManager, const DtEntityIdentifier& id);
61  explicit DtStateDataWrapper(const DtStateDataManager* simManager, const DtExternalCurrentFrameState*);
62  explicit DtStateDataWrapper(const DtStateData* sd);
63 
65  virtual ~DtStateDataWrapper();
66 
67  DtStateDataWrapper& operator=(const DtUUID&);
69 
70  bool operator==(const DtUUID& rhs) const;
71  bool operator==(const DtStateDataWrapper& rhs) const { return (*this == rhs.uuid()); };
72 
73  bool operator!=(const DtUUID& rhs) const { return !(*this == rhs); };
74  bool operator!=(const DtStateDataWrapper& rhs) const { return !(*this == rhs); };
75 
77  const DtUUID& uuid() const;
78  const DtString& objectName() const;
79  DtString label() const;
80  DtEntityType entityType() const;
81  DtEntityType objectType() const { return entityType(); };
82  unsigned long long userData() const;
83  const DtString& extendedData(const DtString& key) const;
84  std::map<DtString, DtString> extendedDataMap() const;
85  std::map<std::string, std::string> extendedDataStdStringMap() const;
86  bool hasExtendedData(const DtString& key) const;
87  DtString overlay() const;
88  DtAppearance appearance() const;
89  int capabilities() const;
90  DtEntityType guise() const;
91  const DtRwProperties& stateProperties() const;
92 
94  bool isClutterEntity() const;
95 
97  DtVrfObjectGeometry objectGeometry() const;
98  virtual Dt3dBoundingVolume boundingVolume() const;
99 
101  const DtIffStateComponent* iffStateComponent() const;
102  std::vector<const DtLaserDesignatorStateComponent*> laserDesignatorStateComponents() const;
103 
106  {
107  return myAwaiting;
108  }
109 
110  bool isSpotReport() const;
111  bool isTDLReport() const;
112 
114  bool awaitingTransfer() const;
115 
116  bool isModified() const
117  {
118  if (myExternalCurrentFrameState)
119  {
120  return static_cast<const DtExternalCurrentFrameState*>(myExternalCurrentFrameState)->isModified();
121  }
122 
123  return false;
124  }
125 
127  template <typename T_Component>
128  const T_Component* getStateComponent() const
129  {
130  if (myExternalCurrentFrameState)
131  {
132  return myExternalCurrentFrameState->getStateComponent<T_Component>();
133  }
134 
135  return nullptr;
136  }
137 
138  template <typename T_Component>
139  std::vector<const T_Component*> getStateComponentList() const
140  {
141  if (myExternalCurrentFrameState)
142  {
143  return myExternalCurrentFrameState->getStateComponentList<T_Component>();
144  }
145 
146  return std::vector<const T_Component*>();
147  }
148 
149  template <typename T_Component>
150  bool hasStateComponent() const
151  {
152  if (myExternalCurrentFrameState)
153  {
154  return myExternalCurrentFrameState->hasStateComponent<T_Component>();
155  }
156 
157  return false;
158  }
160 
163  DtRwVrfKinematicState kinematicState() const;
164 
167  const DtVector& worldPosition() const;
168  const DtVector& localPosition() const;
169  const DtVector& parentPosition() const;
170  double distSquaredTo(const DtVector&) const;
171 
173  bool hasLocationChanged() const;
174 
177  bool objectVerticesChanged() const;
178 
181  bool worldVerticesChanged() const;
182 
184  bool haveVerticesChanged() const;
185 
186  virtual void frameAdvanced();
187  virtual void firstFrameAdvance();
188 
189  const DtStateData* stateData() const
190  {
191  return myStateData;
192  }
193 
194  DtUUID hostGlobalId() const;
195  DtString parentGlobalId() const;
196 
198  const DtTaitBryan& topographicOrientation() const;
199  const DtTaitBryan& worldOrientation() const;
200  const DtTaitBryan& localOrientation() const;
201  const DtTaitBryan& parentOrientation() const;
202  const DtTaitBryan& localOrientationWrtDatabase() const;
203  const DtDcm& localOrientationMatrix() const;
204  const DtDcm& parentOrientationMatrix() const;
205  const DtDcm& worldOrientationMatrix() const;
206  double heading() const;
207  double pitch() const;
208  double roll() const;
210 
212  DtForceType forceType() const;
213 
215  const DtEntityIdentifier& entityId() const;
216  const DtEntityIdentifier& objectIdentifier() const
217  {
218  return entityId();
219  }
220 
221  DtSimulationAddress simEngineAddress() const;
222 
224  bool isDestroyed() const;
225  int damageState() const;
226 
227  const DtString& globalId() const;
228 
232  bool isUnit() const;
234 
236  bool isEntityOrUnit() const;
237  bool isSimulatedObject() const { return isEntityOrUnit(); };
238 
240  bool isEntity() const;
241 
244  bool isEmbarked() const;
245 
247  DtUUID embarkedOn() const;
248  bool isEmbarkedOn(const DtUUID&) const;
250 
253  bool isValid() const;
254 
255  int sessionId() const;
256  bool isVrfSimulatedObject() const;
257  bool isCurrentlyTasked() const;
258  bool isExecutingPlan() const;
259  bool hasPlan() const;
260  bool independentlyTasked() const;
261  bool underFire() const;
262  DtString rulesOfEngagement() const;
263 
264  DtEchelonId echelonId() const;
265 
267  bool isDeleted() const;
268 
270  virtual void makeInvalid();
271 
272  const DtLocalVertexList& localVertices() const;
273  std::vector<DtVector> localVertexList() const;
274 
275  const DtVertexList& worldVertices() const;
276  std::vector<DtVector> worldVertexList() const;
277 
278  const DtLocalVertexList& relativeVertices() const;
279  std::vector<DtVector> relativeVertexList() const;
280 
282  unsigned long long legionGlobalId() const;
283 
285  bool advancedFrame() const
286  {
287  return myAdvancedFrame;
288  }
289 
290  DtUUID superiorUUID() const;
291 
293  bool isTopLevel() const;
294 
296  {
297  return myExternalCurrentFrameState;
298  }
299 
300  public:
303  boost::signals2::signal<void ()> signal_objectVerticesChanged;
304 
306  mutable boost::signals2::signal<void ()> signal_extendedDataUpdated;
307 
308  mutable boost::signals2::signal<void ()> signal_simObjectDeleted;
309 
311  mutable boost::signals2::signal<void (const DtString&)> signal_discoveredReference;
312 
314  mutable boost::signals2::signal<void (const DtUUID& oldUUID, const DtUUID& newUUID)> signal_uuidChanged;
315 
317  mutable boost::signals2::signal<void (const DtSimulationAddress& oldAddr, const DtSimulationAddress& newAddr)> signal_simEngineAddressChanged;
318 
320  mutable boost::signals2::signal<void (const DtString& oldName, const DtString& newName)> signal_objectRenamed;
321 
323  mutable boost::signals2::signal<void (const DtUUID& oldSuperior, const DtUUID& newSuperior)> signal_superiorChanged;
324 
326  mutable boost::signals2::signal<void()> signal_isClutterChanged;
327 
328  mutable boost::signals2::signal<void (DtStateComponent*)> signal_stateComponentAdded;
329  mutable boost::signals2::signal<void (DtStateComponent*)> signal_stateComponentRemoved;
330 
335  mutable boost::signals2::signal<void ()> signal_advancedFrame;
336 
338  boost::signals2::signal<void ()> signal_firstFrameAdvance;
339 
340  public:
342  {
343  if (myCurrentFrameSimulatedObjectStateComponent)
344  {
345  return myCurrentFrameSimulatedObjectStateComponent;
346  }
347  else if (!myCachedComponents && hasStateComponent<DtSimulatedObjectStateComponent>())
348  {
349  return getStateComponent<DtSimulatedObjectStateComponent>();
350  }
351  else
352  {
353  return nullptr;
354  }
355  }
356 
358  {
359  if (myCurrentFrameLocationStateComponent)
360  {
361  return myCurrentFrameLocationStateComponent;
362  }
363  else if (!myCachedComponents && hasStateComponent<DtLocationStateComponent>())
364  {
365  return getStateComponent<DtLocationStateComponent>();
366  }
367  else
368  {
369  return nullptr;
370  }
371  }
372 
374  {
375  if (myCurrentFrameStatePropertiesStateComponent)
376  {
377  return myCurrentFrameStatePropertiesStateComponent;
378  }
379  else if (!myCachedComponents && hasStateComponent<DtStatePropertiesStateComponent>())
380  {
381  return getStateComponent<DtStatePropertiesStateComponent>();
382  }
383  else
384  {
385  return nullptr;
386  }
387  }
388 
390  {
391  if (myCurrentFrameVrfGeometryStateComponent)
392  {
393  return myCurrentFrameVrfGeometryStateComponent;
394  }
395  else if (!myCachedComponents && hasStateComponent<DtVrfGeometryStateComponent>())
396  {
397  return getStateComponent<DtVrfGeometryStateComponent>();
398  }
399  else
400  {
401  return nullptr;
402  }
403  }
404 
406  {
407  return myCurrentFrameEntityStateComponent;
408  }
409 
411  {
412  if (myCurrentFrameVrfStateComponent)
413  {
414  return myCurrentFrameVrfStateComponent;
415  }
416  else if (!myCachedComponents && hasStateComponent<DtVrfStateComponent>())
417  {
418  return getStateComponent<DtVrfStateComponent>();
419  }
420  else
421  {
422  return nullptr;
423  }
424  }
425 
426  std::set<int> currentFrameModifiedStateComponentTypes() const;
427  std::set<int> nextFrameModifiedStateComponentTypes() const;
428 
429  protected:
430  virtual const DtStateData* stateDataFor(const DtUUID& uuid) const;
431  virtual void cacheComponents();
432  virtual void clearCachedComponents();
433 
434  virtual void stateDataAdded(DtStateData*);
435  virtual void setUUID(const DtUUID&);
436  bool checkAndConnectForVrfStateComponent();
437 
438  void uuidChanged(const DtUUID&, const DtUUID&);
439  virtual void objectNameChanged(const DtString& oldText, const DtString& newText);
440 
441  virtual void completeSetup();
442  virtual void extendedDataUpdated();
443  virtual void superiorChanged();
444  virtual void isClutterChanged();
445 
447  virtual void externalFrameStateToBeDestroyed();
448  virtual void slot_stateComponentAdded(DtStateComponent*);
449  virtual void slot_stateComponentRemoved(DtStateComponent*);
450  virtual void simEngineAddressChanged(const DtSimulationAddress& oldAddress, const DtSimulationAddress& newAddress);
451 
452  protected:
454 
455  boost::signals2::scoped_connection myStateComponentAddedConnection;
456  boost::signals2::scoped_connection myStateComponentRemovedConnection;
457  boost::signals2::scoped_connection myDeletedConnection;
458  boost::signals2::scoped_connection myAddedConnection;
459  boost::signals2::scoped_connection myUUIDChangedConnection;
460  boost::signals2::scoped_connection myObjectNameChangedConnection;
461  boost::signals2::scoped_connection myExtendedDataUpdatedConnection;
462  boost::signals2::scoped_connection myFirstFrameAdvancedConnection;
463  boost::signals2::scoped_connection mySuperiorChangedConnection;
464  boost::signals2::scoped_connection myAdvancedFrameConnection;
465  boost::signals2::scoped_connection myIsClutterChangedConnection;
466  boost::signals2::scoped_connection mySimEngineAddressChangedConnection;
467 
471 
474  unsigned long long myLegionGlobalId;
475 
477 
480  mutable DtEntityType myEntityType;
481 
484 
485  mutable tbb::spin_rw_mutex myExternalCurrentFrameStateMutex;
486 
488 
495 
497 
498  const DtStateData* myStateData = nullptr;
499 
500  protected:
502  };
503 }
const DtSimulatedObjectStateComponent * currentFrameSimulatedObjectStateComponent() const
Definition: stateDataWrapper.h:341
UUID is a unique ID wrapper class.
Definition: uuid.h:59
boost::signals2::scoped_connection mySuperiorChangedConnection
Definition: stateDataWrapper.h:463
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: statePropertiesStateComponent.h:93
DtUUID myEmbarkedOn
Definition: stateDataWrapper.h:487
boost::signals2::scoped_connection myExtendedDataUpdatedConnection
Definition: stateDataWrapper.h:461
DtUUID mySuperiorUUID
Definition: stateDataWrapper.h:482
const DtUUID & uuid() const
@ Convenience accessors for various pieces of state Data
DtStateDataWrapper & operator=(const DtStateDataWrapper &rhs)
Definition: stateDataWrapper.h:68
The DtLocationStateComponent interface contains the interface that all DtLocationStateComponents can ...
Definition: locationStateComponent.h:25
bool operator!=(const DtUUID &rhs) const
Definition: stateDataWrapper.h:73
1) Define the interface class that will be used to represent the next and current frames...
Definition: entityStateComponent.h:91
const DtStatePropertiesStateComponent * myCurrentFrameStatePropertiesStateComponent
Definition: stateDataWrapper.h:494
DtUUID myUUID
Once assigned, the UUID of this object. This will be valid even after the object is deleted...
Definition: stateDataWrapper.h:473
The DtSimulatedObjectStateComponent is an interface that all main components (those that are consider...
Definition: simulatedObjectStateComponent.h:21
DT_DLL_VRFGUICORE bool operator==(const std::vector< makArchives::DtEnvironmentRecord::DtElevationalConfigurationRecord > &lhs, const std::vector< makArchives::DtEnvironmentRecord::DtElevationalConfigurationRecord > &rhs)
boost::signals2::scoped_connection myAddedConnection
Definition: stateDataWrapper.h:458
bool isSimulatedObject() const
Definition: stateDataWrapper.h:237
const DtLocationStateComponent * myCurrentFrameLocationStateComponent
Definition: stateDataWrapper.h:492
const DtLocationStateComponent * currentFrameLocationStateComponent() const
Definition: stateDataWrapper.h:357
boost::signals2::signal< void()> signal_extendedDataUpdated
Signal sent out (during advance frame) when the extended data has been updated.
Definition: stateDataWrapper.h:306
Contains the DtUUID class declaration.
boost::signals2::scoped_connection myObjectNameChangedConnection
Definition: stateDataWrapper.h:460
const T_Component * getStateComponent() const
General call to get any component that does not have a method.
Definition: stateDataWrapper.h:128
const DtExternalFrameStateInterface * externalCurrentFrameState() const
Definition: stateDataWrapper.h:295
const DtVrfStateComponent * currentFrameVrfStateComponent() const
Definition: stateDataWrapper.h:410
boost::signals2::signal< void()> signal_firstFrameAdvance
Signal when the frame is advanced for the first time.
Definition: stateDataWrapper.h:338
boost::signals2::signal< void(DtStateComponent *)> signal_stateComponentRemoved
Definition: stateDataWrapper.h:329
const DtSimulatedObjectStateComponent * myCurrentFrameSimulatedObjectStateComponent
Definition: stateDataWrapper.h:489
bool operator!=(const DtStateDataWrapper &rhs) const
Definition: stateDataWrapper.h:74
boost::signals2::signal< void()> signal_isClutterChanged
Signal sent out (during advance frame) when the is-clutter flag has been updated. ...
Definition: stateDataWrapper.h:326
boost::signals2::scoped_connection myStateComponentRemovedConnection
Definition: stateDataWrapper.h:456
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: vrfGeometryStateComponent.h:54
const DtEntityIdentifier & objectIdentifier() const
Definition: stateDataWrapper.h:216
bool advancedFrame() const
Will be true if this object has advanced at least one frame.
Definition: stateDataWrapper.h:285
boost::signals2::signal< void(DtStateComponent *)> signal_stateComponentAdded
Definition: stateDataWrapper.h:328
boost::signals2::signal< void()> signal_objectVerticesChanged
Signal sent when the user changes the vertices via a set command. If this is a remote object...
Definition: stateDataWrapper.h:303
boost::signals2::signal< void(const DtString &)> signal_discoveredReference
Signal sent if this was awaiting for the base data to show up, and, it has.
Definition: stateDataWrapper.h:311
boost::signals2::scoped_connection myIsClutterChangedConnection
Definition: stateDataWrapper.h:465
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: vrfStateComponent.h:62
const DtStateDataManager * myStateDataManager
Definition: stateDataWrapper.h:501
boost::signals2::scoped_connection myAdvancedFrameConnection
Definition: stateDataWrapper.h:464
boost::signals2::signal< void(const DtSimulationAddress &oldAddr, const DtSimulationAddress &newAddr)> signal_simEngineAddressChanged
Signal sent when the backend hosting this object has changed. Sent during a frame advance...
Definition: stateDataWrapper.h:317
The overall structure of the DtStateData mechanism is: The DtStateData contains a list of double buff...
Definition: stateData.h:398
boost::signals2::scoped_connection myDeletedConnection
Definition: stateDataWrapper.h:457
DtString awaiting() const
If awaiting, who awaiting for.
Definition: stateDataWrapper.h:105
bool hasStateComponent() const
Definition: stateDataWrapper.h:150
const DtStateData * stateData() const
Overall kinematic state.
Definition: stateDataWrapper.h:189
class DtVertexList:
Definition: vertexList.h:22
DtEntityType myEntityType
Definition: stateDataWrapper.h:480
boost::signals2::signal< void()> signal_simObjectDeleted
Definition: stateDataWrapper.h:308
bool isModified() const
Definition: stateDataWrapper.h:116
const DtEntityStateComponent * myCurrentFrameEntityStateComponent
Definition: stateDataWrapper.h:491
Definition: stateData.h:301
This class maintains a rectangular bounding volume and an ordered list of vertices describing the phy...
Definition: vrfObjectGeometry.h:39
boost::signals2::scoped_connection myUUIDChangedConnection
Definition: stateDataWrapper.h:459
Definition: echelonId.h:13
bool operator==(const DtStateDataWrapper &rhs) const
Definition: stateDataWrapper.h:71
const DtVrfGeometryStateComponent * currentFrameVrfGeometryStateComponent() const
Definition: stateDataWrapper.h:389
Definition: stateComponent.h:52
boost::signals2::signal< void(const DtString &oldName, const DtString &newName)> signal_objectRenamed
Signal sent when the uuid of this object has changed. Sent during a frame advance.
Definition: stateDataWrapper.h:320
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: stateDataWrapper.h:49
const DtEntityStateComponent * currentFrameEntityStateComponent() const
Definition: stateDataWrapper.h:405
DtEntityType objectType() const
Definition: stateDataWrapper.h:81
DtString myObjectName
This is for debug purposes only. It will get set when the bounding volume is checked (and locked) and...
Definition: stateDataWrapper.h:479
unsigned long long myLegionGlobalId
Definition: stateDataWrapper.h:474
boost::signals2::scoped_connection myFirstFrameAdvancedConnection
Definition: stateDataWrapper.h:462
boost::signals2::scoped_connection mySimEngineAddressChangedConnection
Definition: stateDataWrapper.h:466
bool myAdvancedFrame
Definition: stateDataWrapper.h:483
Contains the declaration of the DtExtent class.
boost::signals2::signal< void(const DtUUID &oldSuperior, const DtUUID &newSuperior)> signal_superiorChanged
Signal sent when superior has changed.
Definition: stateDataWrapper.h:323
const DtVrfStateComponent * myCurrentFrameVrfStateComponent
Definition: stateDataWrapper.h:490
boost::signals2::scoped_connection myStateComponentAddedConnection
Definition: stateDataWrapper.h:455
const DtExternalFrameStateInterface * myExternalCurrentFrameState
Definition: stateDataWrapper.h:453
Definition: stateData.h:73
Definition: rwVrfKinematicState.h:26
#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
A list of properties. A DtPropertyInterface object that is a specialized version of DtRwVariableBindi...
Definition: rwProperties.h:122
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: iffStateComponent.h:83
bool myCachedComponents
Definition: stateDataWrapper.h:496
bool myIsDeleted
Definition: stateDataWrapper.h:476
const DtVrfGeometryStateComponent * myCurrentFrameVrfGeometryStateComponent
Definition: stateDataWrapper.h:493
class DtLocalVertexList:
Definition: localVertexList.h:20
boost::signals2::signal< void()> signal_advancedFrame
Signal sent when the state data signals that the frame has been advanced WARNING: This signal will be...
Definition: stateDataWrapper.h:335
tbb::spin_rw_mutex myExternalCurrentFrameStateMutex
Definition: stateDataWrapper.h:485
std::vector< const T_Component * > getStateComponentList() const
Definition: stateDataWrapper.h:139
DtString myAwaiting
If this object is awaiting for its reference to show up, this will be either a UUID or an entity id s...
Definition: stateDataWrapper.h:470
boost::signals2::signal< void(const DtUUID &oldUUID, const DtUUID &newUUID)> signal_uuidChanged
Signal sent when the uuid of this object has changed. Sent during a frame advance.
Definition: stateDataWrapper.h:314
const DtStatePropertiesStateComponent * currentFrameStatePropertiesStateComponent() const
Definition: stateDataWrapper.h:373
This class holds the state data that represents each simulation object in the system.
Definition: stateDataManager.h:73

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)