TrueReality  v0.1.1912
SystemDirector.h
Go to the documentation of this file.
1 /*
2 * True Reality Open Source Game and Simulation Engine
3 * Copyright © 2021 Acid Rain Studios LLC
4 *
5 * This library is free software; you can redistribute it and/or modify it under
6 * the terms of the GNU Lesser General Public License as published by the Free
7 * Software Foundation; either version 3.0 of the License, or (at your option)
8 * any later version.
9 *
10 * This library is distributed in the hope that it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12 * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
13 * details.
14 *
15 * You should have received a copy of the GNU Lesser General Public License
16 * along with this library; if not, write to the Free Software Foundation, Inc.,
17 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 *
19 * @author Maxim Serebrennik
20 */
21 #pragma once
22 
23 #include "Export.h"
24 
26 #include <trManager/DirectorBase.h>
27 #include <trManager/MessageBase.h>
28 #include <trUtil/RefStr.h>
29 #include <trUtil/Timer.h>
30 
31 namespace trCore
32 {
33 
40  {
41  public:
43 
44  const static trUtil::RefStr CLASS_TYPE;
45 
46  const static double MAX_TIME_SCALE;
47  const static double MIN_TIME_SCALE;
48 
56  SystemDirector(const std::string name = CLASS_TYPE);
57 
65  virtual const std::string& GetType() const override;
66 
74  virtual void OnMessage(const trManager::MessageBase& msg);
75 
81  virtual void Run();
82 
88  virtual void RunOnce();
89 
97  virtual bool IsRunning();
98 
104  virtual void ShutDown();
105 
113  trManager::TimingStructure GetTimeStructure();
114 
115  protected:
116 
122  ~SystemDirector();
123 
132  virtual void UpdateTiming(trManager::TimingStructure& timeStruct, double dt);
133 
141  virtual void EventTraversal(const trManager::TimingStructure& timeStruct);
142 
150  virtual void PostEventTraversal(const trManager::TimingStructure& timeStruct);
151 
160  virtual void PreFrame(const trManager::TimingStructure& timeStruct);
161 
169  virtual void CameraSynch(const trManager::TimingStructure& timeStruct);
170 
178  virtual void FrameSynch(const trManager::TimingStructure& timeStruct);
179 
187  virtual void Frame(const trManager::TimingStructure& timeStruct);
188 
196  virtual void PostFrame(const trManager::TimingStructure& timeStruct);
197 
205  virtual void SetTimeScale(const double timeScale);
206 
212  virtual void IncrementTimeScale();
213 
219  virtual void DecrementTimeScale();
220 
226  virtual void CheckForShutdown();
227 
228  private:
229 
230  bool mIsRunning = false;
231  bool mIsShuttingDown = false;
232  bool mIsPaused = false;
234 
236  };
237 }
238 
A timing structure for all sim loop variables.
#define TR_CORE_EXPORT
Definition: trCore/Export.h:33
static const double MIN_TIME_SCALE
Hold the maximum time scale the system can use for positive and negaive time.
A string wrapper that will make sure that all of the strings with the same value will point to the sa...
Definition: RefStr.h:50
A director base.
Definition: DirectorBase.h:39
This class is part of the internal garbage collection system.
Definition: SmrtClass.h:38
Timer class is used for measuring elapsed time or time between two points.
Definition: Timer.h:65
A System director.
static const double MAX_TIME_SCALE
Holds the class type name for efficient comparisons.
trManager::TimingStructure mTimeStruct
static const trUtil::RefStr CLASS_TYPE
Adds an easy and swappable access to the base class.
trUtil::Timer mSystemTimer
This is the base class for all the messages in TR.
Definition: MessageBase.h:40