Honeycomb  0.1
Component-Model Framework
Clock.h
Go to the documentation of this file.
1 // Honeycomb, Copyright (C) 2015 NewGamePlus Inc. Distributed under the Boost Software License v1.0.
2 #pragma once
3 
6 
7 namespace honey
8 {
9 
11 struct SystemClock : private platform::SystemClock<SystemClock>
12 {
13 private:
14  typedef platform::SystemClock<SystemClock> Super;
15 public:
16  typedef Super::TimePoint TimePoint;
18  typedef Duration::Rep Rep;
20 
21  static const bool isMonotonic = false;
22 
24  static TimePoint now() { return Super::now(); }
25 
27  static time_t toStdTime(const TimePoint& t) { return time_t(Seconds(t.time()).count()); }
28 
30  static TimePoint fromStdTime(const time_t& t) { return TimePoint(Seconds(t)); }
31 };
32 
33 
35 struct MonoClock : private platform::MonoClock<MonoClock>
36 {
37 private:
38  typedef platform::MonoClock<MonoClock> Super;
39 public:
40  typedef Super::TimePoint TimePoint;
42  typedef Duration::Rep Rep;
44 
45  static const bool isMonotonic = true;
46 
48  static TimePoint now() { return Super::now(); }
49 };
50 
51 }
52 
Rep_ Rep
Definition: Duration.h:29
Period_ Period
Definition: Duration.h:30
static TimePoint now()
Get current time.
Definition: Clock.h:48
TimePoint::Duration Duration
Definition: Clock.h:17
System-wide monotonic clock. High-resolution and steady-rate time since application start...
Definition: Clock.h:35
Duration::Rep Rep
Definition: Clock.h:18
System-wide real-time clock. Low-resolution time since Unix Epoch, can possibly go backwards if chang...
Definition: Clock.h:11
Duration::Rep Rep
Definition: Clock.h:42
static time_t toStdTime(const TimePoint &t)
Convert to standard C time.
Definition: Clock.h:27
Super::TimePoint TimePoint
Definition: Clock.h:40
Duration::Period Period
Definition: Clock.h:19
static TimePoint fromStdTime(const time_t &t)
Convert from standard C time.
Definition: Clock.h:30
Duration::Period Period
Definition: Clock.h:43
static TimePoint now()
Get current time.
Definition: Clock.h:24
Dur Duration
Definition: TimePoint.h:16
static const bool isMonotonic
Definition: Clock.h:21
static const bool isMonotonic
Definition: Clock.h:45
Super::TimePoint TimePoint
Definition: Clock.h:16
TimePoint::Duration Duration
Definition: Clock.h:41
Global Honeycomb namespace.