libdonut
2.3.2
Application framework for cross-platform game development in C++20
|
Time duration value wrapper. More...
#include <donut/Time.hpp>
Public Types | |
using | Duration = std::chrono::duration< T, Period > |
Underlying duration type. More... | |
Public Member Functions | |
constexpr | Time () noexcept=default |
Construct a time value of 0. More... | |
constexpr | Time (Duration duration) noexcept |
Construct a time value from a duration. More... | |
constexpr | Time (std::chrono::seconds seconds) noexcept |
Construct a time value from a number of seconds. More... | |
constexpr | Time (std::chrono::milliseconds milliseconds) noexcept |
Construct a time value from a number of milliseconds. More... | |
constexpr | Time (std::chrono::microseconds microseconds) noexcept |
Construct a time value from a number of microseconds. More... | |
constexpr | Time (std::chrono::nanoseconds nanoseconds) noexcept |
Construct a time value from a number of nanoseconds. More... | |
constexpr | Time (std::chrono::minutes minutes) noexcept |
Construct a time value from a number of minutes. More... | |
constexpr | Time (std::chrono::hours hours) noexcept |
Construct a time value from a number of hours. More... | |
constexpr | operator Duration () const noexcept |
Convert a time value to its underlying duration type. More... | |
constexpr | operator T () const noexcept |
Convert a time value to its underlying scalar type. More... | |
constexpr Time & | operator+= (Time deltaTime) noexcept |
Add time to this time value. More... | |
constexpr Time & | operator-= (Time deltaTime) noexcept |
Subtract time from this time value. More... | |
constexpr bool | countDown (Time deltaTime, Time targetTime=Duration{}) noexcept |
Subtract time from this value and then check if it reached a given target time value. More... | |
constexpr bool | countUp (Time deltaTime, Time targetTime) noexcept |
Add time to this value and then check if it reached a given target time value. More... | |
constexpr std::size_t | countDownLoop (Time deltaTime, Time interval) noexcept |
Subtract time from this value and then check how many times it reached 0 while looping back to a given time interval. More... | |
constexpr std::size_t | countUpLoop (Time deltaTime, Time interval) noexcept |
Add time to this value and then check how many times it reached a given time interval while looping back to 0. More... | |
constexpr std::size_t | countDownLoop (Time deltaTime, Time interval, bool active) noexcept |
Update a countdown loop with a boolean trigger that determines whether the loop is active or not. More... | |
constexpr std::size_t | countUpLoop (Time deltaTime, Time interval, bool active) noexcept |
Update a countup loop with a boolean trigger that determines whether the loop is active or not. More... | |
Friends | |
constexpr friend bool | operator== (const Time &a, const Time &b) noexcept |
Compare two time values for equality. More... | |
constexpr friend bool | operator!= (const Time &a, const Time &b) noexcept |
Compare two time values for inequality. More... | |
constexpr friend bool | operator< (const Time &a, const Time &b) noexcept |
Check if a time value is less than another time value. More... | |
constexpr friend bool | operator<= (const Time &a, const Time &b) noexcept |
Check if a time value is less than or equal to another time value. More... | |
constexpr friend bool | operator> (const Time &a, const Time &b) noexcept |
Check if a time value is greater than another time value. More... | |
constexpr friend bool | operator>= (const Time &a, const Time &b) noexcept |
Check if a time value is greater than or equal to another time value. More... | |
constexpr friend Time | operator+ (Time a) noexcept |
Get the additive identity of a time value. More... | |
constexpr friend Time | operator- (Time a) noexcept |
Get the additive inverse of a time value. More... | |
constexpr friend Time | operator+ (Time a, Time b) noexcept |
Add two time values. More... | |
constexpr friend Time | operator- (Time a, Time b) noexcept |
Subtract a time value from another. More... | |
Time duration value wrapper.
T | scalar type to use as the representation for the underlying duration. |
Period | period corresponding to the value 1 of the underlying time representation type, measured in seconds, expressed as a standard ratio type. |
using donut::Time< T, Period >::Duration = std::chrono::duration<T, Period> |
Underlying duration type.
|
constexprdefaultnoexcept |
Construct a time value of 0.
|
inlineconstexprnoexcept |
Construct a time value from a duration.
duration | the duration to initialize the time value to. |
|
inlineconstexprnoexcept |
Construct a time value from a number of seconds.
seconds | the number of seconds to initialize the time value to. |
|
inlineconstexprnoexcept |
Construct a time value from a number of milliseconds.
milliseconds | the number of milliseconds to initialize the time value to. |
|
inlineconstexprnoexcept |
Construct a time value from a number of microseconds.
microseconds | the number of microseconds to initialize the time value to. |
|
inlineconstexprnoexcept |
Construct a time value from a number of nanoseconds.
nanoseconds | the number of microseconds to initialize the time value to. |
|
inlineconstexprnoexcept |
Construct a time value from a number of minutes.
minutes | the number of minutes to initialize the time value to. |
|
inlineconstexprnoexcept |
Construct a time value from a number of hours.
hours | the number of hours to initialize the time value to. |
|
inlineconstexprnoexcept |
Convert a time value to its underlying duration type.
|
inlineconstexprnoexcept |
Convert a time value to its underlying scalar type.
|
inlineconstexprnoexcept |
Add time to this time value.
deltaTime | the time delta to add to this value. |
*this
, for chaining.
|
inlineconstexprnoexcept |
Subtract time from this time value.
deltaTime | the time delta to subtract from this value. |
*this
, for chaining.
|
inlineconstexprnoexcept |
Subtract time from this value and then check if it reached a given target time value.
deltaTime | the time delta to subtract from this value. |
targetTime | target time. |
|
inlineconstexprnoexcept |
Add time to this value and then check if it reached a given target time value.
deltaTime | the time delta to add to this value. |
targetTime | target time. |
|
inlineconstexprnoexcept |
Subtract time from this value and then check how many times it reached 0 while looping back to a given time interval.
deltaTime | the time delta to subtract from this value. |
interval | loop interval duration. |
|
inlineconstexprnoexcept |
Add time to this value and then check how many times it reached a given time interval while looping back to 0.
deltaTime | the time delta to add to this value. |
interval | loop interval duration. |
|
inlineconstexprnoexcept |
Update a countdown loop with a boolean trigger that determines whether the loop is active or not.
An inactive loop will continue counting down to 0 but will not loop back around to the interval time and will always return 0.
deltaTime | the time delta to subtract from this value. |
interval | loop interval duration. |
active | whether the loop is currently active or not. |
|
inlineconstexprnoexcept |
Update a countup loop with a boolean trigger that determines whether the loop is active or not.
An inactive loop will reset itself to 0 and will always return 0.
deltaTime | the time delta to add to this value. |
interval | loop interval duration. |
active | whether the loop is currently active or not. |
|
friend |
Compare two time values for equality.
a | first time value. |
b | second time value. |
|
friend |
Compare two time values for inequality.
a | first time value. |
b | second time value. |
|
friend |
Check if a time value is less than another time value.
a | first time value. |
b | second time value. |
|
friend |
Check if a time value is less than or equal to another time value.
a | first time value. |
b | second time value. |
|
friend |
Check if a time value is greater than another time value.
a | first time value. |
b | second time value. |
|
friend |
Check if a time value is greater than or equal to another time value.
a | first time value. |
b | second time value. |
|
friend |
Get the additive identity of a time value.
a | time value. |
|
friend |
Get the additive inverse of a time value.
a | time value. |
|
friend |
Add two time values.
a | first time value. |
b | second time value. |
|
friend |
Subtract a time value from another.
a | first time value. |
b | second time value. |