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

Document ID: Generated on Sun Dec 4 20:22:03 EST 2022 from SVN revision 249613
Copyright © 2005-2021 MAK Technologies. All Rights Reserved (www.mak.com)