AnimEngine
Timeline.hpp
1 #pragma once
2 #ifndef TIMELINE_H_
3 #define TIMELINE_H_
4 
5 #include <chrono>
6 
7 using namespace std;
8 
9 class Timeline{
10  public:
11  Timeline(bool aStartPaused = false){
12  chrono::high_resolution_clock::time_point start = chrono::high_resolution_clock::now();
13  mStartTime = start;
14  mLastTime = start;
15  if(aStartPaused == true){
16  mPaused = true;
17  mPauseTime = start;
18  }
19  }
20  double getTime() const;
21  double get() const;
22  inline explicit operator double() const {return(get());}
23  double elapsed();
24  double peekElapsed();
25  void reset();
26  void pause();
27  void unpause();
28  void togglePause();
29  bool isPaused() const;
30  protected:
31  bool mPaused = false;
32  chrono::high_resolution_clock::time_point mLastTime;
33  chrono::high_resolution_clock::time_point mStartTime;
34  chrono::high_resolution_clock::time_point mPauseTime;
35  double mAccumulatedPauseTime = 0.0;
36 };
37 
38 #endif
Definition: Timeline.hpp:9