Lumiera  0.pre.03
»edit your freedom«
real-clock.hpp
Go to the documentation of this file.
1 /*
2  REAL-CLOCK.hpp - convenience front-end to access the system clock
3 
4  Copyright (C)
5  2012, Hermann Vosseler <Ichthyostega@web.de>
6 
7   **Lumiera** is free software; you can redistribute it and/or modify it
8   under the terms of the GNU General Public License as published by the
9   Free Software Foundation; either version 2 of the License, or (at your
10   option) any later version. See the file COPYING for further details.
11 
12 */
13 
28 #ifndef VAULT_REAL_CLOCK_H
29 #define VAULT_REAL_CLOCK_H
30 
31 
32 #include "lib/error.hpp"
33 #include "lib/time/timevalue.hpp"
34 
35 namespace vault {
36 
37  using lib::time::Time;
39  using lib::time::Offset;
40 
41 
45  class RealClock
46  {
47 
48 
49  public:
50 
51  static Time
52  now()
53  {
54  return Time{_readSystemTime()};
55  }
56 
57  static bool
58  wasRecently (Time event)
59  {
60  Offset past{event, now()};
61  return Time::ZERO <= past
62  and past < CONSIDERED_RECENT;
63  }
64 
65 
66  private:
67  static TimeValue _readSystemTime();
68  static const Offset CONSIDERED_RECENT;
69  };
70 
71 
72 
73 } // namespace vault
74 #endif
Lumiera&#39;s internal time value datatype.
Definition: timevalue.hpp:299
Lumiera error handling (C++ interface).
static const Offset CONSIDERED_RECENT
events during the last ms are considered "recent" for the purpose of testing
Definition: real-clock.hpp:68
Offset measures a distance in time.
Definition: timevalue.hpp:358
Convenience frontend to access the current raw system time.
Definition: real-clock.hpp:45
a family of time value like entities and their relationships.
basic constant internal time value.
Definition: timevalue.hpp:133
Vault-Layer implementation namespace root.