VR-Forces Developer's Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
laserDesignatorStateComponent.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 
10 #include <legionStandardOM/sets/readDesignatorRepository.hpp>
11 #include <legionStandardOM/sets/writeDesignatorRepository.hpp>
12 #include <vrfutil/rwUUID.h>
13 #include <matrix/vlVector.h>
14 
15 namespace makVrf
16 {
20  {
22  : myDesignatedObject(DtUUID::nullUUID())
23  , myDesignatorId(DtUUID::nullUUID())
24  , myUserData(0)
25  {
26  }
27 
29  : myDesignatedObject(orig.myDesignatedObject)
30  , myDesignatorId(orig.myDesignatorId)
31  , myGlobalId(orig.myGlobalId)
32  , myUserData(orig.myUserData)
33  {
34  }
35 
37  {
38  myDesignatedObject = rhs.myDesignatedObject;
39  myDesignatorId = rhs.myDesignatorId;
40  myGlobalId = rhs.myGlobalId;
41  myUserData = rhs.myUserData;
42 
43  return *this;
44  }
45 
46  DEFINE_ACCESSOR_MUTATOR(DtUUID, designatedObject, DesignatedObject)
47  DEFINE_ACCESSOR_MUTATOR(DtUUID, designatorId, DesignatorId)
48  DEFINE_ACCESSOR_MUTATOR(DtString, globalId, GlobalId)
49  DEFINE_ACCESSOR_MUTATOR(unsigned long long, userData, UserData)
50 
51  protected:
53  DtUUID myDesignatedObject;
55  DtUUID myDesignatorId;
57  DtString myGlobalId;
59  unsigned long long myUserData;
60  };
61 
65  {
66  public:
68 
70  : DtFrameStateInterface(storage)
71  {
72  }
73 
74  UNDEFINED_RETURNREF_ACCESSOR_MUTATOR(DtUUID, designatedObject, DesignatedObject)
75  UNDEFINED_RETURNREF_ACCESSOR_MUTATOR(DtUUID, designatorId, DesignatorId)
76  UNDEFINED_RETURNVALUE_ACCESSOR_MUTATOR(unsigned int, designatorCode, DesignatorCode)
77  UNDEFINED_RETURNVALUE_ACCESSOR_MUTATOR(unsigned int, drAlgorithm, DrAlgorithm)
78  UNDEFINED_RETURNVALUE_ACCESSOR_MUTATOR(double, designatorPower, DesignatorPower)
79  UNDEFINED_RETURNVALUE_ACCESSOR_MUTATOR(double, designatorWavelength, DesignatorWavelength)
80  UNDEFINED_RETURNVALUE_ACCESSOR_MUTATOR(DtVector, designatorSpotLocation, DesignatorSpotLocation)
81  UNDEFINED_RETURNVALUE_ACCESSOR_MUTATOR(DtVector, relativeSpotLocation, RelativeSpotLocation)
82  UNDEFINED_RETURNVALUE_ACCESSOR_MUTATOR(DtVector, relativePosition, RelativePosition)
83  UNDEFINED_RETURNVALUE_ACCESSOR_MUTATOR(unsigned int, codeName, CodeName)
84  UNDEFINED_RETURNVALUE_ACCESSOR_MUTATOR(unsigned long long, userData, UserData)
85  UNDEFINED_RETURNVALUE_ACCESSOR_MUTATOR(DtVector, spotLinearAcceleration, SpotLinearAcceleration)
87  };
88 
91  {
92  public:
94  virtual ~DtLaserDesignatorStateComponentNextFrame() override;
95 
97  const DtLaserDesignatorStateComponentData& frameState() const { return myData; };
99 
101  virtual const DtUUID& designatedObject() const override;
103  virtual void setDesignatedObject(const DtUUID&) override;
104 
106  virtual const DtUUID& designatorId() const override;
108  virtual void setDesignatorId(const DtUUID&) override;
109 
111  virtual const unsigned int designatorCode() const override;
113  virtual void setDesignatorCode(const unsigned int&) override;
114 
116  virtual const unsigned long long userData() const override;
118  virtual void setUserData(const unsigned long long&) override;
119 
121  virtual const unsigned int drAlgorithm() const override;
123  virtual void setDrAlgorithm(const unsigned int&) override;
124 
126  virtual const unsigned int codeName() const override;
128  virtual void setCodeName(const unsigned int&) override;
129 
131  virtual const DtVector spotLinearAcceleration() const override;
133  virtual void setSpotLinearAcceleration(const DtVector&) override;
134 
136  virtual const double designatorPower() const override;
138  virtual void setDesignatorPower(const double&) override;
139 
141  virtual const double designatorWavelength() const override;
143  virtual void setDesignatorWavelength(const double&) override;
144 
146  virtual const DtVector designatorSpotLocation() const override;
148  virtual void setDesignatorSpotLocation(const DtVector&) override;
149 
151  virtual const DtVector relativeSpotLocation() const override;
153  virtual void setRelativeSpotLocation(const DtVector&) override;
154 
156  virtual const DtVector relativePosition() const override;
158  virtual void setRelativePosition(const DtVector&) override;
159 
161  virtual const DtString& globalId() const override;
163  virtual void setGlobalId(const DtString&) override;
164 
166  virtual void makeWritable() override;
167 
169  virtual void makeReadOnly() override;
171  void cleanupWriteState();
172 
173  protected:
177  LOM::WriteDesignatorRepository myWriteDesignatorRepository;
178  };
179 
182  {
183  public:
186 
188  const DtLaserDesignatorStateComponentData& frameState() const { return myData; };
189 
191  virtual const unsigned long long userData() const override;
193  virtual const DtUUID& designatedObject() const override;
195  virtual const DtUUID& designatorId() const override;
197  virtual const unsigned int designatorCode() const override;
199  virtual const double designatorPower() const override;
201  virtual const double designatorWavelength() const override;
203  virtual const DtVector designatorSpotLocation() const override;
205  virtual const DtVector relativeSpotLocation() const override;
207  virtual const DtVector relativePosition() const override;
209  virtual const unsigned int codeName() const override;
211  virtual const DtVector spotLinearAcceleration() const override;
213  virtual const unsigned int drAlgorithm() const override;
215  virtual const DtString& globalId() const override;
216 
218  bool readComponentValid() const;
221  bool findReadComponent();
222 
223  protected:
225  void handleDataUpdated();
226 
231  {
232  myData = data;
233  }
234 
235  protected:
239  LOM::ReadDesignatorRepository myReadDesignatorRepository;
242  };
243 
247  {
248  public:
250 
252  bool isDoubleBuffered() { return true; };
254  virtual const DtFrameStateInterface* currentFrameState() const override { return &myCurrentFrameState; }
256  virtual DtFrameStateInterface* nextFrameState() override { return &myNextFrameState; };
258  virtual const DtFrameStateInterface* nextFrameState() const override { return &myNextFrameState; };
259 
262  virtual bool forceAdvance() override;
263 
266  virtual void updateDataStorage() override
267  {
268  if (myNextFrameState.isWritable())
269  {
270  if (!myFoundComponent)
271  {
272  myFoundComponent = myCurrentFrameState.findReadComponent();
273  }
274 
275  myCurrentFrameState.advanceFrame(myNextFrameState.frameState());
276  }
277 
278  myCurrentFrameState.emitComponentUpdated();
279  }
280 
283  virtual void updateStateData(DtStateData* sd) override
284  {
285  myCurrentFrameState.updateStateData(sd);
286  myNextFrameState.updateStateData(sd);
287  }
288 
290  virtual void aboutToBeDeleted() override
291  {
293  myCurrentFrameState.aboutToBeDeleted();
294  myNextFrameState.aboutToBeDeleted();
295  }
296 
298  virtual void firstFrameAdvance() override;
300  virtual void removeAdditionalStateComponents() override;
301 
302  protected:
309  };
310 
314 }
UUID is a unique ID wrapper class.
Definition: uuid.h:59
const DtLaserDesignatorStateComponentData & frameState() const
Current frame state only can access current frame buffers. This ensures thread safety.
Definition: laserDesignatorStateComponent.h:188
DtLaserDesignatorStateComponentData myData
Laser designator state data for the current frame.
Definition: laserDesignatorStateComponent.h:237
DtUUID myDesignatedObject
UUID of the entity currently being designated by this laser designator.
Definition: laserDesignatorStateComponent.h:53
LOM::ReadDesignatorRepository myReadDesignatorRepository
Read-access Legion designator repository for consuming state.
Definition: laserDesignatorStateComponent.h:239
Default creator implementation for a state component type. T_StateComponent is the concrete component...
Definition: stateComponent.h:326
DtStateComponentCreator< DtLaserDesignatorStateComponentImplementation > DtLaserDesignatorStateComponentCreator
5) Define the creator. This will need to be registered with the REGISTER_STATE_COMPONENT macro in the...
Definition: laserDesignatorStateComponent.h:313
DtLaserDesignatorStateComponentData & operator=(const DtLaserDesignatorStateComponentData &rhs)
Definition: laserDesignatorStateComponent.h:36
virtual const DtFrameStateInterface * nextFrameState() const override
Definition: laserDesignatorStateComponent.h:258
DtLaserDesignatorStateComponentNextFrame myNextFrameState
Next frame laser designator state component (write access).
Definition: laserDesignatorStateComponent.h:306
Contains the DtUUID class declaration.
4) Define the state component that will contain the wrappers to the next and current frame states tha...
Definition: laserDesignatorStateComponent.h:246
virtual const DtFrameStateInterface * currentFrameState() const override
Definition: laserDesignatorStateComponent.h:254
virtual void updateDataStorage() override
Copies the next frame state into the current frame, and attempts to locate the read component if it h...
Definition: laserDesignatorStateComponent.h:266
Holds the state data for a single laser designator, including the designated target entity...
Definition: laserDesignatorStateComponent.h:19
DtLaserDesignatorStateComponentData()
Definition: laserDesignatorStateComponent.h:21
The overall structure of the DtStateData mechanism is: The DtStateData contains a list of double buff...
Definition: stateData.h:513
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: laserDesignatorStateComponent.h:64
#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
Subclass from this to indicate that this will be a double buffered state component.
Definition: stateComponent.h:489
unsigned long long myUserData
Application-defined tag for associating arbitrary data with this designator.
Definition: laserDesignatorStateComponent.h:59
#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
LOM::WriteDesignatorRepository myWriteDesignatorRepository
Write-access Legion designator repository for publishing state.
Definition: laserDesignatorStateComponent.h:177
DtUUID myDesignatorId
Unique identifier for this laser designator instance.
Definition: laserDesignatorStateComponent.h:55
DtLaserDesignatorStateComponentData & frameState()
Definition: laserDesignatorStateComponent.h:98
2) Define the next frame class. This will be used for write access.
Definition: laserDesignatorStateComponent.h:90
virtual void aboutToBeDeleted()
Called when the component is about to be deleted; emits signal_stateComponentAboutToBeDeleted.
bool isDoubleBuffered()
Definition: laserDesignatorStateComponent.h:252
virtual void updateStateData(DtStateData *sd) override
Updates the state data pointer for both the current and next frame states.
Definition: laserDesignatorStateComponent.h:283
3) Define the current frame class. This will be used for read access.
Definition: laserDesignatorStateComponent.h:181
#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
#define DEFINE_ACCESSOR_MUTATOR(ReturnType, Accessor, Mutator)
Defines a const reference accessor and an inline setter for a member variable.
Definition: doubleBufferedDataStorage.h:37
DtLaserDesignatorStateComponentData myData
Laser designator state data for the next frame.
Definition: laserDesignatorStateComponent.h:175
virtual void aboutToBeDeleted() override
Notifies the current and next frame states that the component is about to be deleted.
Definition: laserDesignatorStateComponent.h:290
int myCallbackHandle
Handle for the instance-updated callback registered with the read repository.
Definition: laserDesignatorStateComponent.h:241
#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
const DtLaserDesignatorStateComponentData & frameState() const
Next frame access write access. Ensure this is only used in a single thread (i.e.a controller thread)...
Definition: laserDesignatorStateComponent.h:97
DtLaserDesignatorStateComponentCurrentFrame myCurrentFrameState
Current frame laser designator state component (read access).
Definition: laserDesignatorStateComponent.h:304
virtual DtFrameStateInterface * nextFrameState() override
Definition: laserDesignatorStateComponent.h:256
Contains the DtStateComponent class declaration.
bool myFoundComponent
Tracks whether the read designator repository has been located.
Definition: laserDesignatorStateComponent.h:308
DtString myGlobalId
Protocol-independent string identifier for this laser designator.
Definition: laserDesignatorStateComponent.h:57
DtLaserDesignatorStateComponentData(const DtLaserDesignatorStateComponentData &orig)
Definition: laserDesignatorStateComponent.h:28
Base interface for accessing current or next frame state in a double-buffered state component...
Definition: stateComponent.h:354
void advanceFrame(const DtLaserDesignatorStateComponentData &data)
Advances the current frame state to the provided data.
Definition: laserDesignatorStateComponent.h:230

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)