3#include <Foundation/Basics.h>
4#include <Foundation/Configuration/StaticSubSystem.h>
19 [[nodiscard]] PL_ALWAYS_INLINE
constexpr static plTime Nanoseconds(
double fNanoseconds) {
return plTime(fNanoseconds * 0.000000001); }
23 [[nodiscard]] PL_ALWAYS_INLINE
constexpr static plTime Microseconds(
double fMicroseconds) {
return plTime(fMicroseconds * 0.000001); }
27 [[nodiscard]] PL_ALWAYS_INLINE
constexpr static plTime Milliseconds(
double fMilliseconds) {
return plTime(fMilliseconds * 0.001); }
31 [[nodiscard]] PL_ALWAYS_INLINE
constexpr static plTime Seconds(
double fSeconds) {
return plTime(fSeconds); }
35 [[nodiscard]] PL_ALWAYS_INLINE
constexpr static plTime Minutes(
double fMinutes) {
return plTime(fMinutes * 60); }
39 [[nodiscard]] PL_ALWAYS_INLINE
constexpr static plTime Hours(
double fHours) {
return plTime(fHours * 60 * 60); }
44 PL_DECLARE_POD_TYPE();
47 PL_ALWAYS_INLINE
constexpr plTime() =
default;
50 PL_ALWAYS_INLINE
constexpr bool IsZero()
const {
return m_fTime == 0.0; }
53 PL_ALWAYS_INLINE
constexpr bool IsNegative()
const {
return m_fTime < 0.0; }
56 PL_ALWAYS_INLINE
constexpr bool IsPositive()
const {
return m_fTime > 0.0; }
69 constexpr float AsFloatInSeconds()
const;
72 constexpr double GetNanoseconds()
const;
75 constexpr double GetMicroseconds()
const;
78 constexpr double GetMilliseconds()
const;
81 constexpr double GetSeconds()
const;
84 constexpr double GetMinutes()
const;
87 constexpr double GetHours()
const;
90 constexpr void operator-=(
const plTime& other);
93 constexpr void operator+=(
const plTime& other);
96 constexpr void operator*=(
double fFactor);
99 constexpr void operator/=(
double fFactor);
107 constexpr plTime operator-()
const;
109 constexpr bool operator<(
const plTime& rhs)
const {
return m_fTime < rhs.m_fTime; }
110 constexpr bool operator<=(
const plTime& rhs)
const {
return m_fTime <= rhs.m_fTime; }
111 constexpr bool operator>(
const plTime& rhs)
const {
return m_fTime > rhs.m_fTime; }
112 constexpr bool operator>=(
const plTime& rhs)
const {
return m_fTime >= rhs.m_fTime; }
113 constexpr bool operator==(
const plTime& rhs)
const {
return m_fTime == rhs.m_fTime; }
114 constexpr bool operator!=(
const plTime& rhs)
const {
return m_fTime != rhs.m_fTime; }
118 constexpr explicit plTime(
double fTime);
121 double m_fTime = 0.0;
124 PL_MAKE_SUBSYSTEM_STARTUP_FRIEND(Foundation, Time);
126 static void Initialize();
138#include <Foundation/Time/Implementation/Time_inl.h>
The time class encapsulates a double value storing the time in seconds.
Definition Time.h:12
PL_ALWAYS_INLINE constexpr bool IsPositive() const
Checks for a positive time value. This does not include zero.
Definition Time.h:56
PL_ALWAYS_INLINE static constexpr plTime MakeFromMilliseconds(double fMilliseconds)
Creates an instance of plTime that was initialized from milliseconds.
Definition Time.h:26
PL_ALWAYS_INLINE constexpr bool IsZeroOrNegative() const
Returns true if the stored time is zero or negative.
Definition Time.h:59
PL_ALWAYS_INLINE constexpr plTime()=default
The default constructor sets the time to zero.
PL_ALWAYS_INLINE constexpr bool IsNegative() const
Checks for a negative time value.
Definition Time.h:53
PL_ALWAYS_INLINE static constexpr plTime MakeFromSeconds(double fSeconds)
Creates an instance of plTime that was initialized from seconds.
Definition Time.h:30
PL_ALWAYS_INLINE static constexpr plTime MakeZero()
Creates an instance of plTime that was initialized with zero.
Definition Time.h:42
PL_ALWAYS_INLINE static constexpr plTime MakeFromHours(double fHours)
Creates an instance of plTime that was initialized from hours.
Definition Time.h:38
PL_ALWAYS_INLINE constexpr bool IsZero() const
Returns true if the stored time is exactly zero. That typically means the value was not changed from ...
Definition Time.h:50
PL_ALWAYS_INLINE constexpr bool IsZeroOrPositive() const
Returns true if the stored time is zero or positive.
Definition Time.h:62
PL_ALWAYS_INLINE static constexpr plTime MakeFromMicroseconds(double fMicroseconds)
Creates an instance of plTime that was initialized from microseconds.
Definition Time.h:22
PL_ALWAYS_INLINE static constexpr plTime MakeFromNanoseconds(double fNanoseconds)
Creates an instance of plTime that was initialized from nanoseconds.
Definition Time.h:18
PL_ALWAYS_INLINE static constexpr plTime MakeFromMinutes(double fMinutes)
Creates an instance of plTime that was initialized from minutes.
Definition Time.h:34