Add more operators to Timestamp

This commit is contained in:
2020-11-16 23:53:11 +01:00
parent d7f8efa5f4
commit 673e043950

View File

@@ -23,6 +23,18 @@ namespace openVulkanoCpp::Math
[[nodiscard]] uint64_t GetNanos() const { return timestamp; }
[[nodiscard]] double GetSeconds() const { return timestamp * NANOS_TO_SECONDS; }
Timestamp& operator+=(const Timestamp& rhs)
{
timestamp += rhs.timestamp;
return *this;
}
Timestamp& operator-=(const Timestamp& rhs)
{
timestamp -= rhs.timestamp;
return *this;
}
};
inline bool operator==(const Timestamp& lhs, const Timestamp& rhs)
@@ -54,4 +66,19 @@ namespace openVulkanoCpp::Math
{
return !(rhs < lhs);
}
inline Timestamp operator-(const Timestamp& lhs, const Timestamp& rhs)
{
return Timestamp(lhs.GetNanos() - rhs.GetNanos());
}
inline Timestamp operator+(const Timestamp& lhs, const Timestamp& rhs)
{
return Timestamp(lhs.GetNanos() + rhs.GetNanos());
}
inline double operator/(const Timestamp& lhs, const Timestamp& rhs)
{
return lhs.GetNanos() / static_cast<double>(rhs.GetNanos());
}
}