CTimeManager.h
Go to the documentation of this file.
1 
2 #pragma once
3 
4 #include <ionCore.h>
5 #include <ionFramework.h>
6 
7 #include "CWindowManager.h"
8 
9 
10 namespace ion
11 {
12 
13  class CTimeManager : public Singleton<CTimeManager>
14  {
15 
16  public:
17 
18  class CUpdateTick : public IEventListener, public IEvent
19  {
20 
21  public:
22 
23  f64 GetTick() const;
24  f64 GetElapsedTime() const;
25  f64 GetMaxDuration() const;
26  f64 GetAccumulator() const;
27 
28  protected:
29 
30  friend class CTimeManager;
31  CUpdateTick(f64 const Tick, f64 const MaxDuration);
32  void Update(f64 const Elapsed);
33 
37 
38  };
39 
40  void Init(CWindowManager * WindowManager);
41  void Start();
42 
43  void Update();
44 
45  void SkipElapsedTime();
46 
48  f64 GetElapsedTime() const;
49 
51  f64 GetActualElapsedTime() const;
52 
53  f64 GetRunTime() const;
54  f64 GetTimeMultiplier() const;
55 
57 
58  CUpdateTick * MakeUpdateTick(f64 const Tick, f32 const MaxDuration = 1.0);
59 
60  protected:
61 
63  f64 RunTime = 0;
66 
67  vector<CUpdateTick *> UpdateTicks;
68 
69  private:
70 
71  friend class Singleton<CTimeManager>;
72  CTimeManager();
73 
74  };
75 
76  class CStopWatch
77  {
78 
79  public:
80 
81  CStopWatch();
82  f64 Start();
83  f64 Stop();
84 
85  private:
86 
87  f64 t0;
88 
89  };
90 
91 }
CUpdateTick(f64 const Tick, f64 const MaxDuration)
Definition: CTimeManager.cpp:29
Definition: CTimeManager.h:76
f64 GetActualElapsedTime() const
Same as ElapsedTime, except before TimeMultiplier is applied.
Definition: CTimeManager.cpp:78
f64 ElapsedTime
Definition: CTimeManager.h:62
CUpdateTick * MakeUpdateTick(f64 const Tick, f32 const MaxDuration=1.0)
Definition: CTimeManager.cpp:98
f64 RunTime
Definition: CTimeManager.h:63
f64 TimeMultiplier
Definition: CTimeManager.h:65
Definition: CTimeManager.h:18
f64 GetElapsedTime() const
Definition: CTimeManager.cpp:14
Definition: CTimeManager.h:13
f64 GetTimeMultiplier() const
Definition: CTimeManager.cpp:88
void Update(f64 const Elapsed)
Definition: CTimeManager.cpp:36
float f32
Definition: ionTypes.h:94
f64 GetRunTime() const
Definition: CTimeManager.cpp:83
Definition: CCatmullRomAdvancedSplineInterpolator.h:7
Definition: IEvent.h:7
f64 GetAccumulator() const
Definition: CTimeManager.cpp:24
Definition: IEventListener.h:8
void SkipElapsedTime()
Definition: CTimeManager.cpp:68
f64 LastTime
Definition: CTimeManager.h:64
vector< CUpdateTick * > UpdateTicks
Definition: CTimeManager.h:67
f64 Tick
Definition: CTimeManager.h:34
f64 GetTick() const
Definition: CTimeManager.cpp:9
void Init(CWindowManager *WindowManager)
Definition: CTimeManager.cpp:47
f64 Accumulator
Definition: CTimeManager.h:36
Base class for Singleton design pattern implementation.
Definition: ionClass.h:90
f64 MaxDuration
Definition: CTimeManager.h:35
void SetTimeMultiplier(f64 const TimeMultiplier)
Definition: CTimeManager.cpp:93
double f64
Definition: ionTypes.h:95
Definition: CWindowManager.h:19
f64 GetMaxDuration() const
Definition: CTimeManager.cpp:19
void Start()
Definition: CTimeManager.cpp:52
friend class CTimeManager
Definition: CTimeManager.h:30