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