ALib C++ Framework
by
Library Version: 2605 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 the \aliblong. It does not belong to an \alibmod and is
4/// included in any \alibbuild.
5///
6/// Copyright 2013-2026 A-Worx GmbH, Germany.
7/// Published under #"mainpage_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/// #"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 #"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 #"TickConverter" allows converting objects of this type to
25/// objects of sibling type #"%time::DateTime", which then can be further converted to
26/// system-dependent calendar dates and clock times.
27///
28/// The class has no specific interface, but the methods and operators are inherited from base
29/// #"TimePointBase".
30/// @see
31/// For this class, a #"alibtools_debug_helpers_gdb;pretty printer" for the
32/// GNU debugger is provided.
33//==================================================================================================
34class Ticks : public TimePointBase<std::chrono::steady_clock, Ticks> {
35 public:
36//! @cond NO_DOX
37// doxygen bug: generates "return type not documented"
38 /// Use constructors of parent class.
40//! @endcond
41
42
43 /// Equal to operator.
44 /// @param other The time stamp to compare.
45 /// @return The result of the comparison.
46 bool operator==( const Ticks& other ) const { return stamp == other.stamp; }
47
48
49 /// Not equal to operator.
50 /// @param other The time stamp to compare.
51 /// @return The result of the comparison.
52 bool operator!=( const Ticks& other ) const { return stamp != other.stamp; }
53
54 /// Less than operator.
55 /// @param other The time stamp to compare.
56 /// @return A reference to this object.
57 bool operator<( const Ticks& other ) const { return stamp < other.stamp; }
58
59 /// Less than or equal to operator.
60 /// @param other The time stamp to compare.
61 /// @return The result of the comparison.
62 bool operator<=( const Ticks& other ) const { return stamp <= other.stamp; }
63
64 /// Greater than operator.
65 /// @param other The time stamp to compare.
66 /// @return The result of the comparison.
67 bool operator>( const Ticks& other ) const { return stamp > other.stamp; }
68
69 /// Greater than or equal to operator.
70 /// @param other The time stamp to compare.
71 /// @return The result of the comparison.
72 bool operator>=( const Ticks& other ) const { return stamp >= other.stamp; }
73};
74
75//==================================================================================================
76/// The time when \alib was initialized.
77/// This might be useful to measure the time since the process was started.
78/// @return Initialization time of \alib.
79//==================================================================================================
82
83} // namespace alib[::time]
84
85/// Type alias in namespace #"%alib".
87
88} // namespace [alib]
#define ALIB_DLL
#define ALIB_EXPORT
bool operator>=(const Ticks &other) const
Definition ticks.hpp:72
bool operator<=(const Ticks &other) const
Definition ticks.hpp:62
bool operator==(const Ticks &other) const
Definition ticks.hpp:46
bool operator<(const Ticks &other) const
Definition ticks.hpp:57
bool operator!=(const Ticks &other) const
Definition ticks.hpp:52
bool operator>(const Ticks &other) const
Definition ticks.hpp:67
constexpr TimePointBase(const lang::Initialization init=lang::Initialization::Default)
Ticks CreationTime()
Definition time.cpp:23
Definition alox.cpp:14
time::Ticks Ticks
Type alias in namespace #"%alib".
Definition ticks.hpp:86