VR-Forces Developer's Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
entityStateComponent.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 <vlpi/disEnums.h>
11 #include <legionStandardOM/sets/writeEntityRepository.hpp>
12 #include "legionStandardOM/sets/readEntityRepository.hpp"
13 #include "legionDataStore/view.h"
14 #include <tbb/spin_mutex.h>
15 
16 namespace LOM
17 {
18  class ReadEntityRepository;
19 }
20 
21 class DtAppearance;
22 
23 namespace makVrf
24 {
26  {
27  typedef unsigned long long SimStateID;
28 
30  : myUUID(DtUUID::nullUUID())
31  , myIsLocal(false)
32  , myCheckForNameReservation(true)
33  {};
34 
36  : myGlobalId(orig.myGlobalId)
37  , myUUID(orig.myUUID)
38  , myMarkingText(orig.myMarkingText)
39  , myCallsign(orig.myCallsign)
40  , myEntityId(orig.myEntityId)
41  , myIsLocal(orig.myIsLocal)
42  , myCheckForNameReservation(orig.myCheckForNameReservation)
43  {
44  }
45 
47  {
48  myGlobalId = rhs.myGlobalId;
49  myUUID = rhs.myUUID;
50  myEntityId = rhs.myEntityId;
51  myMarkingText = rhs.myMarkingText;
52  myCallsign = rhs.myCallsign;
53  myIsLocal = rhs.myIsLocal;
54  myCheckForNameReservation = rhs.myCheckForNameReservation;
55 
56  return *this;
57  }
58 
59  DEFINE_ACCESSOR_MUTATOR(DtString, globalId, GlobalId)
60  DEFINE_ACCESSOR_MUTATOR(DtEntityIdentifier, entityId, EntityId)
61  DEFINE_ACCESSOR_MUTATOR(DtUUID, uuid, UUID)
62  DEFINE_ACCESSOR_MUTATOR(DtString, markingText, MarkingText)
63  DEFINE_ACCESSOR_MUTATOR(DtString, callsign, Callsign)
64  DEFINE_ACCESSOR_MUTATOR(bool, isLocal, IsLocal)
65  DEFINE_ACCESSOR_MUTATOR(bool, checkForNameReservation, CheckForNameReservation)
66 
67  protected:
68  DtString myGlobalId;
69  DtString myMarkingText;
70  DtString myCallsign;
71  DtEntityIdentifier myEntityId;
72  DtUUID myUUID;
73  bool myIsLocal;
74  bool myCheckForNameReservation;
75  };
76 
80  {
81  public:
83 
85  : DtSimulatedObjectStateComponent(storage)
86  , myUUIDColumn(0xFFFFFFFF)
87  , myIsClutterEntityColumn(0xFFFFFFFF)
88  {
89  }
90 
91  UNDEFINED_RETURNVALUE_ACCESSOR_MUTATOR(bool, isClutterEntity, IsClutterEntity)
92  UNDEFINED_RETURNVALUE_ACCESSOR_MUTATOR(UInt32, capabilities, Capabilities)
93  UNDEFINED_RETURNVALUE_ACCESSOR_MUTATOR(DtEntityType, guise, Guise)
94  UNDEFINED_RETURNREF_ACCESSOR_MUTATOR(DtUUID, superior, Superior)
96 
97  virtual const std::set<DtUUID> attachments() const { throw DtUnimplementedMethod("std::set<DtUUID> attachments() is not implemented for this class."); };
98  virtual void setEntityType(const DtObjectType& ot) { throw DtUnimplementedMethod("void setEntityType(const DtObjectType& ot) is not implemented for this class."); };
99  virtual void addAttachment(const DtUUID&) { throw DtUnimplementedMethod("void addAttachment(const DtUUID&) is not implemented for this class."); };
100  virtual void removeAttachment(const DtUUID&) { throw DtUnimplementedMethod("void removeAttachment(const DtUUID&) is not implemented for this class."); };
101 
102  mutable boost::signals2::signal<void (int oldState, int newState, makVrf::SimStateID)> signal_damageStateChanged;
103  mutable boost::signals2::signal<void (const DtFrameStateInterface*)> signal_attachmentsChanged;
104  mutable boost::signals2::signal<void(const DtUUID& oldSuperior, const DtUUID& newSuperior)> signal_superiorChanged;
105  mutable boost::signals2::signal<void(bool oldIsClutter, bool newIsClutter)> signal_isClutterChanged;
106  mutable boost::signals2::signal<void(const DtString&, const DtString&, makVrf::SimStateID)> signal_callsignChanged;
107 
108  protected:
111  };
112 
114  template <typename T_BaseComponent>
116  {
117  public:
120 
122  const DtEntityStateComponentData& frameState() const { return this->myData; };
123  DtEntityStateComponentData& frameState() { return this->myData; };
124 
125  const bool& isLocal() const;
126  void setIsLocal(const bool&);
127 
128  const bool& checkForNameReservation() const;
129  void setCheckForNameReservation(const bool&);
130 
131  const DtString& globalId() const;
132  void setGlobalId(const DtString&);
133 
134  const DtUUID& uuid() const;
135  void setUUID(const DtUUID&);
136 
137  const bool isClutterEntity() const;
138  void setIsClutterEntity(const bool&);
139 
140  const DtString& markingText() const;
141  void setMarkingText(const DtString&);
142 
143  const DtString& callsign() const;
144  void setCallsign(const DtString&);
145 
146  const DtForceType forceType() const;
147  void setForceType(const DtForceType&);
148 
149  const UInt32 appearanceBits() const;
150  void setAppearanceBits(const UInt32&);
151 
152  const DtEntityType entityType() const { return DtEntityType(objectType()); };
153  const DtObjectType objectType() const;
154  void setEntityType(const DtObjectType&);
155  void setEntityType(const DtEntityType& t) { setEntityType(DtObjectType(t.kind() == 11 ? 3 : 1, t)); };
156 
157  const DtEntityIdentifier& entityId() const;
158  void setEntityId(const DtEntityIdentifier&);
159 
160  const UInt32 capabilities() const;
161  void setCapabilities(const UInt32&);
162 
163  const DtEntityType guise() const;
164  void setGuise(const DtEntityType&);
165 
167  const DtUUID& superior() const;
168  void setSuperior(const DtUUID&);
169 
170  virtual void setAppearance(const DtAppearance& app);
171 
173  virtual void makeWritable();
174 
176  virtual void makeReadOnly();
177 
178  protected:
179  LOM::WriteEntityRepository myWriteEntityStateRepository;
183  };
184 
186 
188  template <typename T_BaseComponent>
190  {
191  public:
194 
196  const DtEntityStateComponentData& frameState() const { return this->myData; };
197 
198  const bool& isLocal() const;
199  const bool& checkForNameReservation() const;
200  const DtString& globalId() const;
201  const DtUUID& uuid() const;
202  const DtString& markingText() const;
203  const DtString& callsign() const;
204  const DtForceType forceType() const;
205  const DtEntityType entityType() const { return DtEntityType(objectType()); };
206  const DtObjectType objectType() const;
207  const DtEntityIdentifier& entityId() const;
208  const UInt32 appearanceBits() const;
209  const bool isClutterEntity() const;
210  const UInt32 capabilities() const;
211  const DtEntityType guise() const;
212 
213  const DtUUID& superior() const;
214 
218  void addAttachment(const DtUUID&);
219  void removeAttachment(const DtUUID&);
220  const std::set<DtUUID> attachments() const;
222 
223  bool checkForUpdatedItems();
224 
225  protected:
226  const DtUUID _uuid() const;
227  const DtString _markingText() const;
228  const DtEntityIdentifier _entityId() const;
229 
230  bool checkEntityIdChanged();
231  bool checkUUIDChanged();
232  bool checkForceChanged();
233  bool checkMarkingTextChanged();
234  bool checkDamageStateChanged();
235  bool checkIsClutterChanged();
236 
237  void handleDataUpdated(const std::vector<UInt32>& attributesUpdated);
238  void completeSetup();
239 
242  {
243  this->myData = data;
244  }
245 
246  protected:
247  friend class DtStateDataManager;
248  void setSuperior(const DtUUID&);
249 
250  protected:
251  LOM::ReadEntityRepository myReadEntityStateRepository;
256  unsigned int myCallbackHandle;
258 
259  std::set<DtUUID> myAttachments;
260  mutable tbb::spin_rw_mutex myAttachmentsMutex;
261  boost::signals2::scoped_connection myCompleteSetupConnection;
262  tbb::spin_mutex myCompleteSetupMutex;
264  };
265 
267 
271  {
272  public:
275 
276  bool isDoubleBuffered() { return true; };
277  const DtFrameStateInterface* currentFrameState() const { return &myCurrentFrameState; }
278  virtual DtFrameStateInterface* nextFrameState() { return &myNextFrameState; };
279  virtual const DtFrameStateInterface* nextFrameState() const { return &myNextFrameState; };
280 
281  void updateDataStorage();
282 
284  {
285  myCurrentFrameState.updateStateData(sd);
286  myNextFrameState.updateStateData(sd);
287  }
288 
289  static void addAdditionalTableColumns(Legion::SimulationDatabase*);
290 
291  virtual void initializeFromParameters(const DtVrfObjectParameters* params);
292 
293  Legion::WriteStateInstance writeStateInstance() override { return myWriteEntityStateRepository; };
294 
296  virtual void convertToRemote();
297 
299  virtual void convertToLocal();
300 
301  virtual void addAdditionalStateComponents() override;
302 
303  virtual void aboutToBeDeleted() override
304  {
306  myCurrentFrameState.aboutToBeDeleted();
307  myNextFrameState.aboutToBeDeleted();
308  }
309 
310  protected:
313  LOM::WriteEntityRepository myWriteEntityStateRepository;
314  };
315 
319 }
320 
321 #define _ENTITY_STATE_COMPONENT 1
322 #include "vrfStateData/entityStateComponent.inl"
2) Define the next frame class. This will be used for write access.
Definition: entityStateComponent.h:115
UUID is a unique ID wrapper class.
Definition: uuid.h:59
boost::signals2::signal< void(const DtFrameStateInterface *)> signal_attachmentsChanged
Definition: entityStateComponent.h:103
unsigned int myCallbackHandle
Definition: entityStateComponent.h:256
Instances of DtVrfObjectParameters are the readable/writeable objects that contain the information ne...
Definition: vrfObjectParameters.h:63
unsigned int UInt32
Definition: stateDataTypes.h:18
LOM::WriteEntityRepository myWriteEntityStateRepository
Definition: entityStateComponent.h:179
const DtEntityType entityType() const
Definition: entityStateComponent.h:205
const DtEntityStateComponentData & frameState() const
Next frame access write access. Ensure this is only used in a single thread (i.e.a controller thread)...
Definition: entityStateComponent.h:122
Definition: stateDataTypes.h:23
DtString myMarkingText
Definition: entityStateComponent.h:69
tbb::spin_mutex myCompleteSetupMutex
Definition: entityStateComponent.h:262
DtEntityStateComponentCurrentFrameTemplate< DtEntityStateComponent > DtEntityStateComponentCurrentFrame
Definition: entityStateComponent.h:266
bool myCheckForNameReservation
Definition: entityStateComponent.h:74
bool myIsClutterEntity
Definition: entityStateComponent.h:257
int myForceId
Definition: entityStateComponent.h:254
Definition: stateComponent.h:62
virtual void addAttachment(const DtUUID &)
Definition: entityStateComponent.h:99
1) Define the interface class that will be used to represent the next and current frames...
Definition: entityStateComponent.h:79
DtStateData * myStateData
Definition: entityStateComponent.h:252
Definition: stateComponent.h:266
The DtSimulatedObjectStateComponent is an interface that all main components (those that are consider...
Definition: simulatedObjectStateComponent.h:21
UInt32 myIsClutterEntityColumn
Definition: entityStateComponent.h:110
DtEntityStateComponentData(const DtEntityStateComponentData &orig)
Definition: entityStateComponent.h:35
bool isDoubleBuffered()
Definition: entityStateComponent.h:276
boost::signals2::scoped_connection myCompleteSetupConnection
Definition: entityStateComponent.h:261
boost::signals2::signal< void(const DtUUID &oldSuperior, const DtUUID &newSuperior)> signal_superiorChanged
Definition: entityStateComponent.h:104
boost::signals2::signal< void(bool oldIsClutter, bool newIsClutter)> signal_isClutterChanged
Definition: entityStateComponent.h:105
virtual const DtFrameStateInterface * nextFrameState() const
Definition: entityStateComponent.h:279
const DtEntityStateComponentData & frameState() const
Current frame state only can access current frame buffers. This ensures thread safety.
Definition: entityStateComponent.h:196
void updateStateData(DtStateData *sd)
Implement to update data storage to the new state data.
Definition: entityStateComponent.h:283
Definition: entityStateComponent.h:25
void advanceFrame(const DtEntityStateComponentData &data)
Definition: entityStateComponent.h:241
4) Define the state component that will contain the wrappers to the next and current frame states tha...
Definition: entityStateComponent.h:270
std::set< DtUUID > myAttachments
Definition: entityStateComponent.h:259
virtual void aboutToBeDeleted() override
Definition: entityStateComponent.h:303
The overall structure of the DtStateData mechanism is: The DtStateData contains a list of double buff...
Definition: stateData.h:339
DtEntityStateComponentData()
Definition: entityStateComponent.h:29
#define DEFINE_STATE_COMPONENT_TYPE(CreatedComponent)
Definition: stateComponent.h:228
3) Define the current frame class. This will be used for read access.
Definition: entityStateComponent.h:189
DtString myGlobalId
Definition: entityStateComponent.h:68
boost::signals2::signal< void(const DtString &, const DtString &, makVrf::SimStateID)> signal_callsignChanged
Definition: entityStateComponent.h:106
DtEntityStateComponentNextFrame myNextFrameState
Definition: entityStateComponent.h:312
Subclass from this to indicate that this will be a double buffered state component.
Definition: stateComponent.h:379
DtUUID mySuperior
Definition: entityStateComponent.h:253
DtEntityIdentifier myEntityId
Definition: entityStateComponent.h:71
#define UNDEFINED_RETURNVALUE_ACCESSOR_MUTATOR(Type, Member, Set)
Definition: doubleBufferedDataStorage.h:53
virtual void aboutToBeDeleted()
LOM::ReadEntityRepository myReadEntityStateRepository
Definition: entityStateComponent.h:251
UInt32 myUUIDColumn
Definition: entityStateComponent.h:109
#define UNDEFINED_RETURNREF_ACCESSOR_MUTATOR(Type, Member, Set)
Definition: doubleBufferedDataStorage.h:57
LOM::WriteEntityRepository myWriteEntityStateRepository
Definition: entityStateComponent.h:313
#define DEFINE_ACCESSOR_MUTATOR(ReturnType, Accessor, Mutator)
Definition: doubleBufferedDataStorage.h:23
DtEntityStateComponentData myData
Definition: entityStateComponent.h:182
unsigned long long SimStateID
Definition: entityStateComponent.h:27
DtStateComponentCreator< DtEntityStateComponentImplementation > DtEntityStateComponentCreator
5) Define the creator. This will need to be registered with the REGISTER_STATE_COMPONENT macro in the...
Definition: entityStateComponent.h:318
DtEntityStateComponentData myData
Definition: entityStateComponent.h:263
DtEntityStateComponentCurrentFrame myCurrentFrameState
Definition: entityStateComponent.h:311
DtString myCallsign
Definition: entityStateComponent.h:70
DtEntityStateComponentNextFrameTemplate< DtEntityStateComponent > DtEntityStateComponentNextFrame
Definition: entityStateComponent.h:185
Legion::WriteStateInstance writeStateInstance() override
Definition: entityStateComponent.h:293
#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
DtUUID myUUID
Definition: entityStateComponent.h:72
DtEntityStateComponentData & frameState()
Definition: entityStateComponent.h:123
virtual void setEntityType(const DtObjectType &ot)
Definition: entityStateComponent.h:98
void setEntityType(const DtEntityType &t)
Definition: entityStateComponent.h:155
DtStateData * myStateData
Definition: entityStateComponent.h:180
int myDamageState
Definition: entityStateComponent.h:255
DtEntityStateComponentData & operator=(const DtEntityStateComponentData &rhs)
Definition: entityStateComponent.h:46
virtual DtFrameStateInterface * nextFrameState()
Definition: entityStateComponent.h:278
bool myIsLocal
Definition: entityStateComponent.h:73
const DtFrameStateInterface * currentFrameState() const
Definition: entityStateComponent.h:277
DtUUID mySuperior
Definition: entityStateComponent.h:181
This is a simple base class that will be used to return a pointer to current or next frame state...
Definition: stateComponent.h:291
tbb::spin_rw_mutex myAttachmentsMutex
Definition: entityStateComponent.h:260
const DtEntityType entityType() const
Definition: entityStateComponent.h:152
This class holds the state data that represents each simulation object in the system.
Definition: stateDataManager.h:73

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)