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 
26  static tbb::spin_mutex theEchelonIdMutex;
27 
30  {
33  : myIsRemoteAttachedObject(false)
34  {
35  }
36 
40  : myIsRemoteAttachedObject(orig.myIsRemoteAttachedObject)
41  , myEchelonId(orig.myEchelonId)
42  {
43  }
44 
49  {
50  myIsRemoteAttachedObject = rhs.myIsRemoteAttachedObject;
51 
52  {
53  tbb::spin_mutex::scoped_lock lock(theEchelonIdMutex);
54  myEchelonId = rhs.myEchelonId;
55  }
56 
57  return *this;
58  }
59 
60  DEFINE_ACCESSOR_MUTATOR(bool, isRemoteAttachedObject, IsRemoteAttachedObject)
61  DEFINE_ACCESSOR_MUTATOR(DtEchelonId, echelonId, EchelonId)
62 
63  protected:
65  bool myIsRemoteAttachedObject;
67  DtEchelonId myEchelonId;
68  };
69 
73  {
74  public:
76  typedef std::map<DtString, DtString> ExtendedData;
78 
79 
82  : DtFrameStateInterface(storage)
83  {
84  }
85 
86  UNDEFINED_RETURNREF_ACCESSOR_MUTATOR(bool, isRemoteAttachedObject, IsRemoteAttachedObject)
87  UNDEFINED_RETURNVALUE_ACCESSOR_MUTATOR(bool, isVrfSimulatedObject, IsVrfSimulatedObject)
89  UNDEFINED_RETURNVALUE_ACCESSOR_MUTATOR(DtString, overlay, Overlay)
90  UNDEFINED_RETURNVALUE_ACCESSOR_MUTATOR(bool, independentlyTasked, IndependentlyTasked)
91  UNDEFINED_RETURNVALUE_ACCESSOR_MUTATOR(DtString, engagementRules, EngagementRules)
92  UNDEFINED_RETURNVALUE_ACCESSOR_MUTATOR(bool, isSubordinateOfForceLevel, IsSubordinateOfForceLevel)
93  UNDEFINED_RETURNVALUE_ACCESSOR_MUTATOR(bool, isTasked, IsTasked)
94  UNDEFINED_RETURNVALUE_ACCESSOR_MUTATOR(bool, underFire, UnderFire)
95  UNDEFINED_RETURNVALUE_ACCESSOR_MUTATOR(bool, executingPlan, ExecutingPlan)
96  UNDEFINED_RETURNVALUE_ACCESSOR_MUTATOR(bool, hasPlan, HasPlan)
97  UNDEFINED_RETURNVALUE_ACCESSOR_MUTATOR(bool, sensorsKilled, SensorsKilled)
98  UNDEFINED_RETURNVALUE_ACCESSOR_MUTATOR(int, sessionId, SessionId)
99  UNDEFINED_RETURNVALUE_ACCESSOR_MUTATOR(int, vrfMessageVersionSupported, VrfMessageVersionSupported)
100  UNDEFINED_RETURNREF_ACCESSOR_MUTATOR(DtEchelonId, echelonId, EchelonId)
101  UNDEFINED_RETURNREF_ACCESSOR_MUTATOR(ExtendedData, extendedData, ExtendedData)
102  UNDEFINED_CONST_METHOD(bool, activated)
103 
104  virtual void setExtendedData(const DtString& key, const DtString& value) { throw DtUnimplementedMethod("setExtendedData(const DtString& key, const DtString& value) is not implemented for this class"); };
105  virtual const DtString& extendedData(const DtString& key) const { throw DtUnimplementedMethod("extendedData(const DtString& key) is not implemented for this class"); };
106  virtual void clearExtendedData() { throw DtUnimplementedMethod("clearExtendedData() is not implemented for this class"); };
107  virtual void removeExtendedData(const DtString& key) { throw DtUnimplementedMethod("removeExtendedData(const DtString& key) is not implemented for this class"); };
108  virtual ExtendedData extendedDataMap() const { throw DtUnimplementedMethod("extendedDataMap() is not implemented for this class"); };
109  virtual bool hasExtendedData(const DtString&) const { throw DtUnimplementedMethod("hasExtendedData(const DtString&) const is not implemented for this class"); };
110 
112  mutable boost::signals2::signal<void (const DtFrameStateInterface*)> signal_extendedDataModified{};
113  };
114 
117  {
118  public:
123  virtual ~DtVrfStateComponentNextFrame() override;
124 
126  const DtVrfStateComponentData& frameState() const { return myData; };
127  DtVrfStateComponentData& frameState() { return myData; };
128 
129  virtual const bool isVrfSimulatedObject() const override;
130  virtual void setIsVrfSimulatedObject(const bool&) override;
131 
132  virtual const DtString label() const override;
133  virtual void setLabel(const DtString&) override;
134 
135  virtual const DtString overlay() const override;
136  virtual void setOverlay(const DtString&) override;
137 
138  virtual const bool independentlyTasked() const override;
139  virtual void setIndependentlyTasked(const bool&) override;
140 
141  virtual const bool& isRemoteAttachedObject() const override;
142  virtual void setIsRemoteAttachedObject(const bool&) override;
143 
144  virtual const DtString engagementRules() const override;
145  virtual void setEngagementRules(const DtString&) override;
146 
147  virtual const bool isSubordinateOfForceLevel() const override;
148  virtual void setIsSubordinateOfForceLevel(const bool&) override;
149 
150  virtual const bool isTasked() const override;
151  virtual void setIsTasked(const bool&) override;
152 
153  virtual const bool underFire() const override;
154  virtual void setUnderFire(const bool&) override;
155 
156  virtual const bool executingPlan() const override;
157  virtual void setExecutingPlan(const bool&) override;
158 
159  virtual const bool hasPlan() const override;
160  virtual void setHasPlan(const bool&) override;
161 
162  virtual const bool sensorsKilled() const override;
163  virtual void setSensorsKilled(const bool&) override;
164 
165  virtual const DtEchelonId& echelonId() const override;
166  virtual void setEchelonId(const DtEchelonId&) override;
167 
168  virtual const int sessionId() const override;
169  virtual void setSessionId(const int&) override;
170 
171  virtual const int vrfMessageVersionSupported() const override;
172  virtual void setVrfMessageVersionSupported(const int&) override;
173 
174  virtual const ExtendedData& extendedData() const override;
175  virtual void setExtendedData(const ExtendedData&) override;
176  virtual void setExtendedData(const DtString& key, const DtString& value) override;
177  virtual const DtString& extendedData(const DtString& key) const override;
178 
179  virtual void clearExtendedData() override;
181  void updateExtendedData();
182  virtual void removeExtendedData(const DtString& key) override;
183 
184  virtual bool activated() const override;
185 
187  virtual void makeWritable() override;
188 
190  virtual void makeReadOnly() override;
191 
194  bool extendedDataModified() const
195  {
196  return myExtendedDataModified;
197  }
198 
201  {
202  myExtendedDataModified = false;
203  }
204 
205  virtual ExtendedData extendedDataMap() const override;
206  virtual bool hasExtendedData(const DtString&) const override;
207 
208  protected:
210  VRF::WriteVrfStateComponentRepository myWriteVrfStateComponentRepository;
219  };
220 
223  {
224  public:
229  virtual ~DtVrfStateComponentCurrentFrame() override;
230 
232  const DtVrfStateComponentData& frameState() const { return myData; };
233 
234  virtual const bool isVrfSimulatedObject() const override;
235  virtual const DtString label() const override;
236  virtual const DtString overlay() const override;
237  virtual const bool independentlyTasked() const override;
238  virtual const bool& isRemoteAttachedObject() const override;
239  virtual const DtString engagementRules() const override;
240  virtual const bool isSubordinateOfForceLevel() const override;
241  virtual const bool isTasked() const override;
242  virtual const bool underFire() const override;
243  virtual const bool executingPlan() const override;
244  virtual const bool hasPlan() const override;
245  virtual const bool sensorsKilled() const override;
246  virtual const DtEchelonId& echelonId() const override;
247  virtual const int sessionId() const override;
248  virtual const int vrfMessageVersionSupported() const override;
249  virtual const ExtendedData& extendedData() const override;
250  virtual bool activated() const override;
253  bool readComponentValid() const;
254  virtual ExtendedData extendedDataMap() const override;
255  virtual bool hasExtendedData(const DtString&) const override;
256 
257  virtual const DtString& extendedData(const DtString& key) const override;
258 
261  virtual bool findReadComponent();
264  void handleExtendedDataUpdated(const std::vector<UInt32>& attributesUpdated);
265 
266  private:
270  void updateExtendedData(const ExtendedData&);
274  {
275  myData = data;
276  }
277 
278  protected:
280  VRF::ReadVrfStateComponentRepository myReadVrfStateComponentRepository;
284  unsigned int myCallbackHandle;
287  };
288 
292  {
293  public:
298  virtual ~DtVrfStateComponentImplementation() override;
299 
302  bool isDoubleBuffered() { return true; };
305  virtual const DtFrameStateInterface* currentFrameState() const override { return &myCurrentFrameState; }
308  virtual DtFrameStateInterface* nextFrameState() override { return &myNextFrameState; };
311  virtual const DtFrameStateInterface* nextFrameState() const override { return &myNextFrameState; };
312 
314  virtual void updateDataStorage() override;
315 
318  virtual void updateStateData(DtStateData* sd) override
319  {
320  myCurrentFrameState.updateStateData(sd);
321  myNextFrameState.updateStateData(sd);
322  }
323 
325  virtual bool forceAdvance() override;
326 
328  virtual void firstFrameAdvance() override;
329 
331  virtual void addAdditionalStateComponents() override;
332 
335  virtual void initializeFromParameters(const DtVrfObjectParameters* params) override;
336 
338  virtual void aboutToBeDeleted() override
339  {
341  myCurrentFrameState.aboutToBeDeleted();
342  myNextFrameState.aboutToBeDeleted();
343  }
344 
345  protected:
352  };
353 
357 }
Instances of DtVrfObjectParameters are the readable/writeable objects that contain the information ne...
Definition: vrfObjectParameters.h:64
virtual void aboutToBeDeleted() override
Notifies sub-components that this state component is about to be removed.
Definition: vrfStateComponent.h:338
void clearExtendedDataModified()
Resets the extended data modified flag to false.
Definition: vrfStateComponent.h:200
virtual const DtString & extendedData(const DtString &key) const
Definition: vrfStateComponent.h:105
Exception thrown when a required method has not been implemented.
Definition: stateDataTypes.h:30
DtVrfStateComponentCurrentFrame myCurrentFrameState
The current-frame (read) view of the VRF state component data.
Definition: vrfStateComponent.h:347
void advanceFrame(const DtVrfStateComponentData &data)
Advances the frame by copying the new state data into the current frame buffer.
Definition: vrfStateComponent.h:273
bool extendedDataModified() const
Returns true if the extended data has been modified since the last clear.
Definition: vrfStateComponent.h:194
ExtendedData myExtendedData
Cached map of extended key-value data for this frame.
Definition: vrfStateComponent.h:212
DtVrfStateComponentData myData
Per-frame state data values for the current frame.
Definition: vrfStateComponent.h:286
DtVrfStateComponentData()
Default constructor; initializes myIsRemoteAttachedObject to false.
Definition: vrfStateComponent.h:32
Default creator implementation for a state component type. T_StateComponent is the concrete component...
Definition: stateComponent.h:326
2) Define the next frame class. This will be used for write access.
Definition: vrfStateComponent.h:116
3) Define the current frame class. This will be used for read access.
Definition: vrfStateComponent.h:222
static tbb::spin_mutex theEchelonIdMutex
Mutex used to protect concurrent access to DtEchelonId data in DtVrfStateComponentData.
Definition: vrfStateComponent.h:23
Contains the DtUUID class declaration.
DtVrfStateComponentData myData
Per-frame state data values for this component.
Definition: vrfStateComponent.h:218
DtVrfStateComponentNextFrame myNextFrameState
The next-frame (write) view of the VRF state component data.
Definition: vrfStateComponent.h:349
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:126
virtual bool hasExtendedData(const DtString &) const
Definition: vrfStateComponent.h:109
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:72
const DtVrfStateComponentData & frameState() const
Current frame state only can access current frame buffers. This ensures thread safety.
Definition: vrfStateComponent.h:232
#define UNDEFINED_CONST_METHOD(Type, Method,...)
Defines a virtual const method with variadic parameters that throws DtUnimplementedMethod, requiring an override in a derived class.
Definition: doubleBufferedDataStorage.h:130
DtEchelonId myEchelonId
Cached echelon identifier for this entity.
Definition: vrfStateComponent.h:214
The overall structure of the DtStateData mechanism is: The DtStateData contains a list of double buff...
Definition: stateData.h:513
virtual DtFrameStateInterface * nextFrameState() override
Returns mutable access to the next frame state for writing.
Definition: vrfStateComponent.h:308
#define DEFINE_STATE_COMPONENT_TYPE(CreatedComponent)
Macro to define all required static and virtual state component type methods. Place in the public sec...
Definition: stateComponent.h:272
bool myExtendedDataModified
True if extended data has been modified and needs to be flushed.
Definition: vrfStateComponent.h:216
DtVrfStateComponentData & operator=(const DtVrfStateComponentData &rhs)
Assignment operator.
Definition: vrfStateComponent.h:48
virtual const DtFrameStateInterface * nextFrameState() const override
Returns read-only access to the next frame state.
Definition: vrfStateComponent.h:311
virtual const DtFrameStateInterface * currentFrameState() const override
Returns read-only access to the current frame state.
Definition: vrfStateComponent.h:305
virtual ExtendedData extendedDataMap() const
Definition: vrfStateComponent.h:108
Subclass from this to indicate that this will be a double buffered state component.
Definition: stateComponent.h:489
bool myFoundComponent
True once the readable Legion VRF state component repository has been located.
Definition: vrfStateComponent.h:351
4) Define the state component that will contain the wrappers to the next and current frame states tha...
Definition: vrfStateComponent.h:291
#define UNDEFINED_RETURNVALUE_ACCESSOR_MUTATOR(Type, Member, Set)
Defines an undefined virtual by-value accessor and an undefined virtual setter, both throwing DtUnimp...
Definition: doubleBufferedDataStorage.h:103
virtual void aboutToBeDeleted()
Called when the component is about to be deleted; emits signal_stateComponentAboutToBeDeleted.
virtual void clearExtendedData()
Definition: vrfStateComponent.h:106
ExtendedData myExtendedData
Cached map of extended key-value data for the current frame.
Definition: vrfStateComponent.h:282
DtEchelonId myEchelonId
Echelon identifier for this entity.
Definition: vrfStateComponent.h:67
Definition: echelonId.h:13
VRF::WriteVrfStateComponentRepository myWriteVrfStateComponentRepository
Writable Legion repository instance for publishing VRF state component data.
Definition: vrfStateComponent.h:210
#define UNDEFINED_RETURNREF_ACCESSOR_MUTATOR(Type, Member, Set)
Defines an undefined virtual const-reference accessor and an undefined virtual setter, both throwing DtUnimplementedMethod and requiring overrides in a derived class.
Definition: doubleBufferedDataStorage.h:112
virtual void updateStateData(DtStateData *sd) override
Updates the state data pointer for both current and next frame sub-components.
Definition: vrfStateComponent.h:318
#define DEFINE_ACCESSOR_MUTATOR(ReturnType, Accessor, Mutator)
Defines a const reference accessor and an inline setter for a member variable.
Definition: doubleBufferedDataStorage.h:37
POD-style data structure holding per-frame VRF state component values.
Definition: vrfStateComponent.h:29
#define DT_DLL_vrfStateData
This file is used to determine how to build Disable inconsistent dll linkage warning Visual Studio 6...
Definition: vrfStateDataDefines.h:29
virtual void removeExtendedData(const DtString &key)
Definition: vrfStateComponent.h:107
DtVrfStateComponentData(const DtVrfStateComponentData &orig)
Copy constructor.
Definition: vrfStateComponent.h:39
unsigned int myCallbackHandle
Handle for the registered Legion attribute update callback.
Definition: vrfStateComponent.h:284
Contains the DtStateComponent class declaration.
Definition: stateComponent.h:76
DtVrfStateComponentData & frameState()
Definition: vrfStateComponent.h:127
bool myIsRemoteAttachedObject
True if this object is a remote attached object.
Definition: vrfStateComponent.h:65
Base interface for accessing current or next frame state in a double-buffered state component...
Definition: stateComponent.h:354
std::map< DtString, DtString > ExtendedData
Map of key-value string pairs used to store extended simulation data.
Definition: vrfStateComponent.h:76
bool isDoubleBuffered()
Returns true indicating this component uses double-buffered state storage.
Definition: vrfStateComponent.h:302
VRF::ReadVrfStateComponentRepository myReadVrfStateComponentRepository
Read-only Legion repository instance for consuming VRF state component data.
Definition: vrfStateComponent.h:280

Document ID: Generated on Thu Oct 15 21:27:02 EDT 2026 from SVN revision 296421
Copyright © 2005-2026 MAK Technologies. All Rights Reserved (www.mak.com)