SDL Utility
|
This class wraps std::chrono::duration and defines some conversions for commonly used times. More...
#include <Time.hpp>
Public Member Functions | |
Time () | |
Default constructor. Constructs a time with value 0. More... | |
template<typename Rep = Int64, typename Period = std::ratio<1>> | |
Rep | AsValue () const |
Returns the stored time in the specified format as a scalar. More... | |
float | AsSeconds () const |
Returns the stored time in seconds. More... | |
Int32 | AsMilliseconds () const |
Returns the stored time in milliseconds. More... | |
Int64 | AsMicroseconds () const |
Returns the stored time in microseconds. More... | |
template<typename Rep = Int64, typename Period = std::ratio<1>> | |
std::chrono::duration< Rep, Period > | AsChrono () const |
Returns the stored time in the specified format as a std::duration. More... | |
std::chrono::seconds | AsChronoSeconds () const |
Returns the stored time in std::chrono::seconds. More... | |
std::chrono::milliseconds | AsChronoMilliseconds () const |
Returns the stored time in std::chrono::milliseconds. More... | |
std::chrono::microseconds | AsChronoMicroseconds () const |
Returns the stored time in std::chrono::microseconds. More... | |
Static Public Member Functions | |
template<typename Rep = Int64, typename Period = std::ratio<1>> | |
static Time | Create (const Rep &duration) |
Stores the given scalar as a time, using the given format. More... | |
template<typename Rep = Int64, typename Period = std::ratio<1>> | |
static Time | Create (const std::chrono::duration< Rep, Period > &duration) |
Stores the given std::duration. More... | |
static Time | Now () |
Creates a Time object storing the current point in time. More... | |
Friends | |
Time | Seconds (float seconds) |
Creates a Time object from a given number of seconds. More... | |
Time | Milliseconds (Int32 milliseconds) |
Creates a Time object from a given number of milliseconds. More... | |
Time | Microseconds (Int64 microseconds) |
Creates a Time object from a given number of microseconds. More... | |
bool | operator== (const Time &left, const Time &right) |
Overload of == operator comparing two Times. More... | |
bool | operator!= (const Time &left, const Time &right) |
Overload of != operator comparing two Times. More... | |
bool | operator< (const Time &left, const Time &right) |
Overload of < operator comparing two Times. More... | |
bool | operator> (const Time &left, const Time &right) |
Overload of > operator comparing two Times. More... | |
bool | operator<= (const Time &left, const Time &right) |
Overload of <= operator comparing two Times. More... | |
bool | operator>= (const Time &left, const Time &right) |
Overload of < operator comparing two Times. More... | |
Time | operator- (const Time &right) |
Overload of the unary - operator. More... | |
Time | operator+ (const Time &left, const Time &right) |
Overload of + operator to add two Times. More... | |
Time & | operator+= (Time &left, const Time &right) |
Overload of += operator to add two Times. More... | |
Time | operator- (const Time &left, const Time &right) |
Overload of - operator to subtract two Times. More... | |
Time & | operator-= (Time &left, const Time &right) |
Overload of -= operator to subtract two Times. More... | |
Time | operator* (const Time &left, float right) |
Overload of * operator to multiply a Time with a scalar. More... | |
Time | operator* (const Time &left, Int64 right) |
Overload of * operator to multiply a Time with a scalar. More... | |
Time | operator* (float left, const Time &right) |
Overload of * operator to multiply a Time with a scalar. More... | |
Time | operator* (Int64 left, const Time &right) |
Overload of * operator to multiply a Time with a scalar. More... | |
Time & | operator*= (Time &left, float right) |
Overload of *= operator to multiply a Time with a scalar. More... | |
Time & | operator*= (Time &left, Int64 right) |
Overload of *= operator to multiply a Time with a scalar. More... | |
Time | operator/ (const Time &left, float right) |
Overload of / operator to divide a Time by a scalar. More... | |
Time | operator/ (const Time &left, Int64 right) |
Overload of / operator to divide a Time by a scalar. More... | |
Time & | operator/= (Time &left, float right) |
Overload of /= operator to divide a Time by a scalar. More... | |
Time & | operator/= (Time &left, Int64 right) |
Overload of /= operator to divide a Time by a scalar. More... | |
float | operator/ (const Time &left, const Time &right) |
Overload of / operator to divide two Times. More... | |
Time | operator% (const Time &left, const Time &right) |
Overload of % operator to calculate the modulo of a Time. More... | |
Time & | operator%= (Time &left, const Time &right) |
Overload of % operator to calculate the modulo of a Time. More... | |
This class wraps std::chrono::duration and defines some conversions for commonly used times.
Time::Time | ( | ) |
Default constructor. Constructs a time with value 0.
|
inline |
Returns the stored time in the specified format as a std::duration.
Rep | The datatype to be returned |
Period | An std::ratio representing the resolution of the time format. E.g. the number of seconds per time step |
std::chrono::microseconds Time::AsChronoMicroseconds | ( | ) | const |
Returns the stored time in std::chrono::microseconds.
std::chrono::milliseconds Time::AsChronoMilliseconds | ( | ) | const |
Returns the stored time in std::chrono::milliseconds.
std::chrono::seconds Time::AsChronoSeconds | ( | ) | const |
Returns the stored time in std::chrono::seconds.
Int64 Time::AsMicroseconds | ( | ) | const |
Returns the stored time in microseconds.
Int32 Time::AsMilliseconds | ( | ) | const |
Returns the stored time in milliseconds.
float Time::AsSeconds | ( | ) | const |
Returns the stored time in seconds.
|
inline |
Returns the stored time in the specified format as a scalar.
Rep | The datatype to be returned |
Period | An std::ratio representing the resolution of the time format. E.g. the number of seconds per time step |
|
inlinestatic |
Stores the given scalar as a time, using the given format.
Rep | The datatype to be returned |
Period | An std::ratio representing the resolution of the time format. E.g. the number of seconds per time step |
|
inlinestatic |
Stores the given std::duration.
Rep | The datatype to be returned |
Period | An std::ratio representing the resolution of the time format. E.g. the number of seconds per time step |
|
inlinestatic |
Overload of != operator comparing two Times.
left | Left operand |
right | Right operand |
Overload of % operator to calculate the modulo of a Time.
left | Left operand |
right | Right operand |
left
% right
Overload of % operator to calculate the modulo of a Time.
left | Left operand |
right | Right operand |
left
Overload of * operator to multiply a Time with a scalar.
left | Left operand |
right | Right operand |
left
scaled by a factor of right
Overload of * operator to multiply a Time with a scalar.
left | Left operand |
right | Right operand |
left
scaled by a factor of right
Overload of * operator to multiply a Time with a scalar.
left | Left operand |
right | Right operand |
right
scaled by a factor of left
Overload of * operator to multiply a Time with a scalar.
left | Left operand |
right | Right operand |
right
scaled by a factor of left
Overload of *= operator to multiply a Time with a scalar.
left | Left operand |
right | Right operand |
left
Overload of *= operator to multiply a Time with a scalar.
left | Left operand |
right | Right operand |
left
Overload of + operator to add two Times.
left | Left operand |
right | Right operand |
Overload of += operator to add two Times.
left | Left operand |
right | Right operand |
left
Overload of - operator to subtract two Times.
left | Left operand |
right | Right operand |
Overload of the unary - operator.
right | Right operand |
right
Overload of -= operator to subtract two Times.
left | Left operand |
right | Right operand |
left
Overload of / operator to divide two Times.
left | Left operand |
right | Right operand |
Overload of / operator to divide a Time by a scalar.
left | Left operand |
right | Right operand |
left
divided by right
Overload of / operator to divide a Time by a scalar.
left | Left operand |
right | Right operand |
left
divided by right
Overload of /= operator to divide a Time by a scalar.
left | Left operand |
right | Right operand |
left
Overload of /= operator to divide a Time by a scalar.
left | Left operand |
right | Right operand |
left
Overload of < operator comparing two Times.
left | Left operand |
right | Right operand |
left
is less than right
Overload of <= operator comparing two Times.
left | Left operand |
right | Right operand |
left
is less than or equal to right
Overload of == operator comparing two Times.
left | Left operand |
right | Right operand |
Overload of > operator comparing two Times.
left | Left operand |
right | Right operand |
left
is greater than right
Overload of < operator comparing two Times.
left | Left operand |
right | Right operand |
left
is greater than or equal to right
|
friend |