VR-Forces 5.0.2 Developer's Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
globalEnvironmentStateComponent.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 <vlpi/netStructs.h>
11 #include <vlutil/vlString.h>
13 #include "legionDataStore/writeStateInstance.h"
14 #include "legionDataStore/readStateInstance.h"
15 #include "vrfOM/sets/writeSimulationDateTimeRepository.hpp"
16 #include "vrfOM/sets/readSimulationDateTimeRepository.hpp"
17 
18 namespace makVrf
19 {
21  {
23  {
24  myScenarioStartTimeAtLocalOnFirstObjectCreationToTime = 36000;
25  myUpdateWhenTimeChangedBy = 60.;
26  myDateAndTimeOfDay = 43200.0;
27  myScenarioStartTimeIsLocal = true;
28  }
29 
31  {
32  myScenarioStartTimeAtLocalOnFirstObjectCreationToTime = orig.myScenarioStartTimeAtLocalOnFirstObjectCreationToTime;
33  myUpdateWhenTimeChangedBy = orig.myUpdateWhenTimeChangedBy;
34  myDateAndTimeOfDay = orig.myDateAndTimeOfDay;
35  myScenarioStartTimeIsLocal = orig.myScenarioStartTimeIsLocal;
36  }
37 
39  {
40  myScenarioStartTimeAtLocalOnFirstObjectCreationToTime = rhs.myScenarioStartTimeAtLocalOnFirstObjectCreationToTime;
41  myUpdateWhenTimeChangedBy = rhs.myUpdateWhenTimeChangedBy;
42  myDateAndTimeOfDay = rhs.myDateAndTimeOfDay;
43  myScenarioStartTimeIsLocal = rhs.myScenarioStartTimeIsLocal;
44  return *this;
45  }
46 
48  {
49  return (myDateAndTimeOfDay != 43200.0);
50  }
51 
52  DEFINE_ACCESSOR_MUTATOR(double, updateWhenTimeChangedBy, UpdateWhenTimeChangedBy)
53  DEFINE_ACCESSOR_MUTATOR(double, dateAndTimeOfDay, DateAndTimeOfDay)
54  DEFINE_ACCESSOR_MUTATOR(int, scenarioStartTimeAtLocalOnFirstObjectCreationToTime, ScenarioStartTimeAtLocalOnFirstObjectCreationToTime)
55  DEFINE_ACCESSOR_MUTATOR(bool, scenarioStartTimeIsLocal, ScenarioStartTimeIsLocal)
56 
57  protected:
58  int myScenarioStartTimeAtLocalOnFirstObjectCreationToTime;
59  double myUpdateWhenTimeChangedBy;
60  double myDateAndTimeOfDay;
61 
64  bool myScenarioStartTimeIsLocal;
65  };
66 
70  {
71  public:
73 
75  : DtFrameStateInterface(storage)
76  {
77  }
78 
79  UNDEFINED_RETURNVALUE_ACCESSOR_MUTATOR(double, updateWhenTimeChangedBy, UpdateWhenTimeChangedBy)
80  UNDEFINED_RETURNVALUE_ACCESSOR(double, dateAndTimeOfDay)
81  UNDEFINED_RETURNVALUE_ACCESSOR_MUTATOR(double, timeOfDayAdvancementSpeed, TimeOfDayAdvancementSpeed)
82  UNDEFINED_RETURNVALUE_ACCESSOR_MUTATOR(bool, useDayNightIlluminationModel, UseDayNightIlluminationModel)
83  UNDEFINED_RETURNVALUE_ACCESSOR_MUTATOR(int, scenarioStartTimeAtLocalOnFirstObjectCreationToTime, ScenarioStartTimeAtLocalOnFirstObjectCreationToTime)
84  virtual void setDateAndTimeOfDay(const double&, bool markModified = false) { throw DtUnimplementedMethod("void setDateAndTimeOfDay(double, bool markModified = false) is not implemented for this class."); };
85 
88  UNDEFINED_RETURNVALUE_ACCESSOR_MUTATOR(bool, userModifiedTime, UserModifiedTime)
89  UNDEFINED_RETURNVALUE_ACCESSOR_MUTATOR(bool, timeToLocalOnFirstPlacement, TimeToLocalOnFirstPlacement)
90  UNDEFINED_RETURNVALUE_ACCESSOR_MUTATOR(bool, alreadySetTimePlacement, AlreadySetTimePlacement)
91  UNDEFINED_RETURNVALUE_ACCESSOR_MUTATOR(bool, canSetScenarioPreStartTime, CanSetScenarioPreStartTime)
92  UNDEFINED_RETURNVALUE_ACCESSOR_MUTATOR(bool, scenarioStartTimeIsLocal, ScenarioStartTimeIsLocal)
93  UNDEFINED_RETURNVALUE_ACCESSOR_MUTATOR(double, timeOfDay, TimeOfDay)
94  };
95 
98  {
99  public:
101 
103  const DtGlobalEnvironmentStateComponentData& frameState() const { return myData; };
105 
106  const double dateAndTimeOfDay() const;
107  void setDateAndTimeOfDay(const double&, bool markModified = false);
108 
109  const double updateWhenTimeChangedBy() const;
110  void setUpdateWhenTimeChangedBy(const double&);
111 
112  const double timeOfDayAdvancementSpeed() const;
113  void setTimeOfDayAdvancementSpeed(const double&);
114 
115  const bool useDayNightIlluminationModel() const;
116  void setUseDayNightIlluminationModel(const bool&);
117 
118  const int scenarioStartTimeAtLocalOnFirstObjectCreationToTime() const;
119  void setScenarioStartTimeAtLocalOnFirstObjectCreationToTime(const int&);
120 
122  void setTimeToLocalOnFirstPlacement(const bool&);
123  const bool timeToLocalOnFirstPlacement() const;
124 
126  void setUserModifiedTime(const bool&);
127  const bool userModifiedTime() const;
128 
130  void setAlreadySetTimePlacement(const bool&);
131  const bool alreadySetTimePlacement() const;
132 
134  void setCanSetScenarioPreStartTime(const bool&);
135  const bool canSetScenarioPreStartTime() const;
136 
139  void setScenarioStartTimeIsLocal(const bool&);
140  const bool scenarioStartTimeIsLocal() const;
141 
142  const DtString timeOfDayString() const;
145  void setTimeOfDay(const double& value);
146 
148  const double timeOfDay() const;
149 
151  virtual void makeWritable();
152 
154  virtual void makeReadOnly();
155 
156  protected:
157  VRF::WriteSimulationDateTimeRepository myWriteSimulationDateTimeRepository;
160  };
161 
164  {
165  public:
168 
170  const DtGlobalEnvironmentStateComponentData& frameState() const { return myData; };
171 
172  bool readComponentValid() const;
173  bool findReadComponent();
174 
175  const double updateWhenTimeChangedBy() const;
176  const double dateAndTimeOfDay() const;
177  const double timeOfDayAdvancementSpeed() const;
178  const bool useDayNightIlluminationModel() const;
179  const int scenarioStartTimeAtLocalOnFirstObjectCreationToTime() const;
180  const DtString timeOfDayString() const;
181  const bool timeToLocalOnFirstPlacement() const;
182  const bool userModifiedTime() const;
183  const bool scenarioStartTimeIsLocal() const;
184 
186  const bool alreadySetTimePlacement() const;
187 
188  const bool canSetScenarioPreStartTime() const;
189  const double timeOfDay() const;
190 
191  protected:
192  void dateAndTimeOfDayChanged();
193 
196  {
197  myData = data;
198  }
199 
200  protected:
201  VRF::ReadSimulationDateTimeRepository myReadSimulationDateTimeRepository;
202  unsigned int myCallbackHandle;
205  };
206 
210  {
211  public:
213 
214  bool isDoubleBuffered() { return true; };
215  const DtFrameStateInterface* currentFrameState() const { return &myCurrentFrameState; }
216  virtual DtFrameStateInterface* nextFrameState() { return &myNextFrameState; };
217  virtual const DtFrameStateInterface* nextFrameState() const { return &myNextFrameState; };
218 
219  void updateDataStorage();
220 
222  {
223  myCurrentFrameState.updateStateData(sd);
224  myNextFrameState.updateStateData(sd);
225  }
226 
228  virtual bool forceAdvance();
229 
231  virtual void firstFrameAdvance() override;
232 
233  virtual void initializeFromParameters(const DtVrfObjectParameters*);
234 
235  virtual void aboutToBeDeleted() override
236  {
238  myCurrentFrameState.aboutToBeDeleted();
239  myNextFrameState.aboutToBeDeleted();
240  }
241 
242  protected:
246  };
247 
251 }
Instances of DtVrfObjectParameters are the readable/writeable objects that contain the information ne...
Definition: vrfObjectParameters.h:63
void advanceFrame(const DtGlobalEnvironmentStateComponentData &data)
Definition: globalEnvironmentStateComponent.h:195
Definition: stateDataTypes.h:23
const DtGlobalEnvironmentStateComponentData & frameState() const
Current frame state only can access current frame buffers. This ensures thread safety.
Definition: globalEnvironmentStateComponent.h:170
virtual DtFrameStateInterface * nextFrameState()
Definition: globalEnvironmentStateComponent.h:216
DtGlobalEnvironmentStateComponentData & frameState()
Definition: globalEnvironmentStateComponent.h:104
double myDateAndTimeOfDay
Definition: globalEnvironmentStateComponent.h:60
Definition: stateComponent.h:257
bool dateAndTimeOfDayHasBeenSet() const
Definition: globalEnvironmentStateComponent.h:47
DtGlobalEnvironmentStateComponentData & operator=(const DtGlobalEnvironmentStateComponentData &rhs)
Definition: globalEnvironmentStateComponent.h:38
bool isDoubleBuffered()
Definition: globalEnvironmentStateComponent.h:214
DtGlobalEnvironmentStateComponentData myData
Definition: globalEnvironmentStateComponent.h:159
#define UNDEFINED_RETURNVALUE_ACCESSOR(ReturnType, Member)
Definition: doubleBufferedDataStorage.h:31
VRF::WriteSimulationDateTimeRepository myWriteSimulationDateTimeRepository
Definition: globalEnvironmentStateComponent.h:157
int myScenarioStartTimeAtLocalOnFirstObjectCreationToTime
Definition: globalEnvironmentStateComponent.h:58
DtStateData * myStateData
Definition: globalEnvironmentStateComponent.h:158
DtGlobalEnvironmentStateComponentData myData
Definition: globalEnvironmentStateComponent.h:204
The overall structure of the DtStateData mechanism is: The DtStateData contains a list of double buff...
Definition: stateData.h:336
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: globalEnvironmentStateComponent.h:69
#define DEFINE_STATE_COMPONENT_TYPE(CreatedComponent)
Definition: stateComponent.h:219
Contains the enums for cloud layers.
Subclass from this to indicate that this will be a double buffered state component.
Definition: stateComponent.h:370
#define UNDEFINED_RETURNVALUE_ACCESSOR_MUTATOR(Type, Member, Set)
Definition: doubleBufferedDataStorage.h:53
double myUpdateWhenTimeChangedBy
Definition: globalEnvironmentStateComponent.h:59
virtual void aboutToBeDeleted()
void updateStateData(DtStateData *sd)
Implement to update data storage to the new state data.
Definition: globalEnvironmentStateComponent.h:221
const DtGlobalEnvironmentStateComponentData & frameState() const
Next frame access write access. Ensure this is only used in a single thread (i.e.a controller thread)...
Definition: globalEnvironmentStateComponent.h:103
Definition: globalEnvironmentStateComponent.h:20
DtGlobalEnvironmentStateComponentData()
Definition: globalEnvironmentStateComponent.h:22
DtStateComponentCreator< DtGlobalEnvironmentStateComponentImplementation > DtGlobalEnvironmentStateComponentCreator
5) Define the creator. This will need to be registered with the REGISTER_STATE_COMPONENT macro in the...
Definition: globalEnvironmentStateComponent.h:250
#define DEFINE_ACCESSOR_MUTATOR(ReturnType, Accessor, Mutator)
Definition: doubleBufferedDataStorage.h:23
virtual const DtFrameStateInterface * nextFrameState() const
Definition: globalEnvironmentStateComponent.h:217
DtGlobalEnvironmentStateComponentNextFrame myNextFrameState
Definition: globalEnvironmentStateComponent.h:244
virtual void aboutToBeDeleted() override
Definition: globalEnvironmentStateComponent.h:235
3) Define the current frame class. This will be used for read access.
Definition: globalEnvironmentStateComponent.h:163
unsigned int myCallbackHandle
Definition: globalEnvironmentStateComponent.h:202
#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
DtGlobalEnvironmentStateComponentData(const DtGlobalEnvironmentStateComponentData &orig)
Definition: globalEnvironmentStateComponent.h:30
const DtFrameStateInterface * currentFrameState() const
Definition: globalEnvironmentStateComponent.h:215
VRF::ReadSimulationDateTimeRepository myReadSimulationDateTimeRepository
Definition: globalEnvironmentStateComponent.h:201
2) Define the next frame class. This will be used for write access.
Definition: globalEnvironmentStateComponent.h:97
DtGlobalEnvironmentStateComponentCurrentFrame myCurrentFrameState
Definition: globalEnvironmentStateComponent.h:243
bool myScenarioStartTimeIsLocal
If this is true (default) the time of day is to be considered a local time. If false, UTC time and this will be considered adjusted for local time.
Definition: globalEnvironmentStateComponent.h:64
bool myFoundComponent
Definition: globalEnvironmentStateComponent.h:245
4) Define the state component that will contain the wrappers to the next and current frame states tha...
Definition: globalEnvironmentStateComponent.h:209
DtStateData * myStateData
Definition: globalEnvironmentStateComponent.h:203
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:282

Document ID: Generated on Sun Dec 4 20:22:03 EST 2022 from SVN revision 249613
Copyright © 2005-2021 MAK Technologies. All Rights Reserved (www.mak.com)