VR-Forces Developer's Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
subsurfaceStateComponent.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 
12 #include <vrfutil/rwWindLevels.h>
13 
14 
15 
16 
17 namespace makVrf
18 {
19 
21  {
23  : myDepth(0.)
24  , myPermeability(0.)
25  {
26 
27  };
28  DtVrfSubsurfaceLayer(double depth, double permeability)
29  : myDepth(depth)
30  , myPermeability(permeability)
31  {
32 
33  };
35  {
36  *this = orig;
37  };
38 
40  {
41  {
42  myDepth = orig.myDepth;
43  myPermeability = orig.myPermeability;
44  }
45  return *this;
46  };
47 
48  bool operator<(const DtVrfSubsurfaceLayer& other) const
49  {
50  return myDepth < other.myDepth;
51  };
52 
53  bool operator==(const DtVrfSubsurfaceLayer& other) const
54  {
55  return (myDepth == other.myDepth
56  && myPermeability == other.myPermeability);
57  };
58  bool operator!=(const DtVrfSubsurfaceLayer& other) const
59  {
60  return !(*this == other);
61  };
62  ACCESSOR_MUTATOR_MEMBER(double, depth, Depth);
63  ACCESSOR_MUTATOR_MEMBER(double, permeability, Permeability);
64  };
65 
66  typedef std::multiset<DtVrfSubsurfaceLayer> DtVrfSubsurfaceLayerSet;
67 
68 
71  {
73  : myUnderwaterVisibility(0.)
74  , mySubsurfaceLayers()
75  , myAmbientWaterTemperature(0.)
76  , myPriority(0)
77  {};
78 
80  {
81  *this = orig;
82  };
83 
85  {
86  {
87  myUnderwaterVisibility = orig.myUnderwaterVisibility;
88  mySubsurfaceLayers = orig.mySubsurfaceLayers;
89  myAmbientWaterTemperature = orig.myAmbientWaterTemperature;
90  myPriority = orig.myPriority;
91  }
92  return *this;
93  };
94 
95  ACCESSOR_MUTATOR_MEMBER(double, underwaterVisibility, UnderwaterVisibility);
96  ACCESSOR_MUTATOR_MEMBER(DtVrfSubsurfaceLayerSet, subsurfaceLayers, SubsurfaceLayers);
97  ACCESSOR_MUTATOR_MEMBER(double, ambientWaterTemperature, AmbientWaterTemperature);
98  ACCESSOR_MUTATOR_MEMBER(int, priority, Priority);
99  };
100 
104  {
105  public:
107 
109  : DtFrameStateInterface(storage)
110  {
111  }
112 
113  UNDEFINED_RETURNVALUE_ACCESSOR_MUTATOR(double, underwaterVisibility, UnderwaterVisibility);
114  UNDEFINED_RETURNREF_ACCESSOR_MUTATOR(DtVrfSubsurfaceLayerSet, subsurfaceLayers, SubsurfaceLayers);
115  UNDEFINED_RETURNVALUE_ACCESSOR_MUTATOR(double, thermoclineLayer1Depth, ThermoclineLayer1Depth);
116  UNDEFINED_RETURNVALUE_ACCESSOR_MUTATOR(double, thermoclineLayer1Permeability, ThermoclineLayer1Permeability);
117  UNDEFINED_RETURNVALUE_ACCESSOR_MUTATOR(double, thermoclineLayer2Depth, ThermoclineLayer2Depth);
118  UNDEFINED_RETURNVALUE_ACCESSOR_MUTATOR(double, thermoclineLayer2Permeability, ThermoclineLayer2Permeability);
119  UNDEFINED_RETURNVALUE_ACCESSOR_MUTATOR(double, thermoclineLayer3Depth, ThermoclineLayer3Depth);
120  UNDEFINED_RETURNVALUE_ACCESSOR_MUTATOR(double, thermoclineLayer3Permeability, ThermoclineLayer3Permeability);
121  UNDEFINED_RETURNVALUE_ACCESSOR_MUTATOR(double, thermoclineLayer4Depth, ThermoclineLayer4Depth);
122  UNDEFINED_RETURNVALUE_ACCESSOR_MUTATOR(double, thermoclineLayer4Permeability, ThermoclineLayer4Permeability);
123  UNDEFINED_RETURNVALUE_ACCESSOR_MUTATOR(double, thermoclineLayer5Depth, ThermoclineLayer5Depth);
124  UNDEFINED_RETURNVALUE_ACCESSOR_MUTATOR(double, thermoclineLayer5Permeability, ThermoclineLayer5Permeability);
125  UNDEFINED_RETURNVALUE_ACCESSOR_MUTATOR(double, ambientWaterTemperature, AmbientWaterTemperature);
126  UNDEFINED_RETURNVALUE_ACCESSOR_MUTATOR(int, priority, Priority);
127 
128  virtual void addSubsurfaceLayer(const DtVrfSubsurfaceLayer& layerToAdd) { throw DtUnimplementedMethod("addSubsurfaceLayer is not implemented by this class."); };
129  virtual void removeSubsurfaceLayer(const DtVrfSubsurfaceLayer& layerToRemove) { throw DtUnimplementedMethod("removeSubsurfaceLayer is not implemented by this class."); };
130 
131  void setIsRemoteComponent(bool b) { myIsRemoteComponent = b; };
132 
133  protected:
134  bool myIsRemoteComponent = false;
135  };
136 
137 #define THERMOCLINE_GETTER(number, Accessor, Setter) \
138  const double thermoclineLayer##number####Setter() const override \
139  { \
140  const unsigned indexToUse = number - 1; \
141  DtVrfSubsurfaceLayer dummy; \
142  thermoclineLayer(indexToUse, dummy); \
143  return dummy.Accessor(); \
144  };
145 
146 #define THERMOCLINE_SETTER(number, Accessor, Setter) \
147  void setThermoclineLayer##number####Setter( const double& Accessor ) override \
148  { \
149  const unsigned indexToUse = number - 1; \
150  DtVrfSubsurfaceLayer dummy; \
151  thermoclineLayer(indexToUse, dummy); \
152  if (dummy.Accessor() != Accessor) \
153  { \
154  dummy.set##Setter(Accessor); \
155  markModified(); \
156  setThermoclineLayerByIndex(dummy, indexToUse); \
157  } \
158  };
159 
160 #define THERMOCLINE_SETTER_GETTER(number, Accessor, Setter) \
161  THERMOCLINE_GETTER(number, Accessor, Setter); \
162  THERMOCLINE_SETTER(number, Accessor, Setter);
163 
164 
165 
166 #define NEXTFRAME_ACCESSOR_MUTATOR_(MemberType, Accessor, MutatorAndMember) \
167  public: \
168  const MemberType Accessor() const override { return frameState().Accessor(); }; \
169  void set##MutatorAndMember(const MemberType& v) override { if (frameState().Accessor() != v) { markModified(); frameState().set##MutatorAndMember(v); } };
170 
172  class DT_DLL_vrfStateData DtSubsurfaceStateComponentNextFrame : public DtStateComponentNextFrameTemplate< DtSubsurfaceStateComponent, DtSubsurfaceStateComponentData >
173  {
174  public:
177  {
178 
179  };
181  {};
182 
183  NEXTFRAME_ACCESSOR_MUTATOR(double, underwaterVisibility, UnderwaterVisibility);
184  NEXTFRAME_ACCESSOR_BY_REF_MUTATOR(DtVrfSubsurfaceLayerSet, subsurfaceLayers, SubsurfaceLayers);
185  NEXTFRAME_ACCESSOR_MUTATOR(double, ambientWaterTemperature, AmbientWaterTemperature);
186  NEXTFRAME_ACCESSOR_MUTATOR(int, priority, Priority);
187 
188  THERMOCLINE_SETTER_GETTER(1, depth, Depth);
189  THERMOCLINE_SETTER_GETTER(1, permeability, Permeability);
190 
191  THERMOCLINE_SETTER_GETTER(2, depth, Depth);
192  THERMOCLINE_SETTER_GETTER(2, permeability, Permeability);
193 
194  THERMOCLINE_SETTER_GETTER(3, depth, Depth);
195  THERMOCLINE_SETTER_GETTER(3, permeability, Permeability);
196 
197  THERMOCLINE_SETTER_GETTER(4, depth, Depth);
198  THERMOCLINE_SETTER_GETTER(4, permeability, Permeability);
199 
200  THERMOCLINE_SETTER_GETTER(5, depth, Depth);
201  THERMOCLINE_SETTER_GETTER(5, permeability, Permeability);
202 
203  void addSubsurfaceLayer(const DtVrfSubsurfaceLayer& layerToAdd) override;
204  void removeSubsurfaceLayer(const DtVrfSubsurfaceLayer& layerToAdd) override;
205  protected:
206  bool thermoclineLayer(unsigned int index, DtVrfSubsurfaceLayer& layer) const;
207  bool removeThermoclineLayer(unsigned int index, DtVrfSubsurfaceLayer& layer);
208  void setThermoclineLayerByIndex(const DtVrfSubsurfaceLayer & layer, unsigned int index);;
209  };
210 
212  class DT_DLL_vrfStateData DtSubsurfaceStateComponentCurrentFrame : public DtStateComponentCurrentFrameTemplate< DtSubsurfaceStateComponent, DtSubsurfaceStateComponentNextFrame, DtSubsurfaceStateComponentData>
213  {
214  public:
217  {
218  };
219 
220  CURRENTFRAME_ACCESSOR(double, underwaterVisibility, UnderwaterVisibility);
221  CURRENTFRAME_ACCESSOR_BY_REF(DtVrfSubsurfaceLayerSet, subsurfaceLayers, SubsurfaceLayers);
222  CURRENTFRAME_ACCESSOR(double, ambientWaterTemperature, AmbientWaterTemperature);
223  CURRENTFRAME_ACCESSOR(int, priority, Priority);
224 
225 
226 
227  THERMOCLINE_GETTER(1, depth, Depth);
228  THERMOCLINE_GETTER(1, permeability, Permeability);
229 
230  THERMOCLINE_GETTER(2, depth, Depth);
231  THERMOCLINE_GETTER(2, permeability, Permeability);
232 
233  THERMOCLINE_GETTER(3, depth, Depth);
234  THERMOCLINE_GETTER(3, permeability, Permeability);
235 
236  THERMOCLINE_GETTER(4, depth, Depth);
237  THERMOCLINE_GETTER(4, permeability, Permeability);
238 
239  THERMOCLINE_GETTER(5, depth, Depth);
240  THERMOCLINE_GETTER(5, permeability, Permeability);
241 
242  protected:
243  bool thermoclineLayer(unsigned int index, DtVrfSubsurfaceLayer& layer) const;
244  };
245 
249 
253 
254 }
Definition: stateDataTypes.h:23
DtStateComponentImplementationTemplate< DtSubsurfaceStateComponent, DtSubsurfaceStateComponentCurrentFrame, DtSubsurfaceStateComponentNextFrame > DtSubsurfaceStateComponentImplementation
4) Define the state component that will contain the wrappers to the next and current frame states tha...
Definition: subsurfaceStateComponent.h:248
virtual void removeSubsurfaceLayer(const DtVrfSubsurfaceLayer &layerToRemove)
Definition: subsurfaceStateComponent.h:129
bool operator==(const DtVrfSubsurfaceLayer &other) const
Definition: subsurfaceStateComponent.h:53
DtVrfSubsurfaceLayer(const DtVrfSubsurfaceLayer &orig)
Definition: subsurfaceStateComponent.h:34
Definition: stateComponentImplementationTemplate.h:68
Definition: stateComponent.h:266
ACCESSOR_MUTATOR_MEMBER(double, underwaterVisibility, UnderwaterVisibility)
#define NEXTFRAME_ACCESSOR_BY_REF_MUTATOR(MemberType, Accessor, MutatorAndMember)
Definition: stateComponentImplementationTemplate.h:57
DtSubsurfaceStateComponentData()
Definition: subsurfaceStateComponent.h:72
DtVrfSubsurfaceLayer(double depth, double permeability)
Definition: subsurfaceStateComponent.h:28
virtual ~DtSubsurfaceStateComponentNextFrame()
Definition: subsurfaceStateComponent.h:180
#define THERMOCLINE_GETTER(number, Accessor, Setter)
Definition: subsurfaceStateComponent.h:137
0) Define the State Component Data. This struct replaces the legion stuff
Definition: subsurfaceStateComponent.h:70
#define CURRENTFRAME_ACCESSOR_BY_REF(MemberType, Accessor, MutatorAndMember)
Definition: stateComponentImplementationTemplate.h:64
#define CURRENTFRAME_ACCESSOR(MemberType, Accessor, MutatorAndMember)
Definition: stateComponentImplementationTemplate.h:61
bool operator<(const DtVrfSubsurfaceLayer &other) const
Definition: subsurfaceStateComponent.h:48
Definition: stateComponentImplementationTemplate.h:89
The overall structure of the DtStateData mechanism is: The DtStateData contains a list of double buff...
Definition: stateData.h:339
#define DEFINE_STATE_COMPONENT_TYPE(CreatedComponent)
Definition: stateComponent.h:228
#define NEXTFRAME_ACCESSOR_MUTATOR(MemberType, Accessor, MutatorAndMember)
Definition: stateComponentImplementationTemplate.h:49
DtSubsurfaceStateComponentCurrentFrame(DtStateData *sd)
Definition: subsurfaceStateComponent.h:215
2) Define the next frame class. This will be used for write access.
Definition: subsurfaceStateComponent.h:172
1) Define the interface class that will be used to represent the next and current frames...
Definition: subsurfaceStateComponent.h:103
DtVrfSubsurfaceLayer()
Definition: subsurfaceStateComponent.h:22
#define UNDEFINED_RETURNVALUE_ACCESSOR_MUTATOR(Type, Member, Set)
Definition: doubleBufferedDataStorage.h:53
DtSubsurfaceStateComponentNextFrame(DtStateData *sd)
Definition: subsurfaceStateComponent.h:175
DtStateComponentCreator< DtSubsurfaceStateComponentImplementation > DtSubsurfaceStateComponentCreator
5) Define the creator. This will need to be registered with the REGISTER_STATE_COMPONENT macro in the...
Definition: subsurfaceStateComponent.h:252
bool operator!=(const DtVrfSubsurfaceLayer &other) const
Definition: subsurfaceStateComponent.h:58
virtual void addSubsurfaceLayer(const DtVrfSubsurfaceLayer &layerToAdd)
Definition: subsurfaceStateComponent.h:128
#define UNDEFINED_RETURNREF_ACCESSOR_MUTATOR(Type, Member, Set)
Definition: doubleBufferedDataStorage.h:57
Definition: subsurfaceStateComponent.h:20
DtSubsurfaceStateComponentData & operator=(const DtSubsurfaceStateComponentData &orig)
Definition: subsurfaceStateComponent.h:84
#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
std::multiset< DtVrfSubsurfaceLayer > DtVrfSubsurfaceLayerSet
Definition: subsurfaceStateComponent.h:66
#define THERMOCLINE_SETTER_GETTER(number, Accessor, Setter)
Definition: subsurfaceStateComponent.h:160
3) Define the current frame class. This will be used for read access.
Definition: subsurfaceStateComponent.h:212
DtSubsurfaceStateComponentData(const DtSubsurfaceStateComponentData &orig)
Definition: subsurfaceStateComponent.h:79
Contains the DtStateComponent class declaration.
This is a simple base class that will be used to return a pointer to current or next frame state...
Definition: stateComponent.h:291
Definition: stateComponentImplementationTemplate.h:137
ACCESSOR_MUTATOR_MEMBER(double, depth, Depth)
DtVrfSubsurfaceLayer & operator=(const DtVrfSubsurfaceLayer &orig)
Definition: subsurfaceStateComponent.h:39
void setIsRemoteComponent(bool b)
Definition: subsurfaceStateComponent.h:131

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)