IceShard 1
A personal game engine project, with development focused on 2D/2.5D games.
Loading...
Searching...
No Matches
clock.hxx
Go to the documentation of this file.
1
3
4#pragma once
5#include <ice/clock_types.hxx>
6
7namespace ice
8{
9
21
26 struct SystemClock : ice::Clock { };
27
44
51
57
65
66 namespace clock
67 {
68
69 auto now() noexcept -> ice::Timestamp;
70
71 auto clock_frequency() noexcept -> ice::ClockFrequency;
72
73 auto create_clock() noexcept -> ice::SystemClock;
74
76 ice::Clock const& clock,
77 ice::f32 modifier
78 ) noexcept -> ice::CustomClock;
79
80 void update(ice::SystemClock& clock) noexcept;
81
82 void update(ice::CustomClock& clock) noexcept;
83
86 ice::Tns max_delta
87 ) noexcept;
88
89 auto elapsed(ice::Clock const& clock) noexcept -> ice::Tns;
90
91 auto elapsed(ice::Timestamp start, ice::Timestamp end) noexcept -> ice::Tns;
92
93 } // namespace clock
94
95 namespace timer
96 {
97
99 ice::Clock const& clock,
100 ice::Tns timer_step
101 ) noexcept -> ice::Timer;
102
104 ice::Clock const& clock,
105 ice::Tns timer_step,
106 ice::Timestamp initial_timestamp
107 ) noexcept -> ice::Timer;
108
109 bool update(ice::Timer& timer) noexcept;
110
112
113 auto elapsed(ice::Timer const& timer) noexcept -> ice::Tns;
114
115 auto elapsed_us(ice::Timer const& timer) noexcept -> ice::Tus;
116
117 auto alpha(ice::Timer const& timer) noexcept -> ice::f32;
118
119 } // namespace timer
120
121 namespace timeline
122 {
123
125
126 void reset(ice::Timeline& timeline) noexcept;
127
128 auto elapsed(ice::Timeline const& timeline) noexcept -> ice::Tns;
129
130 auto elapsed_us(ice::Timeline const& timeline) noexcept -> ice::Tus;
131
132 } // namespace timeline
133
134 namespace stopwatch
135 {
136
137 // Always uses system clock
138 auto create_stopwatch() noexcept -> ice::Stopwatch;
139 auto create_stopwatch(ice::Clock const& clock) noexcept -> ice::Stopwatch;
140
141 auto elapsed(ice::Stopwatch const& stopwatch) noexcept -> ice::Tns;
142 auto elapsed_us(ice::Stopwatch const& stopwatch) noexcept -> ice::Tus;
143
144 void start(ice::Stopwatch& stopwatch) noexcept;
145
146 void stop(ice::Stopwatch& stopwatch) noexcept;
147
148 } // namespace stopwatch
149
150} // namespace ice
Definition clock.hxx:67
auto create_clock() noexcept -> ice::SystemClock
void update(ice::SystemClock &clock) noexcept
auto elapsed(ice::Clock const &clock) noexcept -> ice::Tns
auto now() noexcept -> ice::Timestamp
void update_max_delta(ice::CustomClock &clock, ice::Tns max_delta) noexcept
auto clock_frequency() noexcept -> ice::ClockFrequency
Definition clock.hxx:135
void start(ice::Stopwatch &stopwatch) noexcept
auto elapsed_us(ice::Stopwatch const &stopwatch) noexcept -> ice::Tus
void stop(ice::Stopwatch &stopwatch) noexcept
auto create_stopwatch() noexcept -> ice::Stopwatch
auto elapsed(ice::Stopwatch const &stopwatch) noexcept -> ice::Tns
Definition clock.hxx:122
auto elapsed_us(ice::Timeline const &timeline) noexcept -> ice::Tus
void reset(ice::Timeline &timeline) noexcept
auto create_timeline(ice::Clock const &clock) noexcept -> ice::Timeline
auto elapsed(ice::Timeline const &timeline) noexcept -> ice::Tns
Definition clock.hxx:96
auto alpha(ice::Timer const &timer) noexcept -> ice::f32
bool update_by_step(ice::Timer &timer) noexcept
auto create_timer(ice::Clock const &clock, ice::Tns timer_step) noexcept -> ice::Timer
auto elapsed_us(ice::Timer const &timer) noexcept -> ice::Tus
SPDX-License-Identifier: MIT.
Definition array.hxx:12
float f32
Definition types.hxx:16
Represent the current systems clock frequency. Can be used to transform timestamps to time values.
Definition clock_types.hxx:92
Simple object representing a clock by using two timestamps.
Definition clock.hxx:17
ice::Timestamp _ts_latest
Definition clock.hxx:19
ice::Timestamp _ts_previous
Definition clock.hxx:18
A custom clock allows to control the "speed" of calculated time.
Definition clock.hxx:40
ice::f32 modifier
Definition clock.hxx:42
ice::Clock const * _clock_base
Definition clock.hxx:41
Definition clock.hxx:59
ice::Timestamp _ts_initial
Definition clock.hxx:62
ice::Clock const * clock
Definition clock.hxx:60
ice::Timestamp _ts_final
Definition clock.hxx:63
A system clock provides access to the actual time on the running system.
Definition clock.hxx:26
Definition clock.hxx:53
ice::Timestamp _ts_initial
Definition clock.hxx:55
ice::Clock const * _clock_base
Definition clock.hxx:54
Definition clock.hxx:46
ice::Timestamp _ts_latest
Definition clock.hxx:49
ice::Timestamp _timer_step
Definition clock.hxx:48
ice::Clock const * _clock_base
Definition clock.hxx:47
Represents platform native timestamp with undefined representation.
Definition clock_types.hxx:89
Represents time interval of nanoseconds.
Definition clock_types.hxx:73
Represents time interval of microseconds.
Definition clock_types.hxx:56