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 
98  mutable boost::signals2::signal<void (const DtFrameStateInterface*)> signal_extendedDataModified;
99  };
100 
103  {
104  public:
106  virtual ~DtVrfStateComponentNextFrame();
107 
109  const DtVrfStateComponentData& frameState() const { return myData; };
110  DtVrfStateComponentData& frameState() { return myData; };
111 
112  const bool isVrfSimulatedObject() const;
113  void setIsVrfSimulatedObject(const bool&);
114 
115  const DtString label() const;
116  void setLabel(const DtString&);
117 
118  const DtString overlay() const;
119  void setOverlay(const DtString&);
120 
121  const bool independentlyTasked() const;
122  void setIndependentlyTasked(const bool&);
123 
124  const bool& isRemoteAttachedObject() const;
125  void setIsRemoteAttachedObject(const bool&);
126 
127  const DtString engagementRules() const;
128  void setEngagementRules(const DtString&);
129 
130  const bool isSubordinateOfForceLevel() const;
131  void setIsSubordinateOfForceLevel(const bool&);
132 
133  const bool isTasked() const;
134  void setIsTasked(const bool&);
135 
136  const bool underFire() const;
137  void setUnderFire(const bool&);
138 
139  const bool executingPlan() const;
140  void setExecutingPlan(const bool&);
141 
142  const bool hasPlan() const;
143  void setHasPlan(const bool&);
144 
145  const bool sensorsKilled() const;
146  void setSensorsKilled(const bool&);
147 
148  const DtEchelonId& echelonId() const;
149  void setEchelonId(const DtEchelonId&);
150 
151  const int sessionId() const;
152  void setSessionId(const int&);
153 
154  const int vrfMessageVersionSupported() const;
155  void setVrfMessageVersionSupported(const int&);
156 
157  const ExtendedData& extendedData() const;
158  void setExtendedData(const ExtendedData&);
159  void setExtendedData(const DtString& key, const DtString& value);
160  const DtString& extendedData(const DtString& key) const;
161 
162  void clearExtendedData();
163  void updateExtendedData();
164  void removeExtendedData(const DtString& key);
165 
166  bool activated() const;
167 
169  virtual void makeWritable();
170 
172  virtual void makeReadOnly();
173 
174  bool extendedDataModified() const
175  {
176  return myExtendedDataModified;
177  }
178 
180  {
181  myExtendedDataModified = false;
182  }
183 
184  ExtendedData extendedDataMap() const;
185 
186  protected:
187  VRF::WriteVrfStateComponentRepository myWriteVrfStateComponentRepository;
193  };
194 
197  {
198  public:
201 
203  const DtVrfStateComponentData& frameState() const { return myData; };
204 
205  const bool isVrfSimulatedObject() const;
206  const DtString label() const;
207  const DtString overlay() const;
208  const bool independentlyTasked() const;
209  const bool& isRemoteAttachedObject() const;
210  const DtString engagementRules() const;
211  const bool isSubordinateOfForceLevel() const;
212  const bool isTasked() const;
213  const bool underFire() const;
214  const bool executingPlan() const;
215  const bool hasPlan() const;
216  const bool sensorsKilled() const;
217  const DtEchelonId& echelonId() const;
218  const int sessionId() const;
219  const int vrfMessageVersionSupported() const;
220  const ExtendedData& extendedData() const;
221  bool activated() const;
222  bool readComponentValid() const;
223  ExtendedData extendedDataMap() const;
224 
225  const DtString& extendedData(const DtString& key) const;
226 
227  virtual bool findReadComponent();
228  void handleExtendedDataUpdated(const std::vector<UInt32>& attributesUpdated);
229 
230  private:
232  void updateExtendedData(const ExtendedData&);
234  {
235  myData = data;
236  }
237 
238  protected:
239  VRF::ReadVrfStateComponentRepository myReadVrfStateComponentRepository;
241  unsigned int myCallbackHandle;
244  };
245 
249  {
250  public:
253 
254  bool isDoubleBuffered() { return true; };
255  const DtFrameStateInterface* currentFrameState() const { return &myCurrentFrameState; }
256  virtual DtFrameStateInterface* nextFrameState() { return &myNextFrameState; };
257  virtual const DtFrameStateInterface* nextFrameState() const { return &myNextFrameState; };
258 
259  void updateDataStorage();
260 
262  {
263  myCurrentFrameState.updateStateData(sd);
264  myNextFrameState.updateStateData(sd);
265  }
266 
268  virtual bool forceAdvance();
269 
271  virtual void firstFrameAdvance() override;
272 
274  virtual void addAdditionalStateComponents() override;
275 
276  virtual void initializeFromParameters(const DtVrfObjectParameters* params);
277 
278  virtual void aboutToBeDeleted() override
279  {
281  myCurrentFrameState.aboutToBeDeleted();
282  myNextFrameState.aboutToBeDeleted();
283  }
284 
285  protected:
289  };
290 
294 }
Instances of DtVrfObjectParameters are the readable/writeable objects that contain the information ne...
Definition: vrfObjectParameters.h:63
virtual void aboutToBeDeleted() override
Definition: vrfStateComponent.h:278
void clearExtendedDataModified()
Definition: vrfStateComponent.h:179
virtual const DtString & extendedData(const DtString &key) const
Definition: vrfStateComponent.h:92
Definition: stateDataTypes.h:23
DtVrfStateComponentCurrentFrame myCurrentFrameState
Definition: vrfStateComponent.h:286
void advanceFrame(const DtVrfStateComponentData &data)
Definition: vrfStateComponent.h:233
bool extendedDataModified() const
Definition: vrfStateComponent.h:174
ExtendedData myExtendedData
Definition: vrfStateComponent.h:188
const DtFrameStateInterface * currentFrameState() const
Definition: vrfStateComponent.h:255
DtVrfStateComponentData myData
Definition: vrfStateComponent.h:243
DtVrfStateComponentData()
Definition: vrfStateComponent.h:29
Definition: stateComponent.h:266
2) Define the next frame class. This will be used for write access.
Definition: vrfStateComponent.h:102
3) Define the current frame class. This will be used for read access.
Definition: vrfStateComponent.h:196
static tbb::spin_mutex theEchelonIdMutex
Definition: vrfStateComponent.h:23
Contains the DtUUID class declaration.
DtVrfStateComponentData myData
Definition: vrfStateComponent.h:192
DtVrfStateComponentNextFrame myNextFrameState
Definition: vrfStateComponent.h:287
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:109
DtStateData * myStateData
Definition: vrfStateComponent.h:191
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:203
#define UNDEFINED_CONST_METHOD(Type, Method,...)
Definition: doubleBufferedDataStorage.h:65
DtEchelonId myEchelonId
Definition: vrfStateComponent.h:189
The overall structure of the DtStateData mechanism is: The DtStateData contains a list of double buff...
Definition: stateData.h:339
#define DEFINE_STATE_COMPONENT_TYPE(CreatedComponent)
Definition: stateComponent.h:228
bool myExtendedDataModified
Definition: vrfStateComponent.h:190
DtVrfStateComponentData & operator=(const DtVrfStateComponentData &rhs)
Definition: vrfStateComponent.h:40
Subclass from this to indicate that this will be a double buffered state component.
Definition: stateComponent.h:379
bool myFoundComponent
Definition: vrfStateComponent.h:288
4) Define the state component that will contain the wrappers to the next and current frame states tha...
Definition: vrfStateComponent.h:248
#define UNDEFINED_RETURNVALUE_ACCESSOR_MUTATOR(Type, Member, Set)
Definition: doubleBufferedDataStorage.h:53
virtual void aboutToBeDeleted()
virtual void clearExtendedData()
Definition: vrfStateComponent.h:93
DtStateData * myStateData
Definition: vrfStateComponent.h:242
ExtendedData myExtendedData
Definition: vrfStateComponent.h:240
DtEchelonId myEchelonId
Definition: vrfStateComponent.h:57
Definition: echelonId.h:13
VRF::WriteVrfStateComponentRepository myWriteVrfStateComponentRepository
Definition: vrfStateComponent.h:187
#define UNDEFINED_RETURNREF_ACCESSOR_MUTATOR(Type, Member, Set)
Definition: doubleBufferedDataStorage.h:57
#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
DtStateComponentCreator< DtVrfStateComponentImplementation, false > DtVrfStateComponentCreator
5) Define the creator. This will need to be registered with the REGISTER_STATE_COMPONENT macro in the...
Definition: vrfStateComponent.h:293
virtual void removeExtendedData(const DtString &key)
Definition: vrfStateComponent.h:94
virtual DtFrameStateInterface * nextFrameState()
Definition: vrfStateComponent.h:256
void updateStateData(DtStateData *sd)
Implement to update data storage to the new state data.
Definition: vrfStateComponent.h:261
DtVrfStateComponentData(const DtVrfStateComponentData &orig)
Definition: vrfStateComponent.h:34
unsigned int myCallbackHandle
Definition: vrfStateComponent.h:241
Contains the DtStateComponent class declaration.
Definition: stateComponent.h:73
DtVrfStateComponentData & frameState()
Definition: vrfStateComponent.h:110
bool myIsRemoteAttachedObject
Definition: vrfStateComponent.h:56
virtual const DtFrameStateInterface * nextFrameState() const
Definition: vrfStateComponent.h:257
This is a simple base class that will be used to return a pointer to current or next frame state...
Definition: stateComponent.h:291
std::map< DtString, DtString > ExtendedData
Definition: vrfStateComponent.h:65
bool isDoubleBuffered()
Definition: vrfStateComponent.h:254
VRF::ReadVrfStateComponentRepository myReadVrfStateComponentRepository
Definition: vrfStateComponent.h:239

Document ID: Generated on Wed Mar 27 22:49:11 EDT 2024 from SVN revision 264633
Copyright © 2005-2024 MAK Technologies. All Rights Reserved (www.mak.com)