VR-Forces Developer's Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
timeAndDateStateComponent.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 #include <vrfutil/rwUUID.h>
18 
19 namespace makVrf
20 {
21  static DtUUID DtGlobalWeatherObjectUUID("VRF_UUID:73666f77-63d6-e041-a002-f2690e990574");
22 
24  {
26  {
27  myScenarioStartTimeAtLocalOnFirstObjectCreationToTime = 36000;
28  myUpdateWhenTimeChangedBy = 60.;
29  myDateAndTimeOfDay = 43200.0;
30  myScenarioStartTimeIsLocal = true;
31  }
32 
34  {
35  myScenarioStartTimeAtLocalOnFirstObjectCreationToTime = orig.myScenarioStartTimeAtLocalOnFirstObjectCreationToTime;
36  myUpdateWhenTimeChangedBy = orig.myUpdateWhenTimeChangedBy;
37  myDateAndTimeOfDay = orig.myDateAndTimeOfDay;
38  myScenarioStartTimeIsLocal = orig.myScenarioStartTimeIsLocal;
39  }
40 
42  {
43  myScenarioStartTimeAtLocalOnFirstObjectCreationToTime = rhs.myScenarioStartTimeAtLocalOnFirstObjectCreationToTime;
44  myUpdateWhenTimeChangedBy = rhs.myUpdateWhenTimeChangedBy;
45  myDateAndTimeOfDay = rhs.myDateAndTimeOfDay;
46  myScenarioStartTimeIsLocal = rhs.myScenarioStartTimeIsLocal;
47  return *this;
48  }
49 
51  {
52  return (myDateAndTimeOfDay != 43200.0);
53  }
54 
55  DEFINE_ACCESSOR_MUTATOR(double, updateWhenTimeChangedBy, UpdateWhenTimeChangedBy)
56  DEFINE_ACCESSOR_MUTATOR(double, dateAndTimeOfDay, DateAndTimeOfDay)
57  DEFINE_ACCESSOR_MUTATOR(int, scenarioStartTimeAtLocalOnFirstObjectCreationToTime, ScenarioStartTimeAtLocalOnFirstObjectCreationToTime)
58  DEFINE_ACCESSOR_MUTATOR(bool, scenarioStartTimeIsLocal, ScenarioStartTimeIsLocal)
59 
60  protected:
61  int myScenarioStartTimeAtLocalOnFirstObjectCreationToTime;
62  double myUpdateWhenTimeChangedBy;
63  double myDateAndTimeOfDay;
64 
67  bool myScenarioStartTimeIsLocal;
68  };
69 
73  {
74  public:
76 
78  : DtFrameStateInterface(storage)
79  {
80  }
81 
82  UNDEFINED_RETURNVALUE_ACCESSOR_MUTATOR(double, updateWhenTimeChangedBy, UpdateWhenTimeChangedBy)
83  UNDEFINED_RETURNVALUE_ACCESSOR(double, dateAndTimeOfDay)
84  UNDEFINED_RETURNVALUE_ACCESSOR_MUTATOR(double, timeOfDayAdvancementSpeed, TimeOfDayAdvancementSpeed)
85  UNDEFINED_RETURNVALUE_ACCESSOR_MUTATOR(bool, useDayNightIlluminationModel, UseDayNightIlluminationModel)
86  UNDEFINED_RETURNVALUE_ACCESSOR_MUTATOR(int, scenarioStartTimeAtLocalOnFirstObjectCreationToTime, ScenarioStartTimeAtLocalOnFirstObjectCreationToTime)
87  virtual void setDateAndTimeOfDay(const double&, bool markModified = false) { throw DtUnimplementedMethod("void setDateAndTimeOfDay(double, bool markModified = false) is not implemented for this class."); };
88 
91  UNDEFINED_RETURNVALUE_ACCESSOR_MUTATOR(bool, userModifiedTime, UserModifiedTime)
92  UNDEFINED_RETURNVALUE_ACCESSOR_MUTATOR(bool, timeToLocalOnFirstPlacement, TimeToLocalOnFirstPlacement)
93  UNDEFINED_RETURNVALUE_ACCESSOR_MUTATOR(bool, alreadySetTimePlacement, AlreadySetTimePlacement)
94  UNDEFINED_RETURNVALUE_ACCESSOR_MUTATOR(bool, canSetScenarioPreStartTime, CanSetScenarioPreStartTime)
95  UNDEFINED_RETURNVALUE_ACCESSOR_MUTATOR(bool, scenarioStartTimeIsLocal, ScenarioStartTimeIsLocal)
96  UNDEFINED_RETURNVALUE_ACCESSOR_MUTATOR(double, timeOfDay, TimeOfDay)
97  };
98 
101  {
102  public:
104 
106  const DtTimeAndDateStateComponentData& frameState() const { return myData; };
108 
109  const double dateAndTimeOfDay() const;
110  void setDateAndTimeOfDay(const double&, bool markModified = false);
111 
112  const double updateWhenTimeChangedBy() const;
113  void setUpdateWhenTimeChangedBy(const double&);
114 
115  const double timeOfDayAdvancementSpeed() const;
116  void setTimeOfDayAdvancementSpeed(const double&);
117 
118  const bool useDayNightIlluminationModel() const;
119  void setUseDayNightIlluminationModel(const bool&);
120 
121  const int scenarioStartTimeAtLocalOnFirstObjectCreationToTime() const;
122  void setScenarioStartTimeAtLocalOnFirstObjectCreationToTime(const int&);
123 
125  void setTimeToLocalOnFirstPlacement(const bool&);
126  const bool timeToLocalOnFirstPlacement() const;
127 
129  void setUserModifiedTime(const bool&);
130  const bool userModifiedTime() const;
131 
133  void setAlreadySetTimePlacement(const bool&);
134  const bool alreadySetTimePlacement() const;
135 
137  void setCanSetScenarioPreStartTime(const bool&);
138  const bool canSetScenarioPreStartTime() const;
139 
142  void setScenarioStartTimeIsLocal(const bool&);
143  const bool scenarioStartTimeIsLocal() const;
144 
145  const DtString timeOfDayString() const;
148  void setTimeOfDay(const double& value);
149 
151  const double timeOfDay() const;
152 
154  virtual void makeWritable();
155 
157  virtual void makeReadOnly();
158 
159  protected:
160  VRF::WriteSimulationDateTimeRepository myWriteSimulationDateTimeRepository;
163  };
164 
167  {
168  public:
171 
173  const DtTimeAndDateStateComponentData& frameState() const { return myData; };
174 
175  bool readComponentValid() const;
176  bool findReadComponent();
177 
178  const double updateWhenTimeChangedBy() const;
179  const double dateAndTimeOfDay() const;
180  const double timeOfDayAdvancementSpeed() const;
181  const bool useDayNightIlluminationModel() const;
182  const int scenarioStartTimeAtLocalOnFirstObjectCreationToTime() const;
183  const DtString timeOfDayString() const;
184  const bool timeToLocalOnFirstPlacement() const;
185  const bool userModifiedTime() const;
186  const bool scenarioStartTimeIsLocal() const;
187 
189  const bool alreadySetTimePlacement() const;
190 
191  const bool canSetScenarioPreStartTime() const;
192  const double timeOfDay() const;
193 
194  protected:
195  void dateAndTimeOfDayChanged();
196 
199  {
200  myData = data;
201  }
202 
203  protected:
204  VRF::ReadSimulationDateTimeRepository myReadSimulationDateTimeRepository;
205  unsigned int myCallbackHandle;
208  };
209 
213  {
214  public:
216 
217  bool isDoubleBuffered() { return true; };
218  const DtFrameStateInterface* currentFrameState() const { return &myCurrentFrameState; }
219  virtual DtFrameStateInterface* nextFrameState() { return &myNextFrameState; };
220  virtual const DtFrameStateInterface* nextFrameState() const { return &myNextFrameState; };
221 
222  void updateDataStorage();
223 
225  {
226  myCurrentFrameState.updateStateData(sd);
227  myNextFrameState.updateStateData(sd);
228  }
229 
231  virtual bool forceAdvance();
232 
234  virtual void firstFrameAdvance() override;
235 
236  virtual void initializeFromParameters(const DtVrfObjectParameters*);
237 
238  virtual void aboutToBeDeleted() override
239  {
241  myCurrentFrameState.aboutToBeDeleted();
242  myNextFrameState.aboutToBeDeleted();
243  }
244 
245  protected:
249  };
250 
254 }
UUID is a unique ID wrapper class.
Definition: uuid.h:59
Instances of DtVrfObjectParameters are the readable/writeable objects that contain the information ne...
Definition: vrfObjectParameters.h:63
bool dateAndTimeOfDayHasBeenSet() const
Definition: timeAndDateStateComponent.h:50
Definition: stateDataTypes.h:23
DtTimeAndDateStateComponentData myData
Definition: timeAndDateStateComponent.h:207
bool myFoundComponent
Definition: timeAndDateStateComponent.h:248
DtTimeAndDateStateComponentData(const DtTimeAndDateStateComponentData &orig)
Definition: timeAndDateStateComponent.h:33
2) Define the next frame class. This will be used for write access.
Definition: timeAndDateStateComponent.h:100
DtTimeAndDateStateComponentData & operator=(const DtTimeAndDateStateComponentData &rhs)
Definition: timeAndDateStateComponent.h:41
Definition: stateComponent.h:266
int myScenarioStartTimeAtLocalOnFirstObjectCreationToTime
Definition: timeAndDateStateComponent.h:61
DtStateData * myStateData
Definition: timeAndDateStateComponent.h:206
virtual void aboutToBeDeleted() override
Definition: timeAndDateStateComponent.h:238
unsigned int myCallbackHandle
Definition: timeAndDateStateComponent.h:205
3) Define the current frame class. This will be used for read access.
Definition: timeAndDateStateComponent.h:166
void advanceFrame(const DtTimeAndDateStateComponentData &data)
Definition: timeAndDateStateComponent.h:198
virtual DtFrameStateInterface * nextFrameState()
Definition: timeAndDateStateComponent.h:219
DtTimeAndDateStateComponentData()
Definition: timeAndDateStateComponent.h:25
#define UNDEFINED_RETURNVALUE_ACCESSOR(ReturnType, Member)
Definition: doubleBufferedDataStorage.h:31
Contains the DtUUID class declaration.
double myUpdateWhenTimeChangedBy
Definition: timeAndDateStateComponent.h:62
DtStateComponentCreator< DtTimeAndDateStateComponentImplementation > DtTimeAndDateStateComponentCreator
5) Define the creator. This will need to be registered with the REGISTER_STATE_COMPONENT macro in the...
Definition: timeAndDateStateComponent.h:253
const DtTimeAndDateStateComponentData & frameState() const
Current frame state only can access current frame buffers. This ensures thread safety.
Definition: timeAndDateStateComponent.h:173
double myDateAndTimeOfDay
Definition: timeAndDateStateComponent.h:63
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: timeAndDateStateComponent.h:72
DtTimeAndDateStateComponentNextFrame myNextFrameState
Definition: timeAndDateStateComponent.h:247
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
Contains the enums for cloud layers.
DtTimeAndDateStateComponentData & frameState()
Definition: timeAndDateStateComponent.h:107
Subclass from this to indicate that this will be a double buffered state component.
Definition: stateComponent.h:379
#define UNDEFINED_RETURNVALUE_ACCESSOR_MUTATOR(Type, Member, Set)
Definition: doubleBufferedDataStorage.h:53
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: timeAndDateStateComponent.h:67
virtual void aboutToBeDeleted()
virtual const DtFrameStateInterface * nextFrameState() const
Definition: timeAndDateStateComponent.h:220
const DtFrameStateInterface * currentFrameState() const
Definition: timeAndDateStateComponent.h:218
DtTimeAndDateStateComponentCurrentFrame myCurrentFrameState
Definition: timeAndDateStateComponent.h:246
#define DEFINE_ACCESSOR_MUTATOR(ReturnType, Accessor, Mutator)
Definition: doubleBufferedDataStorage.h:23
4) Define the state component that will contain the wrappers to the next and current frame states tha...
Definition: timeAndDateStateComponent.h:212
VRF::WriteSimulationDateTimeRepository myWriteSimulationDateTimeRepository
Definition: timeAndDateStateComponent.h:160
DtTimeAndDateStateComponentData myData
Definition: timeAndDateStateComponent.h:162
static DtUUID DtGlobalWeatherObjectUUID("VRF_UUID:73666f77-63d6-e041-a002-f2690e990574")
#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
VRF::ReadSimulationDateTimeRepository myReadSimulationDateTimeRepository
Definition: timeAndDateStateComponent.h:204
Definition: timeAndDateStateComponent.h:23
void updateStateData(DtStateData *sd)
Implement to update data storage to the new state data.
Definition: timeAndDateStateComponent.h:224
Contains the DtStateComponent class declaration.
bool isDoubleBuffered()
Definition: timeAndDateStateComponent.h:217
DtStateData * myStateData
Definition: timeAndDateStateComponent.h:161
This is a simple base class that will be used to return a pointer to current or next frame state...
Definition: stateComponent.h:291
const DtTimeAndDateStateComponentData & frameState() const
Next frame access write access. Ensure this is only used in a single thread (i.e.a controller thread)...
Definition: timeAndDateStateComponent.h:106

Document ID: Generated on Wed Mar 27 22:49:11 EDT 2024 from SVN revision 264633
Copyright © 2005-2024 MAK Technologies. All Rights Reserved (www.mak.com)