VR-Forces Developer's Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
exampleEmbeddedSystemStateComponent.h
Go to the documentation of this file.
1 //******************************************************************************
2 // Copyright (c) 2025 MAK Technologies, Inc.
3 // All rights reserved.
4 //******************************************************************************
5 
6 #pragma once
7 
10 #include <matrix/vlVector.h>
11 #include <vrfutil/uuid.h>
12 
13 namespace makVrf
14 {
18  {
21  : myHostId(DtUUID::nullUUID())
22  , mySystemId(0)
23  , myModelNumber(0)
24  {};
25 
29  : myHostId(orig.myHostId)
30  , mySystemId(orig.mySystemId)
32  {
33  }
34 
39  {
40  myHostId = orig.myHostId;
41  mySystemId = orig.mySystemId;
43 
44  return *this;
45  }
46 
48  DEFINE_ACCESSOR_MUTATOR(DtUUID, hostId, HostId)
50  DEFINE_ACCESSOR_MUTATOR(unsigned, systemId, SystemId)
52  DEFINE_ACCESSOR_MUTATOR(unsigned, modelNumber, ModelNumber)
53 
54  protected:
56  unsigned mySystemId;
57  unsigned myModelNumber;
58  };
59 
61  const unsigned int ExampleEmbeddedSystemStateComponent = 166;
62 
66  {
67  public:
69  DEFINE_STATE_COMPONENT_TYPE(ExampleEmbeddedSystemStateComponent)
70 
71 
74  : DtFrameStateInterface(storage)
75  {
76  }
77 
81  UNDEFINED_RETURNVALUE_ACCESSOR_MUTATOR(unsigned, systemId, SystemId)
83  UNDEFINED_RETURNVALUE_ACCESSOR_MUTATOR(unsigned, modelNumber, ModelNumber)
84  };
85 
89  {
90  public:
94 
97 
100  const DtExampleEmbeddedSystemStateComponentData& frameState() const { return myData; };
101 
105 
107 
110 
113  const DtUUID& hostId() const;
114 
117  void setHostId(const DtUUID& uuid);
118 
120 
123 
126  const unsigned systemId() const;
127 
130  void setSystemId(const unsigned& id);
131 
133 
136 
139  const unsigned modelNumber() const;
140 
143  void setModelNumber(const unsigned& mn);
144 
146 
149 
151  virtual void makeWritable() {};
152 
154  virtual void makeReadOnly() {};
155 
157 
158  protected:
161  };
162 
166  {
167  public:
171 
174  const DtExampleEmbeddedSystemStateComponentData& frameState() const { return myData; };
175 
178 
181  const DtUUID& hostId() const;
182 
185  const unsigned systemId() const;
186 
189  const unsigned modelNumber() const;
190 
192 
193  protected:
196 
200  {
201  myData = data;
202  }
203 
205  virtual void handleDataUpdated();
206 
207  protected:
210  };
211 
214  class DtExampleEmbeddedSystemStateComponentImplementation : public DtDoubleBufferedStateComponent<DtExampleEmbeddedSystemStateComponent>
215  {
216  public:
220 
223 
226  bool isDoubleBuffered() { return true; };
227 
230  const DtFrameStateInterface* currentFrameState() const { return &myCurrentFrameState; }
231 
234  virtual DtFrameStateInterface* nextFrameState() { return &myNextFrameState; };
235 
238  virtual const DtFrameStateInterface* nextFrameState() const { return &myNextFrameState; };
239 
241 
244 
247  {
248  if (myNextFrameState.isWritable())
249  {
250  myCurrentFrameState.advanceFrame(myNextFrameState.frameState());
251  }
252  myCurrentFrameState.emitComponentUpdated();
253  }
254 
258  {
259  myCurrentFrameState.updateStateData(sd);
260  myNextFrameState.updateStateData(sd);
261  }
262 
264 
267 
269  virtual void aboutToBeDeleted() override
270  {
272  myCurrentFrameState.aboutToBeDeleted();
273  myNextFrameState.aboutToBeDeleted();
274  }
275 
277 
278  protected:
281 
284  };
285 
288 }
289 
UUID is a unique ID wrapper class.
Definition: uuid.h:59
void updateStateData(DtStateData *sd)
Updates the state data reference for both frame instances.
Definition: exampleEmbeddedSystemStateComponent.h:257
DtUUID myHostId
Generates accessor/mutator methods for hostId.
Definition: exampleEmbeddedSystemStateComponent.h:55
DtExampleEmbeddedSystemStateComponentData & operator=(const DtExampleEmbeddedSystemStateComponentData &orig)
Assignment operator.
Definition: exampleEmbeddedSystemStateComponent.h:38
const DtExampleEmbeddedSystemStateComponentData & frameState() const
Provides read-only access to the complete current frame state data.
Definition: exampleEmbeddedSystemStateComponent.h:174
Default creator implementation for a state component type. T_StateComponent is the concrete component...
Definition: stateComponent.h:326
DtExampleEmbeddedSystemStateComponentCurrentFrame myCurrentFrameState
Current frame state instance (read-only access)
Definition: exampleEmbeddedSystemStateComponent.h:280
Contains the DtUUID class declaration.
unsigned mySystemId
Unique identifier of this embedded system.
Definition: exampleEmbeddedSystemStateComponent.h:56
const DtExampleEmbeddedSystemStateComponentData & frameState() const
Provides read-only access to the complete frame state data.
Definition: exampleEmbeddedSystemStateComponent.h:100
Next frame class providing write access to embedded system state. Used by controller components to up...
Definition: exampleEmbeddedSystemStateComponent.h:88
DtExampleEmbeddedSystemStateComponentData myData
Internal storage for the current frame state data.
Definition: exampleEmbeddedSystemStateComponent.h:209
Implementation class that manages the double-buffered state component. Maintains both current frame a...
Definition: exampleEmbeddedSystemStateComponent.h:214
DtExampleEmbeddedSystemStateComponentData()
Default constructor - initializes all fields to default values.
Definition: exampleEmbeddedSystemStateComponent.h:20
DtExampleEmbeddedSystemStateComponentData & frameState()
Provides read-write access to the complete frame state data.
Definition: exampleEmbeddedSystemStateComponent.h:104
virtual void aboutToBeDeleted() override
Called when the component is about to be deleted.
Definition: exampleEmbeddedSystemStateComponent.h:269
The overall structure of the DtStateData mechanism is: The DtStateData contains a list of double buff...
Definition: stateData.h:513
bool isDoubleBuffered()
Indicates this component uses double buffering.
Definition: exampleEmbeddedSystemStateComponent.h:226
#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
virtual DtFrameStateInterface * nextFrameState()
Provides access to the next (read-write) frame state.
Definition: exampleEmbeddedSystemStateComponent.h:234
Subclass from this to indicate that this will be a double buffered state component.
Definition: stateComponent.h:489
Current frame class providing read-only access to embedded system state. Used by systems to read the ...
Definition: exampleEmbeddedSystemStateComponent.h:165
virtual void makeWritable()
Override to enable write access to this component.
Definition: exampleEmbeddedSystemStateComponent.h:151
#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
void advanceFrame(const DtExampleEmbeddedSystemStateComponentData &data)
Advances the current frame data with new state from next frame.
Definition: exampleEmbeddedSystemStateComponent.h:199
virtual void aboutToBeDeleted()
Called when the component is about to be deleted; emits signal_stateComponentAboutToBeDeleted.
const unsigned int ExampleEmbeddedSystemStateComponent
Unique component type identifier for the example embedded system state component. ...
Definition: exampleEmbeddedSystemStateComponent.h:61
#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
DtExampleEmbeddedSystemStateComponentData(const DtExampleEmbeddedSystemStateComponentData &orig)
Copy constructor.
Definition: exampleEmbeddedSystemStateComponent.h:28
Data structure containing all state information for an example embedded system. Holds host ID...
Definition: exampleEmbeddedSystemStateComponent.h:17
Base interface class for the example embedded system state component. Defines the common interface us...
Definition: exampleEmbeddedSystemStateComponent.h:65
const DtFrameStateInterface * currentFrameState() const
Provides access to the current (read-only) frame state.
Definition: exampleEmbeddedSystemStateComponent.h:230
DtExampleEmbeddedSystemStateComponentNextFrame myNextFrameState
Next frame state instance (read-write access)
Definition: exampleEmbeddedSystemStateComponent.h:283
void updateDataStorage()
Updates the data storage by advancing current frame with next frame data.
Definition: exampleEmbeddedSystemStateComponent.h:246
unsigned myModelNumber
Model/type identifier for this system.
Definition: exampleEmbeddedSystemStateComponent.h:57
DtStateComponentCreator< DtExampleEmbeddedSystemStateComponentImplementation > DtExampleEmbeddedSystemStateComponentCreator
Factory creator for the example embedded system state component.
Definition: exampleEmbeddedSystemStateComponent.h:287
Contains the DtStateComponent class declaration.
virtual const DtFrameStateInterface * nextFrameState() const
Provides const access to the next frame state.
Definition: exampleEmbeddedSystemStateComponent.h:238
Base interface for accessing current or next frame state in a double-buffered state component...
Definition: stateComponent.h:354

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)