Adding Spectre/Math/Time
This commit is contained in:
parent
4d69ff3a18
commit
6de6028ba4
3 changed files with 153 additions and 1 deletions
50
include/Spectre/Math/Time.h
Normal file
50
include/Spectre/Math/Time.h
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
|
||||
#ifndef SPECTRE_MATH_TIME_H
|
||||
#define SPECTRE_MATH_TIME_H
|
||||
|
||||
namespace sp {
|
||||
|
||||
class Time {
|
||||
public :
|
||||
Time(long value = 0);
|
||||
|
||||
double seconds() const;
|
||||
|
||||
int milliseconds() const;
|
||||
|
||||
long microseconds() const;
|
||||
|
||||
// ----------------------------
|
||||
// Helper construct functions
|
||||
// ----------------------------
|
||||
static Time seconds(double value);
|
||||
static Time milliseconds(int value);
|
||||
static Time microseconds(long value);
|
||||
|
||||
private :
|
||||
|
||||
// In microseconds.
|
||||
long m_value;
|
||||
};
|
||||
|
||||
// ----------------------------
|
||||
// Compare
|
||||
// ----------------------------
|
||||
bool operator ==(const Time& a, const Time& b);
|
||||
bool operator !=(const Time& a, const Time& b);
|
||||
bool operator <(const Time& a, const Time& b);
|
||||
bool operator <=(const Time& a, const Time& b);
|
||||
bool operator >(const Time& a, const Time& b);
|
||||
bool operator >=(const Time& a, const Time& b);
|
||||
|
||||
// ----------------------------
|
||||
// Arithmetic
|
||||
// ----------------------------
|
||||
Time operator +(const Time& a, const Time& b);
|
||||
Time& operator +=(Time& a, const Time& b);
|
||||
Time operator -(const Time& a, const Time& b);
|
||||
Time& operator -=(Time& a, const Time& b);
|
||||
|
||||
}; // namespace sp
|
||||
|
||||
#endif /* SPECTRE_MATH_TIME_H */
|
||||
Loading…
Add table
Add a link
Reference in a new issue