Flutter Engine
The Flutter Engine
Public Member Functions | Static Public Member Functions | List of all members
fml::TimeDelta Class Reference

#include <time_delta.h>

Public Member Functions

constexpr TimeDelta ()=default
 
constexpr int64_t ToNanoseconds () const
 
constexpr int64_t ToMicroseconds () const
 
constexpr int64_t ToMilliseconds () const
 
constexpr int64_t ToSeconds () const
 
constexpr double ToNanosecondsF () const
 
constexpr double ToMicrosecondsF () const
 
constexpr double ToMillisecondsF () const
 
constexpr double ToSecondsF () const
 
constexpr TimeDelta operator- (TimeDelta other) const
 
constexpr TimeDelta operator+ (TimeDelta other) const
 
constexpr TimeDelta operator/ (int64_t divisor) const
 
constexpr int64_t operator/ (TimeDelta other) const
 
constexpr TimeDelta operator* (int64_t multiplier) const
 
constexpr TimeDelta operator% (TimeDelta other) const
 
bool operator== (TimeDelta other) const
 
bool operator!= (TimeDelta other) const
 
bool operator< (TimeDelta other) const
 
bool operator<= (TimeDelta other) const
 
bool operator> (TimeDelta other) const
 
bool operator>= (TimeDelta other) const
 
struct timespec ToTimespec ()
 

Static Public Member Functions

static constexpr TimeDelta Zero ()
 
static constexpr TimeDelta Min ()
 
static constexpr TimeDelta Max ()
 
static constexpr TimeDelta FromNanoseconds (int64_t nanos)
 
static constexpr TimeDelta FromMicroseconds (int64_t micros)
 
static constexpr TimeDelta FromMilliseconds (int64_t millis)
 
static constexpr TimeDelta FromSeconds (int64_t seconds)
 
static constexpr TimeDelta FromSecondsF (double seconds)
 
static constexpr TimeDelta FromMillisecondsF (double millis)
 
static constexpr TimeDelta FromTimespec (struct timespec ts)
 

Detailed Description

Definition at line 29 of file time_delta.h.

Constructor & Destructor Documentation

◆ TimeDelta()

constexpr fml::TimeDelta::TimeDelta ( )
constexprdefault

Member Function Documentation

◆ FromMicroseconds()

static constexpr TimeDelta fml::TimeDelta::FromMicroseconds ( int64_t  micros)
inlinestaticconstexpr

Definition at line 43 of file time_delta.h.

43 {
44 return FromNanoseconds(micros * 1000);
45 }
static constexpr TimeDelta FromNanoseconds(int64_t nanos)
Definition: time_delta.h:40

◆ FromMilliseconds()

static constexpr TimeDelta fml::TimeDelta::FromMilliseconds ( int64_t  millis)
inlinestaticconstexpr

Definition at line 46 of file time_delta.h.

46 {
47 return FromMicroseconds(millis * 1000);
48 }
static constexpr TimeDelta FromMicroseconds(int64_t micros)
Definition: time_delta.h:43

◆ FromMillisecondsF()

static constexpr TimeDelta fml::TimeDelta::FromMillisecondsF ( double  millis)
inlinestaticconstexpr

Definition at line 57 of file time_delta.h.

57 {
58 return FromNanoseconds(millis * (1000.0 * 1000.0));
59 }

◆ FromNanoseconds()

static constexpr TimeDelta fml::TimeDelta::FromNanoseconds ( int64_t  nanos)
inlinestaticconstexpr

Definition at line 40 of file time_delta.h.

40 {
41 return TimeDelta(nanos);
42 }
constexpr TimeDelta()=default

◆ FromSeconds()

static constexpr TimeDelta fml::TimeDelta::FromSeconds ( int64_t  seconds)
inlinestaticconstexpr

Definition at line 49 of file time_delta.h.

49 {
50 return FromMilliseconds(seconds * 1000);
51 }
static constexpr TimeDelta FromMilliseconds(int64_t millis)
Definition: time_delta.h:46

◆ FromSecondsF()

static constexpr TimeDelta fml::TimeDelta::FromSecondsF ( double  seconds)
inlinestaticconstexpr

Definition at line 53 of file time_delta.h.

53 {
54 return FromNanoseconds(seconds * (1000.0 * 1000.0 * 1000.0));
55 }

◆ FromTimespec()

static constexpr TimeDelta fml::TimeDelta::FromTimespec ( struct timespec  ts)
inlinestaticconstexpr

Definition at line 106 of file time_delta.h.

106 {
107 return TimeDelta::FromSeconds(ts.tv_sec) +
108 TimeDelta::FromNanoseconds(ts.tv_nsec);
109 }
static constexpr TimeDelta FromSeconds(int64_t seconds)
Definition: time_delta.h:49

◆ Max()

static constexpr TimeDelta fml::TimeDelta::Max ( )
inlinestaticconstexpr

Definition at line 37 of file time_delta.h.

37 {
39 }
static float max(float r, float g, float b)
Definition: hsl.cpp:49

◆ Min()

static constexpr TimeDelta fml::TimeDelta::Min ( )
inlinestaticconstexpr

Definition at line 34 of file time_delta.h.

34 {
36 }
static float min(float r, float g, float b)
Definition: hsl.cpp:48

◆ operator!=()

bool fml::TimeDelta::operator!= ( TimeDelta  other) const
inline

Definition at line 100 of file time_delta.h.

100{ return delta_ != other.delta_; }

◆ operator%()

constexpr TimeDelta fml::TimeDelta::operator% ( TimeDelta  other) const
inlineconstexpr

Definition at line 95 of file time_delta.h.

95 {
96 return TimeDelta::FromNanoseconds(delta_ % other.delta_);
97 }

◆ operator*()

constexpr TimeDelta fml::TimeDelta::operator* ( int64_t  multiplier) const
inlineconstexpr

Definition at line 91 of file time_delta.h.

91 {
92 return TimeDelta::FromNanoseconds(delta_ * multiplier);
93 }

◆ operator+()

constexpr TimeDelta fml::TimeDelta::operator+ ( TimeDelta  other) const
inlineconstexpr

Definition at line 79 of file time_delta.h.

79 {
80 return TimeDelta::FromNanoseconds(delta_ + other.delta_);
81 }

◆ operator-()

constexpr TimeDelta fml::TimeDelta::operator- ( TimeDelta  other) const
inlineconstexpr

Definition at line 75 of file time_delta.h.

75 {
76 return TimeDelta::FromNanoseconds(delta_ - other.delta_);
77 }

◆ operator/() [1/2]

constexpr TimeDelta fml::TimeDelta::operator/ ( int64_t  divisor) const
inlineconstexpr

Definition at line 83 of file time_delta.h.

83 {
84 return TimeDelta::FromNanoseconds(delta_ / divisor);
85 }

◆ operator/() [2/2]

constexpr int64_t fml::TimeDelta::operator/ ( TimeDelta  other) const
inlineconstexpr

Definition at line 87 of file time_delta.h.

87 {
88 return delta_ / other.delta_;
89 }

◆ operator<()

bool fml::TimeDelta::operator< ( TimeDelta  other) const
inline

Definition at line 101 of file time_delta.h.

101{ return delta_ < other.delta_; }

◆ operator<=()

bool fml::TimeDelta::operator<= ( TimeDelta  other) const
inline

Definition at line 102 of file time_delta.h.

102{ return delta_ <= other.delta_; }

◆ operator==()

bool fml::TimeDelta::operator== ( TimeDelta  other) const
inline

Definition at line 99 of file time_delta.h.

99{ return delta_ == other.delta_; }

◆ operator>()

bool fml::TimeDelta::operator> ( TimeDelta  other) const
inline

Definition at line 103 of file time_delta.h.

103{ return delta_ > other.delta_; }

◆ operator>=()

bool fml::TimeDelta::operator>= ( TimeDelta  other) const
inline

Definition at line 104 of file time_delta.h.

104{ return delta_ >= other.delta_; }

◆ ToMicroseconds()

constexpr int64_t fml::TimeDelta::ToMicroseconds ( ) const
inlineconstexpr

Definition at line 62 of file time_delta.h.

62{ return ToNanoseconds() / 1000; }
constexpr int64_t ToNanoseconds() const
Definition: time_delta.h:61

◆ ToMicrosecondsF()

constexpr double fml::TimeDelta::ToMicrosecondsF ( ) const
inlineconstexpr

Definition at line 67 of file time_delta.h.

67{ return delta_ / 1000.0; }

◆ ToMilliseconds()

constexpr int64_t fml::TimeDelta::ToMilliseconds ( ) const
inlineconstexpr

Definition at line 63 of file time_delta.h.

63{ return ToMicroseconds() / 1000; }
constexpr int64_t ToMicroseconds() const
Definition: time_delta.h:62

◆ ToMillisecondsF()

constexpr double fml::TimeDelta::ToMillisecondsF ( ) const
inlineconstexpr

Definition at line 68 of file time_delta.h.

68 {
69 return delta_ / (1000.0 * 1000.0);
70 }

◆ ToNanoseconds()

constexpr int64_t fml::TimeDelta::ToNanoseconds ( ) const
inlineconstexpr

Definition at line 61 of file time_delta.h.

61{ return delta_; }

◆ ToNanosecondsF()

constexpr double fml::TimeDelta::ToNanosecondsF ( ) const
inlineconstexpr

Definition at line 66 of file time_delta.h.

66{ return delta_; }

◆ ToSeconds()

constexpr int64_t fml::TimeDelta::ToSeconds ( ) const
inlineconstexpr

Definition at line 64 of file time_delta.h.

64{ return ToMilliseconds() / 1000; }
constexpr int64_t ToMilliseconds() const
Definition: time_delta.h:63

◆ ToSecondsF()

constexpr double fml::TimeDelta::ToSecondsF ( ) const
inlineconstexpr

Definition at line 71 of file time_delta.h.

71 {
72 return delta_ / (1000.0 * 1000.0 * 1000.0);
73 }

◆ ToTimespec()

struct timespec fml::TimeDelta::ToTimespec ( )
inline

Definition at line 110 of file time_delta.h.

110 {
111 struct timespec ts;
112 constexpr int64_t kNanosecondsPerSecond = 1000000000ll;
113 ts.tv_sec = static_cast<time_t>(ToSeconds());
114 ts.tv_nsec = delta_ % kNanosecondsPerSecond;
115 return ts;
116 }
constexpr int64_t ToSeconds() const
Definition: time_delta.h:64
constexpr intptr_t kNanosecondsPerSecond
Definition: globals.h:567

◆ Zero()

static constexpr TimeDelta fml::TimeDelta::Zero ( )
inlinestaticconstexpr

Definition at line 33 of file time_delta.h.

33{ return TimeDelta(); }

The documentation for this class was generated from the following file: