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