VR-Forces Developer's Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
vrfStateComponent.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 
11 #include <vrfutil/rwUUID.h>
12 #include "vrfutil/echelonId.h"
13 #include <vlutil/vlTime.h>
14 #include "legionDataStore/writeStateInstance.h"
15 #include "legionDataStore/readStateInstance.h"
16 #include "legionDataStore/view.h"
17 #include "vrfOM/sets/readVrfStateComponentRepository.hpp"
18 #include "vrfOM/sets/writeVrfStateComponentRepository.hpp"
19 #include <tbb/spin_mutex.h>
20 
21 namespace makVrf
22 {
23  class DtVrfStateComponentDataStore;
24 
25  static tbb::spin_mutex theEchelonIdMutex;
26 
28  {
30  : myIsRemoteAttachedObject(false)
31  {
32  }
33 
35  : myIsRemoteAttachedObject(orig.myIsRemoteAttachedObject)
36  , myEchelonId(orig.myEchelonId)
37  {
38  }
39 
41  {
42  myIsRemoteAttachedObject = rhs.myIsRemoteAttachedObject;
43 
44  {
45  tbb::spin_mutex::scoped_lock lock(theEchelonIdMutex);
46  myEchelonId = rhs.myEchelonId;
47  }
48 
49  return *this;
50  }
51 
52  DEFINE_ACCESSOR_MUTATOR(bool, isRemoteAttachedObject, IsRemoteAttachedObject)
53  DEFINE_ACCESSOR_MUTATOR(DtEchelonId, echelonId, EchelonId)
54 
55  protected:
56  bool myIsRemoteAttachedObject;
57  DtEchelonId myEchelonId;
58  };
59 
63  {
64  public:
65  typedef std::map<DtString, DtString> ExtendedData;
67 
69  : DtFrameStateInterface(storage)
70  {
71  }
72 
73  UNDEFINED_RETURNREF_ACCESSOR_MUTATOR(bool, isRemoteAttachedObject, IsRemoteAttachedObject)
74  UNDEFINED_RETURNVALUE_ACCESSOR_MUTATOR(bool, isVrfSimulatedObject, IsVrfSimulatedObject)
76  UNDEFINED_RETURNVALUE_ACCESSOR_MUTATOR(DtString, overlay, Overlay)
77  UNDEFINED_RETURNVALUE_ACCESSOR_MUTATOR(bool, independentlyTasked, IndependentlyTasked)
78  UNDEFINED_RETURNVALUE_ACCESSOR_MUTATOR(DtString, engagementRules, EngagementRules)
79  UNDEFINED_RETURNVALUE_ACCESSOR_MUTATOR(bool, isSubordinateOfForceLevel, IsSubordinateOfForceLevel)
80  UNDEFINED_RETURNVALUE_ACCESSOR_MUTATOR(bool, isTasked, IsTasked)
81  UNDEFINED_RETURNVALUE_ACCESSOR_MUTATOR(bool, underFire, UnderFire)
82  UNDEFINED_RETURNVALUE_ACCESSOR_MUTATOR(bool, executingPlan, ExecutingPlan)
83  UNDEFINED_RETURNVALUE_ACCESSOR_MUTATOR(bool, hasPlan, HasPlan)
84  UNDEFINED_RETURNVALUE_ACCESSOR_MUTATOR(bool, sensorsKilled, SensorsKilled)
85  UNDEFINED_RETURNVALUE_ACCESSOR_MUTATOR(int, sessionId, SessionId)
86  UNDEFINED_RETURNVALUE_ACCESSOR_MUTATOR(int, vrfMessageVersionSupported, VrfMessageVersionSupported)
87  UNDEFINED_RETURNREF_ACCESSOR_MUTATOR(DtEchelonId, echelonId, EchelonId)
88  UNDEFINED_RETURNREF_ACCESSOR_MUTATOR(ExtendedData, extendedData, ExtendedData)
89  UNDEFINED_CONST_METHOD(bool, activated)
90 
91  virtual void setExtendedData(const DtString& key, const DtString& value) { throw DtUnimplementedMethod("setExtendedData(const DtString& key, const DtString& value) is not implemented for this class"); };
92  virtual const DtString& extendedData(const DtString& key) const { throw DtUnimplementedMethod("extendedData(const DtString& key) is not implemented for this class"); };
93  virtual void clearExtendedData() { throw DtUnimplementedMethod("clearExtendedData() is not implemented for this class"); };
94  virtual void removeExtendedData(const DtString& key) { throw DtUnimplementedMethod("removeExtendedData(const DtString& key) is not implemented for this class"); };
95  virtual ExtendedData extendedDataMap() const { throw DtUnimplementedMethod("extendedDataMap() is not implemented for this class"); };
96  virtual bool hasExtendedData(const DtString&) const { throw DtUnimplementedMethod("hasExtendedData(const DtString&) const is not implemented for this class"); };
97 
99  mutable boost::signals2::signal<void (const DtFrameStateInterface*)> signal_extendedDataModified{};
100  };
101 
104  {
105  public:
107  virtual ~DtVrfStateComponentNextFrame() override;
108 
110  const DtVrfStateComponentData& frameState() const { return myData; };
111  DtVrfStateComponentData& frameState() { return myData; };
112 
113  virtual const bool isVrfSimulatedObject() const override;
114  virtual void setIsVrfSimulatedObject(const bool&) override;
115 
116  virtual const DtString label() const override;
117  virtual void setLabel(const DtString&) override;
118 
119  virtual const DtString overlay() const override;
120  virtual void setOverlay(const DtString&) override;
121 
122  virtual const bool independentlyTasked() const override;
123  virtual void setIndependentlyTasked(const bool&) override;
124 
125  virtual const bool& isRemoteAttachedObject() const override;
126  virtual void setIsRemoteAttachedObject(const bool&) override;
127 
128  virtual const DtString engagementRules() const override;
129  virtual void setEngagementRules(const DtString&) override;
130 
131  virtual const bool isSubordinateOfForceLevel() const override;
132  virtual void setIsSubordinateOfForceLevel(const bool&) override;
133 
134  virtual const bool isTasked() const override;
135  virtual void setIsTasked(const bool&) override;
136 
137  virtual const bool underFire() const override;
138  virtual void setUnderFire(const bool&) override;
139 
140  virtual const bool executingPlan() const override;
141  virtual void setExecutingPlan(const bool&) override;
142 
143  virtual const bool hasPlan() const override;
144  virtual void setHasPlan(const bool&) override;
145 
146  virtual const bool sensorsKilled() const override;
147  virtual void setSensorsKilled(const bool&) override;
148 
149  virtual const DtEchelonId& echelonId() const override;
150  virtual void setEchelonId(const DtEchelonId&) override;
151 
152  virtual const int sessionId() const override;
153  virtual void setSessionId(const int&) override;
154 
155  virtual const int vrfMessageVersionSupported() const override;
156  virtual void setVrfMessageVersionSupported(const int&) override;
157 
158  virtual const ExtendedData& extendedData() const override;
159  virtual void setExtendedData(const ExtendedData&) override;
160  virtual void setExtendedData(const DtString& key, const DtString& value) override;
161  virtual const DtString& extendedData(const DtString& key) const override;
162 
163  virtual void clearExtendedData() override;
164  void updateExtendedData();
165  virtual void removeExtendedData(const DtString& key) override;
166 
167  virtual bool activated() const override;
168 
170  virtual void makeWritable() override;
171 
173  virtual void makeReadOnly() override;
174 
175  bool extendedDataModified() const
176  {
177  return myExtendedDataModified;
178  }
179 
181  {
182  myExtendedDataModified = false;
183  }
184 
185  virtual ExtendedData extendedDataMap() const override;
186  virtual bool hasExtendedData(const DtString&) const override;
187 
188  protected:
189  VRF::WriteVrfStateComponentRepository myWriteVrfStateComponentRepository;
194  };
195 
198  {
199  public:
201  virtual ~DtVrfStateComponentCurrentFrame() override;
202 
204  const DtVrfStateComponentData& frameState() const { return myData; };
205 
206  virtual const bool isVrfSimulatedObject() const override;
207  virtual const DtString label() const override;
208  virtual const DtString overlay() const override;
209  virtual const bool independentlyTasked() const override;
210  virtual const bool& isRemoteAttachedObject() const override;
211  virtual const DtString engagementRules() const override;
212  virtual const bool isSubordinateOfForceLevel() const override;
213  virtual const bool isTasked() const override;
214  virtual const bool underFire() const override;
215  virtual const bool executingPlan() const override;
216  virtual const bool hasPlan() const override;
217  virtual const bool sensorsKilled() const override;
218  virtual const DtEchelonId& echelonId() const override;
219  virtual const int sessionId() const override;
220  virtual const int vrfMessageVersionSupported() const override;
221  virtual const ExtendedData& extendedData() const override;
222  virtual bool activated() const override;
223  bool readComponentValid() const;
224  virtual ExtendedData extendedDataMap() const override;
225  virtual bool hasExtendedData(const DtString&) const override;
226 
227  virtual const DtString& extendedData(const DtString& key) const override;
228 
229  virtual bool findReadComponent();
230  void handleExtendedDataUpdated(const std::vector<UInt32>& attributesUpdated);
231 
232  private:
234  void updateExtendedData(const ExtendedData&);
236  {
237  myData = data;
238  }
239 
240  protected:
241  VRF::ReadVrfStateComponentRepository myReadVrfStateComponentRepository;
243  unsigned int myCallbackHandle;
245  };
246 
250  {
251  public:
253  virtual ~DtVrfStateComponentImplementation() override;
254 
255  bool isDoubleBuffered() { return true; };
256  virtual const DtFrameStateInterface* currentFrameState() const override { return &myCurrentFrameState; }
257  virtual DtFrameStateInterface* nextFrameState() override { return &myNextFrameState; };
258  virtual const DtFrameStateInterface* nextFrameState() const override { return &myNextFrameState; };
259 
260  virtual void updateDataStorage() override;
261 
262  virtual void updateStateData(DtStateData* sd) override
263  {
264  myCurrentFrameState.updateStateData(sd);
265  myNextFrameState.updateStateData(sd);
266  }
267 
269  virtual bool forceAdvance() override;
270 
272  virtual void firstFrameAdvance() override;
273 
275  virtual void addAdditionalStateComponents() override;
276 
277  virtual void initializeFromParameters(const DtVrfObjectParameters* params) override;
278 
279  virtual void aboutToBeDeleted() override
280  {
282  myCurrentFrameState.aboutToBeDeleted();
283  myNextFrameState.aboutToBeDeleted();
284  }
285 
286  protected:
290  };
291 
295 }
Instances of DtVrfObjectParameters are the readable/writeable objects that contain the information ne...
Definition: vrfObjectParameters.h:64
virtual void aboutToBeDeleted() override
Definition: vrfStateComponent.h:279
void clearExtendedDataModified()
Definition: vrfStateComponent.h:180
virtual const DtString & extendedData(const DtString &key) const
Definition: vrfStateComponent.h:92
Definition: stateDataTypes.h:23
DtVrfStateComponentCurrentFrame myCurrentFrameState
Definition: vrfStateComponent.h:287
void advanceFrame(const DtVrfStateComponentData &data)
Definition: vrfStateComponent.h:235
bool extendedDataModified() const
Definition: vrfStateComponent.h:175
ExtendedData myExtendedData
Definition: vrfStateComponent.h:190
DtVrfStateComponentData myData
Definition: vrfStateComponent.h:244
DtVrfStateComponentData()
Definition: vrfStateComponent.h:29
Definition: stateComponent.h:269
2) Define the next frame class. This will be used for write access.
Definition: vrfStateComponent.h:103
3) Define the current frame class. This will be used for read access.
Definition: vrfStateComponent.h:197
static tbb::spin_mutex theEchelonIdMutex
Definition: vrfStateComponent.h:23
Contains the DtUUID class declaration.
DtVrfStateComponentData myData
Definition: vrfStateComponent.h:193
DtVrfStateComponentNextFrame myNextFrameState
Definition: vrfStateComponent.h:288
const DtVrfStateComponentData & frameState() const
Next frame access write access. Ensure this is only used in a single thread (i.e.a controller thread)...
Definition: vrfStateComponent.h:110
virtual bool hasExtendedData(const DtString &) const
Definition: vrfStateComponent.h:96
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 DtVrfStateComponentData & frameState() const
Current frame state only can access current frame buffers. This ensures thread safety.
Definition: vrfStateComponent.h:204
#define UNDEFINED_CONST_METHOD(Type, Method,...)
Definition: doubleBufferedDataStorage.h:65
DtEchelonId myEchelonId
Definition: vrfStateComponent.h:191
The overall structure of the DtStateData mechanism is: The DtStateData contains a list of double buff...
Definition: stateData.h:398
virtual DtFrameStateInterface * nextFrameState() override
Definition: vrfStateComponent.h:257
#define DEFINE_STATE_COMPONENT_TYPE(CreatedComponent)
Definition: stateComponent.h:231
bool myExtendedDataModified
Definition: vrfStateComponent.h:192
DtVrfStateComponentData & operator=(const DtVrfStateComponentData &rhs)
Definition: vrfStateComponent.h:40
virtual const DtFrameStateInterface * nextFrameState() const override
Definition: vrfStateComponent.h:258
virtual const DtFrameStateInterface * currentFrameState() const override
Definition: vrfStateComponent.h:256
virtual ExtendedData extendedDataMap() const
Definition: vrfStateComponent.h:95
Subclass from this to indicate that this will be a double buffered state component.
Definition: stateComponent.h:384
bool myFoundComponent
Definition: vrfStateComponent.h:289
4) Define the state component that will contain the wrappers to the next and current frame states tha...
Definition: vrfStateComponent.h:249
#define UNDEFINED_RETURNVALUE_ACCESSOR_MUTATOR(Type, Member, Set)
Definition: doubleBufferedDataStorage.h:53
virtual void aboutToBeDeleted()
virtual void clearExtendedData()
Definition: vrfStateComponent.h:93
ExtendedData myExtendedData
Definition: vrfStateComponent.h:242
DtEchelonId myEchelonId
Definition: vrfStateComponent.h:57
Definition: echelonId.h:13
VRF::WriteVrfStateComponentRepository myWriteVrfStateComponentRepository
Definition: vrfStateComponent.h:189
#define UNDEFINED_RETURNREF_ACCESSOR_MUTATOR(Type, Member, Set)
Definition: doubleBufferedDataStorage.h:57
virtual void updateStateData(DtStateData *sd) override
Implement to update data storage to the new state data.
Definition: vrfStateComponent.h:262
#define DEFINE_ACCESSOR_MUTATOR(ReturnType, Accessor, Mutator)
Definition: doubleBufferedDataStorage.h:23
Definition: vrfStateComponent.h:27
#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
virtual void removeExtendedData(const DtString &key)
Definition: vrfStateComponent.h:94
DtVrfStateComponentData(const DtVrfStateComponentData &orig)
Definition: vrfStateComponent.h:34
unsigned int myCallbackHandle
Definition: vrfStateComponent.h:243
Contains the DtStateComponent class declaration.
Definition: stateComponent.h:76
DtVrfStateComponentData & frameState()
Definition: vrfStateComponent.h:111
bool myIsRemoteAttachedObject
Definition: vrfStateComponent.h:56
This is a simple base class that will be used to return a pointer to current or next frame state...
Definition: stateComponent.h:294
std::map< DtString, DtString > ExtendedData
Definition: vrfStateComponent.h:65
bool isDoubleBuffered()
Definition: vrfStateComponent.h:255
VRF::ReadVrfStateComponentRepository myReadVrfStateComponentRepository
Definition: vrfStateComponent.h:241

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)