summaryrefslogtreecommitdiffhomepage
path: root/src/timer-fwd.hpp
blob: 9831319a2d6b29c147861bfdf5d5808ab0a70bf3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#pragma once
#include <compare>

namespace Magnum::Math { template<class T> class Nanoseconds; }

namespace floormat {

using Ns = Math::Nanoseconds<int64_t>;
//long double operator/(Ns a, Ns b) noexcept;

struct Time final
{
    static Time now() noexcept;
    bool operator==(const Time&) const noexcept;
    std::strong_ordering operator<=>(const Time&) const noexcept;
    friend Ns operator-(const Time& a, const Time& b) noexcept;
    [[nodiscard]] Ns update(const Time& ts = now()) & noexcept;

    static float to_seconds(const Ns& ts) noexcept;
    static float to_milliseconds(const Ns& ts) noexcept;

    uint64_t stamp = init();

private:
    static uint64_t init() noexcept;
};

} // namespace floormat