SPARK  0.1.0
A general purpose game engine written in C++.
Loading...
Searching...
No Matches
Clock.h
1#pragma once
2
3#include "spark/lib/Export.h"
4
5#include "spark/base/Platforms.h"
6
7#include <chrono>
8
9namespace spark::lib
10{
11#ifdef SPARK_OS_WINDOWS
12 template <typename T>
13 concept IsDuration = std::chrono::_Is_duration_v<std::remove_cvref_t<T>>;
14#else
15 template <typename T>
16 concept IsDuration = std::chrono::__is_duration<std::remove_cvref_t<T>>::value;
17#endif
18
22 class SPARK_LIB_EXPORT Clock
23 {
24 public:
28 Clock();
29 ~Clock() = default;
30
31 Clock(const Clock& other) = default;
32 Clock(Clock&& other) noexcept = default;
33 Clock& operator=(const Clock& other) = default;
34 Clock& operator=(Clock&& other) noexcept = default;
35
41 template <typename T> requires IsDuration<T>
42 [[nodiscard]] float elapsedTime() const;
43
47 void restart();
48
54 template <typename T> requires IsDuration<T>
55 [[nodiscard]] float restart();
56
57 private:
58 std::chrono::steady_clock::time_point m_startTime;
59 };
60}
61
62#include "spark/lib/impl/Clock.h"
A class that can be used to measure time like a stopwatch.
Definition Clock.h:23
Definition Clock.h:16