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) Lumiera.org
5  2012, Hermann Vosseler <Ichthyostega@web.de>
6 
7  This program is free software; you can redistribute it and/or
8  modify it under the terms of the GNU General Public License as
9  published by the Free Software Foundation; either version 2 of
10  the License, or (at your option) any later version.
11 
12  This program is distributed in the hope that it will be useful,
13  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  GNU General Public License for more details.
16 
17  You should have received a copy of the GNU General Public License
18  along with this program; if not, write to the Free Software
19  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 
21 */
22 
37 #ifndef VAULT_REAL_CLOCK_H
38 #define VAULT_REAL_CLOCK_H
39 
40 
41 #include "lib/error.hpp"
42 #include "lib/time/timevalue.hpp"
43 
44 namespace vault {
45 
46  using lib::time::Time;
48  using lib::time::Offset;
49 
50 
54  class RealClock
55  {
56 
57 
58  public:
59 
60  static Time
61  now()
62  {
63  return Time{_readSystemTime()};
64  }
65 
66  static bool
67  wasRecently (Time event)
68  {
69  Offset past{event, now()};
70  return Time::ZERO <= past
71  and past < CONSIDERED_RECENT;
72  }
73 
74 
75  private:
76  static TimeValue _readSystemTime();
77  static const Offset CONSIDERED_RECENT;
78  };
79 
80 
81 
82 } // namespace vault
83 #endif
Lumiera&#39;s internal time value datatype.
Definition: timevalue.hpp:308
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:77
Offset measures a distance in time.
Definition: timevalue.hpp:367
Convenience frontend to access the current raw system time.
Definition: real-clock.hpp:54
a family of time value like entities and their relationships.
basic constant internal time value.
Definition: timevalue.hpp:142
Vault-Layer implementation namespace root.