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  , myLabel(orig.myLabel)
38  {
39  }
40 
42  {
43  myIsRemoteAttachedObject = rhs.myIsRemoteAttachedObject;
44  myLabel = rhs.myLabel;
45 
46  {
47  tbb::spin_mutex::scoped_lock lock(theEchelonIdMutex);
48  myEchelonId = rhs.myEchelonId;
49  }
50 
51  return *this;
52  }
53 
54  DEFINE_ACCESSOR_MUTATOR(bool, isRemoteAttachedObject, IsRemoteAttachedObject)
55  DEFINE_ACCESSOR_MUTATOR(DtEchelonId, echelonId, EchelonId)
56  DEFINE_ACCESSOR_MUTATOR(DtString, label, Label)
57 
58  protected:
59  bool myIsRemoteAttachedObject;
60  DtEchelonId myEchelonId;
61  DtString myLabel;
62  };
63 
67  {
68  public:
69  typedef std::map<DtString, DtString> ExtendedData;
71 
73  : DtFrameStateInterface(storage)
74  {
75  }
76 
77  UNDEFINED_RETURNREF_ACCESSOR_MUTATOR(bool, isRemoteAttachedObject, IsRemoteAttachedObject)
78  UNDEFINED_RETURNVALUE_ACCESSOR_MUTATOR(bool, isVrfSimulatedObject, IsVrfSimulatedObject)
79  UNDEFINED_RETURNREF_ACCESSOR_MUTATOR(DtString, label, Label)
80  UNDEFINED_RETURNVALUE_ACCESSOR_MUTATOR(DtString, overlay, Overlay)
81  UNDEFINED_RETURNVALUE_ACCESSOR_MUTATOR(bool, independentlyTasked, IndependentlyTasked)
82  UNDEFINED_RETURNVALUE_ACCESSOR_MUTATOR(DtString, engagementRules, EngagementRules)
83  UNDEFINED_RETURNVALUE_ACCESSOR_MUTATOR(bool, isSubordinateOfForceLevel, IsSubordinateOfForceLevel)
84  UNDEFINED_RETURNVALUE_ACCESSOR_MUTATOR(bool, isTasked, IsTasked)
85  UNDEFINED_RETURNVALUE_ACCESSOR_MUTATOR(bool, underFire, UnderFire)
86  UNDEFINED_RETURNVALUE_ACCESSOR_MUTATOR(bool, executingPlan, ExecutingPlan)
87  UNDEFINED_RETURNVALUE_ACCESSOR_MUTATOR(bool, hasPlan, HasPlan)
88  UNDEFINED_RETURNVALUE_ACCESSOR_MUTATOR(bool, sensorsKilled, SensorsKilled)
89  UNDEFINED_RETURNVALUE_ACCESSOR_MUTATOR(int, sessionId, SessionId)
90  UNDEFINED_RETURNVALUE_ACCESSOR_MUTATOR(int, vrfMessageVersionSupported, VrfMessageVersionSupported)
91  UNDEFINED_RETURNREF_ACCESSOR_MUTATOR(DtEchelonId, echelonId, EchelonId)
92  UNDEFINED_RETURNREF_ACCESSOR_MUTATOR(ExtendedData, extendedData, ExtendedData)
93  UNDEFINED_CONST_METHOD(bool, activated)
94 
95  virtual void setExtendedData(const DtString& key, const DtString& value) { throw DtUnimplementedMethod("setExtendedData(const DtString& key, const DtString& value) is not implemented for this class"); };
96  virtual const DtString& extendedData(const DtString& key) const { throw DtUnimplementedMethod("extendedData(const DtString& key) is not implemented for this class"); };
97  virtual void clearExtendedData() { throw DtUnimplementedMethod("clearExtendedData() is not implemented for this class"); };
98  virtual void removeExtendedData(const DtString& key) { throw DtUnimplementedMethod("removeExtendedData(const DtString& key) is not implemented for this class"); };
99  virtual ExtendedData extendedDataMap() const { throw DtUnimplementedMethod("extendedDataMap() is not implemented for this class"); };
100 
102  mutable boost::signals2::signal<void (const DtFrameStateInterface*)> signal_extendedDataModified;
103  };
104 
107  {
108  public:
110  virtual ~DtVrfStateComponentNextFrame();
111 
113  const DtVrfStateComponentData& frameState() const { return myData; };
114  DtVrfStateComponentData& frameState() { return myData; };
115 
116  const bool isVrfSimulatedObject() const;
117  void setIsVrfSimulatedObject(const bool&);
118 
119  const DtString& label() const;
120  void setLabel(const DtString&);
121 
122  const DtString overlay() const;
123  void setOverlay(const DtString&);
124 
125  const bool independentlyTasked() const;
126  void setIndependentlyTasked(const bool&);
127 
128  const bool& isRemoteAttachedObject() const;
129  void setIsRemoteAttachedObject(const bool&);
130 
131  const DtString engagementRules() const;
132  void setEngagementRules(const DtString&);
133 
134  const bool isSubordinateOfForceLevel() const;
135  void setIsSubordinateOfForceLevel(const bool&);
136 
137  const bool isTasked() const;
138  void setIsTasked(const bool&);
139 
140  const bool underFire() const;
141  void setUnderFire(const bool&);
142 
143  const bool executingPlan() const;
144  void setExecutingPlan(const bool&);
145 
146  const bool hasPlan() const;
147  void setHasPlan(const bool&);
148 
149  const bool sensorsKilled() const;
150  void setSensorsKilled(const bool&);
151 
152  const DtEchelonId& echelonId() const;
153  void setEchelonId(const DtEchelonId&);
154 
155  const int sessionId() const;
156  void setSessionId(const int&);
157 
158  const int vrfMessageVersionSupported() const;
159  void setVrfMessageVersionSupported(const int&);
160 
161  const ExtendedData& extendedData() const;
162  void setExtendedData(const ExtendedData&);
163  void setExtendedData(const DtString& key, const DtString& value);
164  const DtString& extendedData(const DtString& key) const;
165 
166  void clearExtendedData();
167  void updateExtendedData();
168  void removeExtendedData(const DtString& key);
169 
170  bool activated() const;
171 
173  virtual void makeWritable();
174 
176  virtual void makeReadOnly();
177 
178  bool extendedDataModified() const
179  {
180  return myExtendedDataModified;
181  }
182 
184  {
185  myExtendedDataModified = false;
186  }
187 
188  ExtendedData extendedDataMap() const;
189 
190  protected:
191  VRF::WriteVrfStateComponentRepository myWriteVrfStateComponentRepository;
197  };
198 
201  {
202  public:
205 
207  const DtVrfStateComponentData& frameState() const { return myData; };
208 
209  const bool isVrfSimulatedObject() const;
210  const DtString& label() const;
211  const DtString overlay() const;
212  const bool independentlyTasked() const;
213  const bool& isRemoteAttachedObject() const;
214  const DtString engagementRules() const;
215  const bool isSubordinateOfForceLevel() const;
216  const bool isTasked() const;
217  const bool underFire() const;
218  const bool executingPlan() const;
219  const bool hasPlan() const;
220  const bool sensorsKilled() const;
221  const DtEchelonId& echelonId() const;
222  const int sessionId() const;
223  const int vrfMessageVersionSupported() const;
224  const ExtendedData& extendedData() const;
225  bool activated() const;
226  bool readComponentValid() const;
227  ExtendedData extendedDataMap() const;
228 
229  const DtString& extendedData(const DtString& key) const;
230 
231  virtual bool findReadComponent();
232  void handleExtendedDataUpdated(const std::vector<UInt32>& attributesUpdated);
233 
234  private:
236  void updateExtendedData(const ExtendedData&);
238  {
239  myData = data;
240  }
241 
242  protected:
243  VRF::ReadVrfStateComponentRepository myReadVrfStateComponentRepository;
245  unsigned int myCallbackHandle;
248  };
249 
253  {
254  public:
257 
258  bool isDoubleBuffered() { return true; };
259  const DtFrameStateInterface* currentFrameState() const { return &myCurrentFrameState; }
260  virtual DtFrameStateInterface* nextFrameState() { return &myNextFrameState; };
261  virtual const DtFrameStateInterface* nextFrameState() const { return &myNextFrameState; };
262 
263  void updateDataStorage();
264 
266  {
267  myCurrentFrameState.updateStateData(sd);
268  myNextFrameState.updateStateData(sd);
269  }
270 
272  virtual bool forceAdvance();
273 
275  virtual void firstFrameAdvance() override;
276 
278  virtual void addAdditionalStateComponents() override;
279 
280  virtual void initializeFromParameters(const DtVrfObjectParameters* params);
281 
282  virtual void aboutToBeDeleted() override
283  {
285  myCurrentFrameState.aboutToBeDeleted();
286  myNextFrameState.aboutToBeDeleted();
287  }
288 
289  protected:
293  };
294 
298 }
Instances of DtVrfObjectParameters are the readable/writeable objects that contain the information ne...
Definition: vrfObjectParameters.h:63
virtual void aboutToBeDeleted() override
Definition: vrfStateComponent.h:282
void clearExtendedDataModified()
Definition: vrfStateComponent.h:183
virtual const DtString & extendedData(const DtString &key) const
Definition: vrfStateComponent.h:96
Definition: stateDataTypes.h:23
DtVrfStateComponentCurrentFrame myCurrentFrameState
Definition: vrfStateComponent.h:290
void advanceFrame(const DtVrfStateComponentData &data)
Definition: vrfStateComponent.h:237
bool extendedDataModified() const
Definition: vrfStateComponent.h:178
ExtendedData myExtendedData
Definition: vrfStateComponent.h:192
const DtFrameStateInterface * currentFrameState() const
Definition: vrfStateComponent.h:259
DtVrfStateComponentData myData
Definition: vrfStateComponent.h:247
DtVrfStateComponentData()
Definition: vrfStateComponent.h:29
Definition: stateComponent.h:266
DtString myLabel
Definition: vrfStateComponent.h:61
2) Define the next frame class. This will be used for write access.
Definition: vrfStateComponent.h:106
3) Define the current frame class. This will be used for read access.
Definition: vrfStateComponent.h:200
static tbb::spin_mutex theEchelonIdMutex
Definition: vrfStateComponent.h:23
Contains the DtUUID class declaration.
DtVrfStateComponentData myData
Definition: vrfStateComponent.h:196
DtVrfStateComponentNextFrame myNextFrameState
Definition: vrfStateComponent.h:291
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:113
DtStateData * myStateData
Definition: vrfStateComponent.h:195
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:66
const DtVrfStateComponentData & frameState() const
Current frame state only can access current frame buffers. This ensures thread safety.
Definition: vrfStateComponent.h:207
#define UNDEFINED_CONST_METHOD(Type, Method,...)
Definition: doubleBufferedDataStorage.h:65
DtEchelonId myEchelonId
Definition: vrfStateComponent.h:193
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:194
DtVrfStateComponentData & operator=(const DtVrfStateComponentData &rhs)
Definition: vrfStateComponent.h:41
Subclass from this to indicate that this will be a double buffered state component.
Definition: stateComponent.h:379
bool myFoundComponent
Definition: vrfStateComponent.h:292
4) Define the state component that will contain the wrappers to the next and current frame states tha...
Definition: vrfStateComponent.h:252
#define UNDEFINED_RETURNVALUE_ACCESSOR_MUTATOR(Type, Member, Set)
Definition: doubleBufferedDataStorage.h:53
virtual void aboutToBeDeleted()
virtual void clearExtendedData()
Definition: vrfStateComponent.h:97
DtStateData * myStateData
Definition: vrfStateComponent.h:246
ExtendedData myExtendedData
Definition: vrfStateComponent.h:244
DtEchelonId myEchelonId
Definition: vrfStateComponent.h:60
Definition: echelonId.h:13
VRF::WriteVrfStateComponentRepository myWriteVrfStateComponentRepository
Definition: vrfStateComponent.h:191
#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:297
virtual void removeExtendedData(const DtString &key)
Definition: vrfStateComponent.h:98
virtual DtFrameStateInterface * nextFrameState()
Definition: vrfStateComponent.h:260
void updateStateData(DtStateData *sd)
Implement to update data storage to the new state data.
Definition: vrfStateComponent.h:265
DtVrfStateComponentData(const DtVrfStateComponentData &orig)
Definition: vrfStateComponent.h:34
unsigned int myCallbackHandle
Definition: vrfStateComponent.h:245
Contains the DtStateComponent class declaration.
Definition: stateComponent.h:73
DtVrfStateComponentData & frameState()
Definition: vrfStateComponent.h:114
bool myIsRemoteAttachedObject
Definition: vrfStateComponent.h:59
virtual const DtFrameStateInterface * nextFrameState() const
Definition: vrfStateComponent.h:261
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:69
bool isDoubleBuffered()
Definition: vrfStateComponent.h:258
VRF::ReadVrfStateComponentRepository myReadVrfStateComponentRepository
Definition: vrfStateComponent.h:243

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)