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

Document ID: Generated on Sun Dec 4 20:22:03 EST 2022 from SVN revision 249613
Copyright © 2005-2021 MAK Technologies. All Rights Reserved (www.mak.com)