XII Release 0.1.0
Loading...
Searching...
No Matches
xiiTime Struct Reference

The time class encapsulates a double value storing the time in seconds. More...

#include <Time.h>

Public Member Functions

 XII_DECLARE_POD_TYPE ()
 
XII_ALWAYS_INLINE constexpr xiiTime ()=default
 The default constructor sets the time to zero.
 
XII_ALWAYS_INLINE constexpr bool IsZero () const
 Returns true if the stored time is exactly zero. That typically means the value was not changed from the default.
 
XII_ALWAYS_INLINE constexpr bool IsNegative () const
 Checks for a negative time value.
 
XII_ALWAYS_INLINE constexpr bool IsPositive () const
 Checks for a positive time value. This does not include zero.
 
XII_ALWAYS_INLINE constexpr bool IsZeroOrNegative () const
 Returns true if the stored time is zero or negative.
 
XII_ALWAYS_INLINE constexpr bool IsZeroOrPositive () const
 Returns true if the stored time is zero or positive.
 
constexpr float AsFloatInSeconds () const
 Returns the time as a float value (in seconds).
 
constexpr double GetNanoseconds () const
 Returns the nanoseconds value.
 
constexpr double GetMicroseconds () const
 Returns the microseconds value.
 
constexpr double GetMilliseconds () const
 Returns the milliseconds value.
 
constexpr double GetSeconds () const
 Returns the seconds value.
 
constexpr double GetMinutes () const
 Returns the minutes value.
 
constexpr double GetHours () const
 Returns the hours value.
 
constexpr void operator-= (const xiiTime &other)
 Subtracts the time value of "other" from this instances value.
 
constexpr void operator+= (const xiiTime &other)
 Adds the time value of "other" to this instances value.
 
constexpr void operator*= (double fFactor)
 Multiplies the time by the given factor.
 
constexpr void operator/= (double fFactor)
 Divides the time by the given factor.
 
constexpr xiiTime operator- (const xiiTime &other) const
 Returns the difference: "this instance - other".
 
constexpr xiiTime operator+ (const xiiTime &other) const
 Returns the sum: "this instance + other".
 
constexpr xiiTime operator- () const
 
constexpr bool operator== (const xiiTime &rhs) const
 
constexpr std::partial_ordering operator<=> (const xiiTime &rhs) const
 

Static Public Member Functions

static xiiTime Now ()
 Gets the current time.
 
XII_ALWAYS_INLINE static constexpr xiiTime MakeFromNanoseconds (double fNanoseconds)
 Creates an instance of xiiTime that was initialized from nanoseconds.
 
XII_ALWAYS_INLINE static constexpr xiiTime MakeFromMicroseconds (double fMicroseconds)
 Creates an instance of xiiTime that was initialized from microseconds.
 
XII_ALWAYS_INLINE static constexpr xiiTime MakeFromMilliseconds (double fMilliseconds)
 Creates an instance of xiiTime that was initialized from milliseconds.
 
XII_ALWAYS_INLINE static constexpr xiiTime MakeFromSeconds (double fSeconds)
 Creates an instance of xiiTime that was initialized from seconds.
 
XII_ALWAYS_INLINE static constexpr xiiTime MakeFromMinutes (double fMinutes)
 Creates an instance of xiiTime that was initialized from minutes.
 
XII_ALWAYS_INLINE static constexpr xiiTime MakeFromHours (double fHours)
 Creates an instance of xiiTime that was initialized from hours.
 
XII_ALWAYS_INLINE static constexpr xiiTime MakeZero ()
 Creates an instance of xiiTime that was initialized with zero.
 

Detailed Description

The time class encapsulates a double value storing the time in seconds.

It offers convenient functions to get the time in other units. xiiTime is a high-precision time using the OS specific high-precision timing functions and may thus be used for profiling as well as simulation code.

Member Function Documentation

◆ AsFloatInSeconds()

XII_ALWAYS_INLINE float xiiTime::AsFloatInSeconds ( ) const
constexpr

Returns the time as a float value (in seconds).

Useful for simulation time steps etc. Please note that it is not recommended to use the float value for long running time calculations since the precision can deteriorate quickly. (Only use for delta times is recommended)


The documentation for this struct was generated from the following files: