VR-Forces Developer's Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
windCorridorStateComponent.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 <vlutil/vlString.h>
11 #include <matrix/vlVector.h>
12 
13 namespace makVrf
14 {
16  {
18  : myWindSpeed(0.)
19  , myPriority(1)
20  , myWidth(0.)
21  , myHeight(0.)
22  {};
23 
25  {
26  myWindSpeed = orig.myWindSpeed;
27  myPriority = orig.myPriority;
28  myWidth = orig.myWidth;
29  myHeight = orig.myHeight;
30  myWorldPositions = orig.myWorldPositions;
31  }
32 
34  {
35  myWindSpeed = orig.myWindSpeed;
36  myPriority = orig.myPriority;
37  myWidth = orig.myWidth;
38  myHeight = orig.myHeight;
39  myWorldPositions = orig.myWorldPositions;
40 
41  return *this;
42  }
43 
44  DEFINE_ACCESSOR_MUTATOR(double, width, Width)
45  DEFINE_ACCESSOR_MUTATOR(double, height, Height)
46  DEFINE_ACCESSOR_MUTATOR(double, windSpeed, WindSpeed)
47  DEFINE_ACCESSOR_MUTATOR(std::vector<DtVector>, worldPositions, WorldPositions)
48  DEFINE_ACCESSOR_MUTATOR(int, priority, Priority)
49 
50  protected:
51  double myWindSpeed;
52  double myWidth;
53  double myHeight;
54  std::vector<DtVector> myWorldPositions{};
56  };
57 
61  {
62  public:
64 
66  : DtFrameStateInterface(storage)
67  {
68  }
69 
70  UNDEFINED_RETURNREF_ACCESSOR_MUTATOR(double, width, Width)
71  UNDEFINED_RETURNREF_ACCESSOR_MUTATOR(double, height, Height)
72  UNDEFINED_RETURNREF_ACCESSOR_MUTATOR(double, windSpeed, WindSpeed)
73  UNDEFINED_RETURNREF_ACCESSOR_MUTATOR(int, priority, Priority)
74  UNDEFINED_RETURNVALUE_ACCESSOR_MUTATOR(std::vector<DtVector>, worldPositions, WorldPositions)
75  };
76 
79  {
80  public:
82 
84  const DtWindCorridorStateComponentData& frameState() const { return myData; };
86 
87  virtual const double& width() const override;
88  virtual void setWidth(const double&) override;
89 
90  virtual const double& height() const override;
91  virtual void setHeight(const double&) override;
92 
93  virtual const std::vector<DtVector> worldPositions() const override;
94  virtual void setWorldPositions(const std::vector<DtVector>&) override;
95 
96  virtual const double& windSpeed() const override;
97  virtual void setWindSpeed(const double&) override;
98 
99  virtual const int& priority() const override;
100  virtual void setPriority(const int&) override;
101 
102  virtual void updateWindCorridorData();
103 
105  virtual void makeWritable() override {};
106 
108  virtual void makeReadOnly() override {};
109 
110  virtual void completeSetup();
111 
112  protected:
113  boost::signals2::scoped_connection myVrfStateComponentChangedConnection;
115  };
116 
119  {
120  public:
122  virtual ~DtWindCorridorStateComponentCurrentFrame() override;
123 
125  const DtWindCorridorStateComponentData& frameState() const { return myData; };
126 
127  virtual const double& width() const override;
128  virtual const double& height() const override;
129  virtual const std::vector<DtVector> worldPositions() const override;
130  virtual const double& windSpeed() const override;
131  virtual const int& priority() const override;
132 
133  protected:
135  void completeSetup();
136 
137  protected:
138  void updateVrfStateComponentParameters();
139 
140  void updateWindCorridorData();
141 
144  {
145  myData = data;
146  }
147 
148  protected:
149  boost::signals2::scoped_connection myVrfStateComponentChangedConnection;
151  };
152 
156  {
157  public:
159 
160  bool isDoubleBuffered() { return true; };
161  virtual const DtFrameStateInterface* currentFrameState() const override { return &myCurrentFrameState; }
162  virtual DtFrameStateInterface* nextFrameState() override { return &myNextFrameState; };
163  virtual const DtFrameStateInterface* nextFrameState() const override { return &myNextFrameState; };
164 
165  virtual void completeSetup() override;
166 
167  virtual void updateDataStorage() override
168  {
169  if (myNextFrameState.isWritable())
170  {
171  myCurrentFrameState.advanceFrame(myNextFrameState.frameState());
172  }
173 
174  myCurrentFrameState.emitComponentUpdated();
175  }
176 
177  virtual void updateStateData(DtStateData* sd) override
178  {
179  myCurrentFrameState.updateStateData(sd);
180  myNextFrameState.updateStateData(sd);
181  }
182 
183  virtual void aboutToBeDeleted() override
184  {
186  myCurrentFrameState.aboutToBeDeleted();
187  myNextFrameState.aboutToBeDeleted();
188  }
189 
190  protected:
193  };
194 
198 }
DtWindCorridorStateComponentData()
Definition: windCorridorStateComponent.h:17
virtual const DtFrameStateInterface * nextFrameState() const override
Definition: windCorridorStateComponent.h:163
std::vector< DtVector > myWorldPositions
Definition: windCorridorStateComponent.h:54
virtual void makeWritable() override
Override to make component writable.
Definition: windCorridorStateComponent.h:105
const DtWindCorridorStateComponentData & frameState() const
Current frame state only can access current frame buffers. This ensures thread safety.
Definition: windCorridorStateComponent.h:125
Definition: stateComponent.h:269
double myWindSpeed
Definition: windCorridorStateComponent.h:51
DtWindCorridorStateComponentNextFrame myNextFrameState
Definition: windCorridorStateComponent.h:192
virtual const DtFrameStateInterface * currentFrameState() const override
Definition: windCorridorStateComponent.h:161
double myHeight
Definition: windCorridorStateComponent.h:53
2) Define the next frame class. This will be used for write access.
Definition: windCorridorStateComponent.h:78
DtWindCorridorStateComponentData myData
Definition: windCorridorStateComponent.h:114
DtWindCorridorStateComponentCurrentFrame myCurrentFrameState
Definition: windCorridorStateComponent.h:191
DtWindCorridorStateComponentData & frameState()
Definition: windCorridorStateComponent.h:85
The overall structure of the DtStateData mechanism is: The DtStateData contains a list of double buff...
Definition: stateData.h:398
boost::signals2::scoped_connection myVrfStateComponentChangedConnection
Definition: windCorridorStateComponent.h:149
#define DEFINE_STATE_COMPONENT_TYPE(CreatedComponent)
Definition: stateComponent.h:231
Subclass from this to indicate that this will be a double buffered state component.
Definition: stateComponent.h:384
virtual DtFrameStateInterface * nextFrameState() override
Definition: windCorridorStateComponent.h:162
virtual void makeReadOnly() override
Override to make component read-only.
Definition: windCorridorStateComponent.h:108
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: windCorridorStateComponent.h:60
#define UNDEFINED_RETURNVALUE_ACCESSOR_MUTATOR(Type, Member, Set)
Definition: doubleBufferedDataStorage.h:53
virtual void updateStateData(DtStateData *sd) override
Implement to update data storage to the new state data.
Definition: windCorridorStateComponent.h:177
virtual void aboutToBeDeleted()
bool isDoubleBuffered()
Definition: windCorridorStateComponent.h:160
Definition: windCorridorStateComponent.h:15
DtWindCorridorStateComponentData(const DtWindCorridorStateComponentData &orig)
Definition: windCorridorStateComponent.h:24
const DtWindCorridorStateComponentData & frameState() const
Next frame access write access. Ensure this is only used in a single thread (i.e.a controller thread)...
Definition: windCorridorStateComponent.h:84
DtStateComponentCreator< DtWindCorridorStateComponentImplementation > DtWindCorridorStateComponentCreator
5) Define the creator. This will need to be registered with the REGISTER_STATE_COMPONENT macro in the...
Definition: windCorridorStateComponent.h:197
#define UNDEFINED_RETURNREF_ACCESSOR_MUTATOR(Type, Member, Set)
Definition: doubleBufferedDataStorage.h:57
#define DEFINE_ACCESSOR_MUTATOR(ReturnType, Accessor, Mutator)
Definition: doubleBufferedDataStorage.h:23
DtWindCorridorStateComponentData myData
Definition: windCorridorStateComponent.h:150
virtual void updateDataStorage() override
Implement to update data storage. Called from advanceFrame.
Definition: windCorridorStateComponent.h:167
void advanceFrame(const DtWindCorridorStateComponentData &data)
Definition: windCorridorStateComponent.h:143
#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
3) Define the current frame class. This will be used for read access.
Definition: windCorridorStateComponent.h:118
int myPriority
Definition: windCorridorStateComponent.h:55
virtual void aboutToBeDeleted() override
Definition: windCorridorStateComponent.h:183
DtWindCorridorStateComponentData & operator=(const DtWindCorridorStateComponentData &orig)
Definition: windCorridorStateComponent.h:33
Contains the DtStateComponent class declaration.
double myWidth
Definition: windCorridorStateComponent.h:52
This is a simple base class that will be used to return a pointer to current or next frame state...
Definition: stateComponent.h:294
4) Define the state component that will contain the wrappers to the next and current frame states tha...
Definition: windCorridorStateComponent.h:155
boost::signals2::scoped_connection myVrfStateComponentChangedConnection
Definition: windCorridorStateComponent.h:113

Document ID: Generated on Thu Oct 23 22:29:17 EDT 2025 from SVN revision 280951
Copyright © 2005-2024 MAK Technologies. All Rights Reserved (www.mak.com)