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;
55  int myPriority;
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  const double& width() const;
88  void setWidth(const double&);
89 
90  const double& height() const;
91  void setHeight(const double&);
92 
93  const std::vector<DtVector> worldPositions() const;
94  void setWorldPositions(const std::vector<DtVector>&);
95 
96  const double& windSpeed() const;
97  void setWindSpeed(const double&);
98 
99  const int& priority() const;
100  void setPriority(const int&);
101 
102  virtual void updateWindCorridorData();
103 
105  virtual void makeWritable() {};
106 
108  virtual void makeReadOnly() {};
109 
110  virtual void completeSetup();
111 
112  protected:
113  boost::signals2::scoped_connection myVrfStateComponentChangedConnection;
116  };
117 
120  {
121  public:
124 
126  const DtWindCorridorStateComponentData& frameState() const { return myData; };
127 
128  const double& width() const;
129  const double& height() const;
130  const std::vector<DtVector> worldPositions() const;
131  const double& windSpeed() const;
132  const int& priority() const;
133 
134  protected:
136  void completeSetup();
137 
138  protected:
139  void updateVrfStateComponentParameters();
140 
141  void updateWindCorridorData();
142 
145  {
146  myData = data;
147  }
148 
149  protected:
150  boost::signals2::scoped_connection myVrfStateComponentChangedConnection;
153  };
154 
158  {
159  public:
161 
162  bool isDoubleBuffered() { return true; };
163  const DtFrameStateInterface* currentFrameState() const { return &myCurrentFrameState; }
164  virtual DtFrameStateInterface* nextFrameState() { return &myNextFrameState; };
165  virtual const DtFrameStateInterface* nextFrameState() const { return &myNextFrameState; };
166 
167  virtual void completeSetup() override;
168 
170  {
171  if (myNextFrameState.isWritable())
172  {
173  myCurrentFrameState.advanceFrame(myNextFrameState.frameState());
174  }
175 
176  myCurrentFrameState.emitComponentUpdated();
177  }
178 
180  {
181  myCurrentFrameState.updateStateData(sd);
182  myNextFrameState.updateStateData(sd);
183  }
184 
185  virtual void aboutToBeDeleted() override
186  {
188  myCurrentFrameState.aboutToBeDeleted();
189  myNextFrameState.aboutToBeDeleted();
190  }
191 
192  protected:
195  };
196 
200 }
DtWindCorridorStateComponentData()
Definition: windCorridorStateComponent.h:17
std::vector< DtVector > myWorldPositions
Definition: windCorridorStateComponent.h:54
void updateDataStorage()
Implement to update data storage. Called from advanceFrame.
Definition: windCorridorStateComponent.h:169
const DtWindCorridorStateComponentData & frameState() const
Current frame state only can access current frame buffers. This ensures thread safety.
Definition: windCorridorStateComponent.h:126
virtual void makeReadOnly()
Override to make component read-only.
Definition: windCorridorStateComponent.h:108
Definition: stateComponent.h:266
double myWindSpeed
Definition: windCorridorStateComponent.h:51
DtWindCorridorStateComponentNextFrame myNextFrameState
Definition: windCorridorStateComponent.h:194
void updateStateData(DtStateData *sd)
Implement to update data storage to the new state data.
Definition: windCorridorStateComponent.h:179
double myHeight
Definition: windCorridorStateComponent.h:53
2) Define the next frame class. This will be used for write access.
Definition: windCorridorStateComponent.h:78
DtStateData * myStateData
Definition: windCorridorStateComponent.h:114
DtWindCorridorStateComponentData myData
Definition: windCorridorStateComponent.h:115
DtWindCorridorStateComponentCurrentFrame myCurrentFrameState
Definition: windCorridorStateComponent.h:193
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:339
boost::signals2::scoped_connection myVrfStateComponentChangedConnection
Definition: windCorridorStateComponent.h:150
#define DEFINE_STATE_COMPONENT_TYPE(CreatedComponent)
Definition: stateComponent.h:228
Subclass from this to indicate that this will be a double buffered state component.
Definition: stateComponent.h:379
virtual const DtFrameStateInterface * nextFrameState() const
Definition: windCorridorStateComponent.h:165
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 DtFrameStateInterface * nextFrameState()
Definition: windCorridorStateComponent.h:164
virtual void aboutToBeDeleted()
bool isDoubleBuffered()
Definition: windCorridorStateComponent.h:162
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:199
#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:152
DtStateData * myStateData
Definition: windCorridorStateComponent.h:151
const DtFrameStateInterface * currentFrameState() const
Definition: windCorridorStateComponent.h:163
void advanceFrame(const DtWindCorridorStateComponentData &data)
Definition: windCorridorStateComponent.h:144
#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:119
int myPriority
Definition: windCorridorStateComponent.h:55
virtual void aboutToBeDeleted() override
Definition: windCorridorStateComponent.h:185
virtual void makeWritable()
Override to make component writable.
Definition: windCorridorStateComponent.h:105
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:291
4) Define the state component that will contain the wrappers to the next and current frame states tha...
Definition: windCorridorStateComponent.h:157
boost::signals2::scoped_connection myVrfStateComponentChangedConnection
Definition: windCorridorStateComponent.h:113

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)