VR-Forces Developer's Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
groundVehicleLightingStateComponent.h
Go to the documentation of this file.
1 /*******************************************************************************
2 ** Copyright (c) 2023 MAK Technologies, Inc.
3 ** All rights reserved.
4 *******************************************************************************/
5 
6 #pragma once
7 
10 #include "legionDataStore/writeStateInstance.h"
11 
12 #include <vlutil/vlString.h>
13 
14 namespace makVrf
15 {
17  {
21  , myEmergencyLightsOn(false)
22  {};
23 
25  {
29  }
30 
32  {
36 
37  return *this;
38  }
39 
40  DEFINE_ACCESSOR_MUTATOR(bool, leftIndicatorLightsOn, LeftIndicatorLightsOn)
41  DEFINE_ACCESSOR_MUTATOR(bool, rightIndicatorLightsOn, RightIndicatorLightsOn)
42  DEFINE_ACCESSOR_MUTATOR(bool, emergencyLightsOn, EmergencyLightsOn)
43 
44  protected:
48  };
49 
53  {
54  public:
56 
58  : DtFrameStateInterface(storage)
59  {
60  }
61 
62  UNDEFINED_RETURNVALUE_ACCESSOR_MUTATOR(bool, leftIndicatorLightsOn, LeftIndicatorLightsOn)
63  UNDEFINED_RETURNVALUE_ACCESSOR_MUTATOR(bool, rightIndicatorLightsOn, RightIndicatorLightsOn)
64  UNDEFINED_RETURNVALUE_ACCESSOR_MUTATOR(bool, emergencyLightsOn, EmergencyLightsOn)
65 
66  };
67 
70  {
71  public:
74 
77  const DtGroundVehicleLightingStateComponentData& frameState() const { return myData; };
79 
80  const bool leftIndicatorLightsOn() const;
81  void setLeftIndicatorLightsOn(const bool&);
82 
83  const bool rightIndicatorLightsOn() const;
84  void setRightIndicatorLightsOn(const bool&);
85 
86  const bool emergencyLightsOn() const;
87  void setEmergencyLightsOn(const bool&);
88 
90  virtual void makeWritable() {};
91 
93  virtual void makeReadOnly() {};
94 
95 
96  protected:
97  DtStateData* myStateData;
99  };
100 
103  {
104  public:
105 
108 
110  const DtGroundVehicleLightingStateComponentData& frameState() const { return myData; };
111 
112  const bool leftIndicatorLightsOn() const;
113  const bool rightIndicatorLightsOn() const;
114  const bool emergencyLightsOn() const;
115 
116  friend class DtGroundVehicleLightingStateImplementation;
118  {
119  myData = data;
120  }
121 
122  protected:
125  };
126 
130  {
131  public:
133 
134  bool isDoubleBuffered() { return true; };
135  const DtFrameStateInterface* currentFrameState() const { return &myCurrentFrameState; }
136  virtual DtFrameStateInterface* nextFrameState() { return &myNextFrameState; };
137  virtual const DtFrameStateInterface* nextFrameState() const { return &myNextFrameState; };
138 
140  {
141  if (myNextFrameState.isWritable())
142  {
143  myCurrentFrameState.advanceFrame(myNextFrameState.frameState());
144  }
145 
146  myCurrentFrameState.emitComponentUpdated();
147  }
148 
150  {
151  myCurrentFrameState.updateStateData(sd);
152  myNextFrameState.updateStateData(sd);
153  }
154 
155  virtual void aboutToBeDeleted() override
156  {
158  myCurrentFrameState.aboutToBeDeleted();
159  myNextFrameState.aboutToBeDeleted();
160  }
161 
162  protected:
165  };
166 
170 }
const DtGroundVehicleLightingStateComponentData & frameState() const
Current frame state only can access current frame buffers. This ensures thread safety.
Definition: groundVehicleLightingStateComponent.h:110
const DtFrameStateInterface * currentFrameState() const
Definition: groundVehicleLightingStateComponent.h:135
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: groundVehicleLightingStateComponent.h:52
bool myLeftIndicatorLightsOn
Definition: groundVehicleLightingStateComponent.h:45
DtGroundVehicleLightingStateComponentData & operator=(const DtGroundVehicleLightingStateComponentData &orig)
Definition: groundVehicleLightingStateComponent.h:31
bool myRightIndicatorLightsOn
Definition: groundVehicleLightingStateComponent.h:46
virtual void makeWritable()
Override to make component writable.
Definition: groundVehicleLightingStateComponent.h:90
Definition: stateComponent.h:266
DtGroundVehicleLightingStateComponentCurrentFrame myCurrentFrameState
Definition: groundVehicleLightingStateComponent.h:163
4) Define the state component that will contain the wrappers to the next and current frame states tha...
Definition: groundVehicleLightingStateComponent.h:129
bool isDoubleBuffered()
Definition: groundVehicleLightingStateComponent.h:134
virtual void aboutToBeDeleted() override
Definition: groundVehicleLightingStateComponent.h:155
const DtGroundVehicleLightingStateComponentData & frameState() const
Next frame access write access. Ensure this is only used in a single thread (i.e.a controller thread)...
Definition: groundVehicleLightingStateComponent.h:77
void advanceFrame(const DtGroundVehicleLightingStateComponentData &data)
Definition: groundVehicleLightingStateComponent.h:117
bool myEmergencyLightsOn
Definition: groundVehicleLightingStateComponent.h:47
DtStateComponentCreator< DtGroundVehicleLightingStateComponentImplementation > DtGroundVehicleLightingStateComponentCreator
5) Define the creator. This will need to be registered with the REGISTER_STATE_COMPONENT macro in the...
Definition: groundVehicleLightingStateComponent.h:169
The overall structure of the DtStateData mechanism is: The DtStateData contains a list of double buff...
Definition: stateData.h:339
virtual const DtFrameStateInterface * nextFrameState() const
Definition: groundVehicleLightingStateComponent.h:137
Definition: groundVehicleLightingStateComponent.h:16
#define DEFINE_STATE_COMPONENT_TYPE(CreatedComponent)
Definition: stateComponent.h:228
DtGroundVehicleLightingStateComponentData myData
Definition: groundVehicleLightingStateComponent.h:98
void updateStateData(DtStateData *sd)
Implement to update data storage to the new state data.
Definition: groundVehicleLightingStateComponent.h:149
Subclass from this to indicate that this will be a double buffered state component.
Definition: stateComponent.h:379
virtual DtFrameStateInterface * nextFrameState()
Definition: groundVehicleLightingStateComponent.h:136
void updateDataStorage()
Implement to update data storage. Called from advanceFrame.
Definition: groundVehicleLightingStateComponent.h:139
#define UNDEFINED_RETURNVALUE_ACCESSOR_MUTATOR(Type, Member, Set)
Definition: doubleBufferedDataStorage.h:53
virtual void aboutToBeDeleted()
3) Define the current frame class. This will be used for read access.
Definition: groundVehicleLightingStateComponent.h:102
2) Define the next frame class. This will be used for write access.
Definition: groundVehicleLightingStateComponent.h:69
#define DEFINE_ACCESSOR_MUTATOR(ReturnType, Accessor, Mutator)
Definition: doubleBufferedDataStorage.h:23
DtGroundVehicleLightingStateComponentData myData
Definition: groundVehicleLightingStateComponent.h:124
DtGroundVehicleLightingStateComponentData()
Definition: groundVehicleLightingStateComponent.h:18
DtGroundVehicleLightingStateComponentNextFrame myNextFrameState
Definition: groundVehicleLightingStateComponent.h:164
DtGroundVehicleLightingStateComponentData(const DtGroundVehicleLightingStateComponentData &orig)
Definition: groundVehicleLightingStateComponent.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
Contains the DtStateComponent class declaration.
DtGroundVehicleLightingStateComponentData & frameState()
Definition: groundVehicleLightingStateComponent.h:78
This is a simple base class that will be used to return a pointer to current or next frame state...
Definition: stateComponent.h:291
DtStateData * myStateData
Definition: groundVehicleLightingStateComponent.h:123

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)