vengine  0.1.0
3D graphics engine made with Vulkan
Loading...
Searching...
No Matches
Clock.hpp
Go to the documentation of this file.
1///
2/// @file Clock.hpp
3/// @brief Clock class for time management
4/// @namespace myLib
5///
6
7#pragma once
8
9#include <chrono>
10
11#include "myLib/Clock/Time.hpp"
12
13///
14/// @brief TimePoint is a type alias for a time point which is a very long and complicated type in the standard library
15///
16using TimePoint = std::chrono::time_point<std::chrono::high_resolution_clock>;
17
18namespace myLib {
19
20 ///
21 /// @brief Class for time management
22 ///
23 class Clock {
24
25 public:
26
27 Clock() : m_start(std::chrono::high_resolution_clock::now()) {};
28
29 ~Clock() = default;
30
31 ///
32 /// @brief Restart the clock
33 ///
34 void restart() { m_start = std::chrono::high_resolution_clock::now(); };
35
36 ///
37 /// @brief Pause the clock
38 ///
39 void pause();
40
41 ///
42 /// @brief Resume the clock
43 ///
44 void resume();
45
46 ///
47 /// @brief Get the elapsed time since the last restart
48 /// @return Time The elapsed time
49 ///
50 [[nodiscard]] Time getElapsedTime() const;
51
52 private:
53
54 ///
55 /// @property The start time
56 ///
58
59 ///
60 /// @property The pause time
61 ///
63
64 ///
65 /// @property The "is in pause" boolean variable
66 ///
67 bool m_paused{false};
68
69 }; // Clock
70
71} // namespace myLib
std::chrono::time_point< std::chrono::high_resolution_clock > TimePoint
TimePoint is a type alias for a time point which is a very long and complicated type in the standard ...
Definition Clock.hpp:16
Class for time management.
Class for time management.
Definition Clock.hpp:23
Time getElapsedTime() const
Get the elapsed time since the last restart.
Definition clock.cpp:22
~Clock()=default
TimePoint m_pause
Definition Clock.hpp:62
TimePoint m_start
Definition Clock.hpp:57
bool m_paused
Definition Clock.hpp:67
void restart()
Restart the clock.
Definition Clock.hpp:34
void resume()
Resume the clock.
Definition clock.cpp:12
void pause()
Pause the clock.
Definition clock.cpp:3
Class used for time management.
Definition Time.hpp:15
STL namespace.