Create Time.hpp

This commit is contained in:
tobid7 2021-12-01 20:29:22 +01:00 committed by GitHub
parent 61285be23e
commit d22b7b718c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

82
internal/Time.hpp Normal file
View File

@ -0,0 +1,82 @@
namespace rnd7 {
class Time {
public:
Time();
float asSeconds() const;
int asMilliseconds() const;
long asMicroseconds() const;
static const Time Zero_;
private:
friend Time seconds(float);
friend Time milliseconds(int);
friend Time microseconds(long);
explicit Time(long microseconds);
private:
long m_microseconds; ///< Time value stored as microseconds
};
Time seconds(float amount);
Time milliseconds(int amount);
Time microseconds(long amount);
bool operator==(Time left, Time right);
bool operator!=(Time left, Time right);
bool operator<(Time left, Time right);
bool operator>(Time left, Time right);
bool operator<=(Time left, Time right);
bool operator>=(Time left, Time right);
Time operator-(Time right);
Time operator+(Time left, Time right);
Time &operator+=(Time &left, Time right);
Time operator-(Time left, Time right);
Time &operator-=(Time &left, Time right);
Time operator*(Time left, float right);
Time operator*(Time left, long right);
Time operator*(float left, Time right);
Time operator*(long left, Time right);
Time &operator*=(Time &left, float right);
Time &operator*=(Time &left, long right);
Time operator/(Time left, float right);
Time operator/(Time left, long right);
Time &operator/=(Time &left, float right);
Time &operator/=(Time &left, long right);
float operator/(Time left, Time right);
Time operator%(Time left, Time right);
Time &operator%=(Time &left, Time right);
}