ALib C++ Library
Library Version: 2412 R0
Documentation generated by doxygen
Loading...
Searching...
No Matches
ticks.hpp
Go to the documentation of this file.
1//==================================================================================================
2/// \file
3/// This header file is part of module \alib_time of the \aliblong.
4///
5/// \emoji :copyright: 2013-2024 A-Worx GmbH, Germany.
6/// Published under \ref mainpage_license "Boost Software License".
7//==================================================================================================
8#ifndef HPP_ALIB_TIME_TICKS
9#define HPP_ALIB_TIME_TICKS 1
10#pragma once
12
13namespace alib { namespace time {
14
15
16//==================================================================================================
17/// This class provides an interface into system dependent steady, monotonic timer values, which are
18/// independent of the system's clock settings, hence independent of changes of the clock
19/// by the user, by external clock synchronization using the internet, GPS, mobile network, etc.
20///
21/// Usually, this class is used to measure and store durations (e.g., with inherited method
22/// \alib{time::TimePointBase;Age}).
23/// As tick values are not just system dependent, but even usually change with a reboot of a system,
24/// they should not be stored and loaded in data files or otherwise shared between systems.
25///
26/// In contrast to sibling type \alib{time;DateTime}, this class is also missing conversion methods
27/// with types that represent "human" calendar dates and a clock times.
28/// However, in some situations it still may be needed to convert the points in time measured with
29/// this class to human-readable date and time representations.
30/// For this purpose, class \alib{time;TickConverter} allows converting objects of this type to
31/// objects of sibling type \b %DateTime, which then can be further converted to system-dependent
32/// calendar dates and clock times.
33///
34/// The class has no specific interface, but the methods and operators inherited from base
35/// \alib{time;TimePointBase}.
36/// @see
37/// For this class, a \ref alibtools_debug_helpers_gdb "pretty printer" for the
38/// GNU debugger is provided.
39//==================================================================================================
40class Ticks : public TimePointBase<std::chrono::steady_clock, Ticks>
41{
42 public:
43//! @cond NO_DOX
44// doxygen bug: generates "return type not documented"
45 /// Use constructors of parent class.
47//! @endcond
48
49
50 //==========================================================================================
51 /// Equal to operator.
52 /// @param other The time stamp to compare.
53 /// @return The result of the comparison.
54 //==========================================================================================
55 bool operator==( const Ticks& other ) const
56 {
57 return stamp == other.stamp;
58 }
59
60
61 //==========================================================================================
62 /// Not equal to operator.
63 /// @param other The time stamp to compare.
64 /// @return The result of the comparison.
65 //==========================================================================================
66 bool operator!=( const Ticks& other ) const
67 {
68 return stamp != other.stamp;
69 }
70
71 //==========================================================================================
72 /// Less than operator.
73 /// @param other The time stamp to compare.
74 /// @return A reference to this object.
75 //==========================================================================================
76 bool operator<( const Ticks& other ) const
77 {
78 return stamp < other.stamp;
79 }
80
81 //==========================================================================================
82 /// Less than or equal to operator.
83 /// @param other The time stamp to compare.
84 /// @return The result of the comparison.
85 //==========================================================================================
86 bool operator<=( const Ticks& other ) const
87 {
88 return stamp <= other.stamp;
89 }
90
91 //==========================================================================================
92 /// Greater than operator.
93 /// @param other The time stamp to compare.
94 /// @return The result of the comparison.
95 //==========================================================================================
96 bool operator>( const Ticks& other ) const
97 {
98 return stamp > other.stamp;
99 }
100
101 //==========================================================================================
102 /// Greater than or equal to operator.
103 /// @param other The time stamp to compare.
104 /// @return The result of the comparison.
105 //==========================================================================================
106 bool operator>=( const Ticks& other ) const
107 {
108 return stamp >= other.stamp;
109 }
110};
111
112} // namespace alib[::time]
113
114/// Type alias in namespace \b alib.
116
117} // namespace [alib]
118
119 #if ALIB_BOXING
120 # include "alib/boxing/boxing.hpp"
121 ALIB_BOXING_VTABLE_DECLARE( alib::Ticks , vt_time_ticks )
122 ALIB_BOXING_VTABLE_DECLARE( alib::Ticks::Duration , vt_time_ticks_duration )
123 #endif
124
125
126#endif // HPP_ALIB_TIME_TICKS
127
bool operator>=(const Ticks &other) const
Definition ticks.hpp:106
bool operator!=(const Ticks &other) const
Definition ticks.hpp:66
bool operator==(const Ticks &other) const
Definition ticks.hpp:55
bool operator<=(const Ticks &other) const
Definition ticks.hpp:86
bool operator<(const Ticks &other) const
Definition ticks.hpp:76
bool operator>(const Ticks &other) const
Definition ticks.hpp:96
constexpr TimePointBase(const lang::Initialization init=lang::Initialization::Default)
#define ALIB_BOXING_VTABLE_DECLARE(TMapped, Identifier)
Definition vtable.inl:460
Definition alib.cpp:69