VR-Forces Developer's Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
iffStateComponent.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 
12 #include <vrfutil/rwUUID.h>
13 
14 #include <vlutil/vlString.h>
15 #include <matrix/vlVector.h>
16 
17 namespace makVrf
18 {
23  {
26  : myModeSettingsList("mode-settings")
27  , myHostId(DtUUID::nullUUID())
28  {
29  }
30 
33  : myModeSettingsList(orig.myModeSettingsList)
34  , myHostId(orig.myHostId)
35  {
36  }
37 
40  {
41  myModeSettingsList = rhs.myModeSettingsList;
42  myHostId = rhs.myHostId;
43 
44  return *this;
45  }
46 
50  bool hasModeSetting(int i) const
51  {
52  return myModeSettingsList.hasModeSetting(i);
53  }
54 
58  const DtIffModeSetting* modeSetting(int i) const
59  {
60  return myModeSettingsList.modeSetting(i);
61  }
62 
67  {
68  return myModeSettingsList.modeSetting(i);
69  }
70 
73  std::vector<DtModeType> enabledModes() const
74  {
75  return myModeSettingsList.enabledModes();
76  }
77 
80  {
81  return myModeSettingsList;
82  }
83 
86  {
87  return myModeSettingsList;
88  }
89 
91  DEFINE_ACCESSOR_MUTATOR(DtUUID, hostId, HostId)
92 
93  protected:
95  DtIffModeSettingsList myModeSettingsList;
97  DtUUID myHostId;
98  };
99 
103  {
104  public:
106 
107 
110  : DtFrameStateInterface(sd)
111  {
112  }
113 
115  virtual const DtIffModeSetting* modeSetting(int) const { throw DtUnimplementedMethod("The const DtIffModeSetting* modeSetting(int) const method is unimplemented"); };
117  virtual DtIffModeSetting* modeSetting(int) { throw DtUnimplementedMethod("The DtIffModeSetting* modeSetting(int) method is unimplemented"); };
119  virtual void setEnabledModes(const std::vector<DtModeType>&) { throw DtUnimplementedMethod("The void setEnabledModes(const std::vector<DtModeType>&) method is unimplemented"); };
121  virtual std::vector<DtModeType> enabledModes() const { throw DtUnimplementedMethod("The std::vector<DtModeType> enabledModes() const) method is unimplemented"); };
123  virtual bool anyModeIsOn() const { throw DtUnimplementedMethod("The bool anyModeIsOn() const method is unimplemented"); };
125  virtual bool modeIsOn(DtModeType) const { throw DtUnimplementedMethod("The bool modeIsOn(DtModeType) const method is unimplemented"); };
127  virtual bool hasModeSetting(DtModeType) const { throw DtUnimplementedMethod("The bool hasModeSetting(DtModeType) const method is unimplemented"); };
132 
136  virtual bool canHaveModeCodeSet(DtModeType modeType) const
137  {
138  return CAN_HAVE_CODES_SET(modeType);
139  }
140  };
141 
144  {
145  public:
149 
151  virtual const DtIffModeSetting* modeSetting(int) const override;
153  virtual DtIffModeSetting* modeSetting(int) override;
154 
156  virtual void setEnabledModes(const std::vector<DtModeType>&) override;
158  virtual std::vector<DtModeType> enabledModes() const override;
160  virtual bool anyModeIsOn() const override;
162  virtual bool modeIsOn(DtModeType) const override;
164  virtual bool hasModeSetting(DtModeType) const override;
165 
167  const DtIffStateComponentData& frameState() const { return myData; };
168  DtIffStateComponentData& frameState() { return myData; };
169 
171  virtual const DtUUID& hostId() const override;
174  virtual void setHostId(const DtUUID&) override;
176  virtual const DtIffModeSettingsList& modeSettings() const override;
177 
179  virtual void makeWritable() override {};
180 
182  virtual void makeReadOnly() override {};
183 
184  protected:
187  };
188 
191  {
192  public:
196 
198  const DtIffStateComponentData& frameState() const { return myData; };
199 
201  virtual bool anyModeIsOn() const override;
203  virtual const DtIffModeSetting* modeSetting(int) const override;
205  virtual std::vector<DtModeType> enabledModes() const override;
207  virtual const DtUUID& hostId() const override;
209  virtual const DtIffModeSettingsList& modeSettings() const override;
211  virtual bool modeIsOn(DtModeType) const override;
213  virtual bool hasModeSetting(DtModeType) const override;
214 
215  protected:
220  {
221  myData = data;
222  }
223 
224  protected:
227  };
228 
232  {
233  public:
237 
239  bool isDoubleBuffered() { return true; };
241  virtual const DtFrameStateInterface* currentFrameState() const override { return &myCurrentFrameState; }
243  virtual DtFrameStateInterface* nextFrameState() override { return &myNextFrameState; };
245  virtual const DtFrameStateInterface* nextFrameState() const override { return &myNextFrameState; };
246 
248  virtual void updateDataStorage() override
249  {
250  if (myNextFrameState.isWritable())
251  {
252  myCurrentFrameState.advanceFrame(myNextFrameState.frameState());
253  }
254 
255  myCurrentFrameState.emitComponentUpdated();
256  }
257 
260  virtual void updateStateData(DtStateData* sd) override
261  {
262  myCurrentFrameState.updateStateData(sd);
263  myNextFrameState.updateStateData(sd);
264  }
265 
267  virtual void aboutToBeDeleted() override
268  {
270  myCurrentFrameState.aboutToBeDeleted();
271  myNextFrameState.aboutToBeDeleted();
272  }
273 
274  protected:
279  };
280 
284 }
DtIffModeSettingsList & modeSettings()
Returns a mutable reference to the IFF mode settings list.
Definition: iffStateComponent.h:79
UUID is a unique ID wrapper class.
Definition: uuid.h:59
virtual bool modeIsOn(DtModeType) const
Returns true if the specified IFF mode is currently on.
Definition: iffStateComponent.h:125
Exception thrown when a required method has not been implemented.
Definition: stateDataTypes.h:30
DtIffStateComponentData()
Default modes to be enabled mimic current VRL mode enabled.
Definition: iffStateComponent.h:25
DtIffStateComponentNextFrame myNextFrameState
The next-frame IFF state sub-component (writable from the controller thread).
Definition: iffStateComponent.h:278
const DtIffStateComponentData & frameState() const
Next frame access write access. Ensure this is only used in a single thread (i.e.a controller thread)...
Definition: iffStateComponent.h:167
DtStateComponentCreator< DtIffStateComponentImplementation > DtIffStateComponentCreator
5) Define the creator. This will need to be registered with the REGISTER_STATE_COMPONENT macro in the...
Definition: iffStateComponent.h:283
std::vector< DtModeType > enabledModes() const
Returns the list of currently enabled IFF mode types.
Definition: iffStateComponent.h:73
virtual std::vector< DtModeType > enabledModes() const
Returns the list of currently enabled IFF mode types.
Definition: iffStateComponent.h:121
virtual bool hasModeSetting(DtModeType) const
Returns true if a mode setting for the specified mode type exists.
Definition: iffStateComponent.h:127
virtual DtFrameStateInterface * nextFrameState() override
Returns the next-frame state interface for modification.
Definition: iffStateComponent.h:243
Default creator implementation for a state component type. T_StateComponent is the concrete component...
Definition: stateComponent.h:326
virtual bool anyModeIsOn() const
Returns true if any IFF mode is currently on.
Definition: iffStateComponent.h:123
bool isDoubleBuffered()
Returns true to indicate this component uses double-buffered storage.
Definition: iffStateComponent.h:239
bool hasModeSetting(int i) const
Returns true if a mode setting for mode index i exists.
Definition: iffStateComponent.h:50
virtual const DtFrameStateInterface * currentFrameState() const override
Returns the current-frame state interface.
Definition: iffStateComponent.h:241
const DtIffModeSettingsList & modeSettings() const
Returns a const reference to the IFF mode settings list.
Definition: iffStateComponent.h:85
2) Define the next frame class. This will be used for write access.
Definition: iffStateComponent.h:143
3) Define the current frame class. This will be used for read access.
Definition: iffStateComponent.h:190
Contains the DtUUID class declaration.
#define UNDEFINED_RETURNREF_ACCESSOR(ReturnType, Member)
Defines a virtual const reference accessor that throws DtUnimplementedMethod, marking the method as r...
Definition: doubleBufferedDataStorage.h:60
DtIffModeSettingsList myModeSettingsList
Accessor and mutator for the host entity UUID.
Definition: iffStateComponent.h:95
DtIffStateComponentCurrentFrame myCurrentFrameState
The current-frame IFF state sub-component (read-only, updated each frame).
Definition: iffStateComponent.h:276
Definition: stateComponent.h:86
virtual void makeWritable() override
Override to make component writable.
Definition: iffStateComponent.h:179
DtUUID myHostId
UUID of the host entity associated with this IFF state.
Definition: iffStateComponent.h:97
DtIffModeSetting * modeSetting(int i)
Returns a mutable pointer to the mode setting for mode index i, or nullptr if not found...
Definition: iffStateComponent.h:66
virtual void updateDataStorage() override
Advances the current frame from the next frame if writable, then emits the component-updated signal...
Definition: iffStateComponent.h:248
virtual void aboutToBeDeleted() override
Notifies this component and its sub-components that the owning entity is about to be deleted...
Definition: iffStateComponent.h:267
The overall structure of the DtStateData mechanism is: The DtStateData contains a list of double buff...
Definition: stateData.h:513
virtual const DtIffModeSetting * modeSetting(int) const
Returns a const pointer to the mode setting for the given mode index.
Definition: iffStateComponent.h:115
Definition: iffModeSettings.h:89
#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
Definition: iffModeSettings.h:125
virtual void updateStateData(DtStateData *sd) override
Updates the state data pointer on both current and next frame sub-components.
Definition: iffStateComponent.h:260
Subclass from this to indicate that this will be a double buffered state component.
Definition: stateComponent.h:489
#define CAN_HAVE_CODES_SET(modeType)
Definition: iffModeSettings.h:51
const DtIffModeSetting * modeSetting(int i) const
Returns a const pointer to the mode setting for mode index i, or nullptr if not found.
Definition: iffStateComponent.h:58
Data container for the IFF (Identification Friend or Foe) state of an entity. Holds a list of IFF mod...
Definition: iffStateComponent.h:22
4) Define the state component that will contain the wrappers to the next and current frame states tha...
Definition: iffStateComponent.h:231
virtual void aboutToBeDeleted()
Called when the component is about to be deleted; emits signal_stateComponentAboutToBeDeleted.
virtual DtIffModeSetting * modeSetting(int)
Returns a mutable pointer to the mode setting for the given mode index.
Definition: iffStateComponent.h:117
const DtIffStateComponentData & frameState() const
Current frame state only can access current frame buffers. This ensures thread safety.
Definition: iffStateComponent.h:198
#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
DtIffStateComponentData(const DtIffStateComponentData &orig)
Copy constructor.
Definition: iffStateComponent.h:32
DtIffStateComponentData & operator=(const DtIffStateComponentData &rhs)
Assignment operator.
Definition: iffStateComponent.h:39
virtual const DtFrameStateInterface * nextFrameState() const override
Returns the next-frame state interface (const overload).
Definition: iffStateComponent.h:245
#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
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: iffStateComponent.h:102
void advanceFrame(const DtIffStateComponentData &data)
Advances the current frame by copying IFF state data from the next frame.
Definition: iffStateComponent.h:219
Contains the DtStateComponent class declaration.
DtIffStateComponentData & frameState()
Definition: iffStateComponent.h:168
virtual void setEnabledModes(const std::vector< DtModeType > &)
Enables the specified IFF modes.
Definition: iffStateComponent.h:119
Base interface for accessing current or next frame state in a double-buffered state component...
Definition: stateComponent.h:354
DtIffStateComponentData myData
The read-only IFF state data for the current frame.
Definition: iffStateComponent.h:226

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)