GlPortal Class Reference  0.1.1
Source code documentation of the free and open 3D action puzzle game.
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
TimeDelta.hpp
Go to the documentation of this file.
1 #ifndef RADIX_TIME_DELTA_HPP
2 #define RADIX_TIME_DELTA_HPP
3 
4 #include <cstdint>
5 
6 namespace radix {
7 
8 class TimeDelta final {
9 private:
10  using Type = uint32_t;
12 
13  constexpr TimeDelta(Type microsecs) : value(microsecs) {}
14  constexpr TimeDelta(double microsecs) : value(static_cast<Type>(microsecs)) {}
15  constexpr TimeDelta(int microsecs) : value(static_cast<Type>(microsecs)) {}
16 
17 public:
18  constexpr TimeDelta() : value(0) {}
19  constexpr operator uint32_t() const { return value; }
20 
21  static constexpr TimeDelta sec(double t) { return TimeDelta(t*1000000); }
22  static constexpr TimeDelta sec(int t) { return TimeDelta(t*1000000); }
23  static constexpr TimeDelta sec(Type t) { return TimeDelta(t*1000000); }
24  constexpr Type sec() const { return value / 1000000; }
25  constexpr double sec_d() const { return value / 1000000.; }
26  static constexpr TimeDelta msec(double t) { return TimeDelta(t*1000); }
27  static constexpr TimeDelta msec(int t) { return TimeDelta(t*1000); }
28  static constexpr TimeDelta msec(Type t) { return TimeDelta(t*1000); }
29  constexpr Type msec() const { return value / 1000; }
30  constexpr double msec_d() const { return value / 1000.; }
31  static constexpr TimeDelta usec(double t) { return TimeDelta(t); }
32  static constexpr TimeDelta usec(int t) { return TimeDelta(t); }
33  static constexpr TimeDelta usec(Type t) { return TimeDelta(t); }
34  constexpr Type usec() const { return value; }
35  constexpr double usec_d() const { return static_cast<double>(value); }
36 };
37 
38 using TDelta = TimeDelta;
39 
40 } /* namespace radix */
41 
42 #endif /* RADIX_TIME_DELTA_HPP */
constexpr TimeDelta(Type microsecs)
Definition: TimeDelta.hpp:13
static constexpr TimeDelta sec(double t)
Definition: TimeDelta.hpp:21
Definition: GameController.hpp:7
static constexpr TimeDelta usec(Type t)
Definition: TimeDelta.hpp:33
static constexpr TimeDelta msec(Type t)
Definition: TimeDelta.hpp:28
constexpr Type msec() const
Definition: TimeDelta.hpp:29
uint32_t Type
Definition: TimeDelta.hpp:10
static constexpr TimeDelta sec(int t)
Definition: TimeDelta.hpp:22
static constexpr TimeDelta usec(double t)
Definition: TimeDelta.hpp:31
static constexpr TimeDelta sec(Type t)
Definition: TimeDelta.hpp:23
constexpr double usec_d() const
Definition: TimeDelta.hpp:35
Definition: TimeDelta.hpp:8
static constexpr TimeDelta usec(int t)
Definition: TimeDelta.hpp:32
constexpr TimeDelta(int microsecs)
Definition: TimeDelta.hpp:15
constexpr double sec_d() const
Definition: TimeDelta.hpp:25
constexpr Type usec() const
Definition: TimeDelta.hpp:34
Type value
Definition: TimeDelta.hpp:11
static constexpr TimeDelta msec(double t)
Definition: TimeDelta.hpp:26
static constexpr TimeDelta msec(int t)
Definition: TimeDelta.hpp:27
constexpr TimeDelta(double microsecs)
Definition: TimeDelta.hpp:14
constexpr double msec_d() const
Definition: TimeDelta.hpp:30
constexpr TimeDelta()
Definition: TimeDelta.hpp:18
constexpr Type sec() const
Definition: TimeDelta.hpp:24