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