Panda3D
trueClock.I
Go to the documentation of this file.
1 /**
2  * PANDA 3D SOFTWARE
3  * Copyright (c) Carnegie Mellon University. All rights reserved.
4  *
5  * All use of this software is subject to the terms of the revised BSD
6  * license. You should have received a copy of this license along
7  * with this source code in a file named "LICENSE."
8  *
9  * @file trueClock.I
10  * @author drose
11  * @date 2000-07-04
12  */
13 
14 #if defined(WIN32_VC) || defined(WIN64_VC)
15 
16 /**
17  *
18  */
19 INLINE double TrueClock::
20 get_short_time() {
21  bool is_paranoid_clock = get_paranoid_clock();
22 
23  if (is_paranoid_clock) {
24  _lock.lock();
25  }
26 
27  double time = get_short_raw_time();
28 
29  if (is_paranoid_clock) {
30  // Check for rollforwards, rollbacks, and compensate for Speed Gear type
31  // programs by verifying against the time of day clock.
32  time = correct_time(time);
33  _lock.unlock();
34  }
35 
36  return time;
37 }
38 
39 #else // WIN32_VC
40 
41 /**
42  *
43  */
44 INLINE double TrueClock::
45 get_short_time() {
46  return get_short_raw_time();
47 }
48 
49 #endif // WIN32_VC
50 
51 
52 /**
53  * Returns the number of clock errors that have been detected. Each time a
54  * clock error is detected, in which the value returned by either of the above
55  * methods is suspect, the value returned by this method will be incremented.
56  * Applications can monitor this value and react, for instance, by
57  * resynchronizing their clocks each time this value changes.
58  */
59 INLINE int TrueClock::
60 get_error_count() const {
61  return _error_count;
62 }
63 
64 /**
65  * Returns a pointer to the one TrueClock object in the world.
66  */
67 INLINE TrueClock *TrueClock::
69  if (_global_ptr == nullptr) {
70  _global_ptr = new TrueClock;
71  }
72  return _global_ptr;
73 }
74 
75 /**
76  * A protected destructor because no one should try to delete the global
77  * TrueClock.
78  */
79 INLINE TrueClock::
80 ~TrueClock() {
81 }
static TrueClock * get_global_ptr()
Returns a pointer to the one TrueClock object in the world.
Definition: trueClock.I:68
An interface to whatever real-time clock we might have available in the current environment.
Definition: trueClock.h:33