Zth (libzth)
Loading...
Searching...
No Matches
zth::Timestamp Class Reference

Convenient wrapper around struct timespec that contains an absolute timestamp. More...

#include <time.h>

Public Member Functions

constexpr Timestamp () noexcept
 
constexpr Timestamp (struct timespec const &ts) noexcept
 
constexpr Timestamp (time_t sec, long nsec=0) noexcept
 
 Timestamp (TimeInterval const &ti)
 
constexpr struct timespec const & ts () const noexcept
 
constexpr operator struct timespec const & () const noexcept
 
constexpr bool isBefore (Timestamp const &t) const noexcept
 
constexpr bool isAfter (Timestamp const &t) const noexcept
 
bool hasPassed () const noexcept
 
constexpr bool operator== (Timestamp const &rhs) const noexcept
 
constexpr bool operator!= (Timestamp const &rhs) const noexcept
 
constexpr bool operator< (Timestamp const &rhs) const noexcept
 
constexpr bool operator<= (Timestamp const &rhs) const noexcept
 
constexpr bool operator> (Timestamp const &rhs) const noexcept
 
constexpr bool operator>= (Timestamp const &rhs) const noexcept
 
constexpr TimeInterval timeTo (Timestamp const &t) const
 
TimeInterval passed () const
 
constexpr void add (TimeInterval const &dt) noexcept
 
constexpr Timestampoperator+= (TimeInterval const &dt) noexcept
 
constexpr Timestamp operator+ (TimeInterval const &dt) const noexcept
 
constexpr Timestampoperator-= (TimeInterval const &dt) noexcept
 
constexpr Timestamp operator- (TimeInterval const &dt) const noexcept
 
constexpr TimeInterval operator- (Timestamp const &rhs) const noexcept
 
constexpr bool isNull () const noexcept
 
template<typename Duration >
 Timestamp (std::chrono::time_point< monotonic_clock, Duration > tp)
 
 operator std::chrono::time_point< monotonic_clock > () const
 

Static Public Member Functions

static Timestamp now ()
 
static constexpr Timestamp null () noexcept
 

Detailed Description

Convenient wrapper around struct timespec that contains an absolute timestamp.

Examples
3_coop.cpp, 5_perf.cpp, daemon_pattern.cpp, fsm14.cpp, and measure.cpp.

Definition at line 568 of file time.h.

Constructor & Destructor Documentation

◆ Timestamp() [1/5]

constexpr zth::Timestamp::Timestamp ( )
inlineconstexprnoexcept

Definition at line 572 of file time.h.

◆ Timestamp() [2/5]

constexpr zth::Timestamp::Timestamp ( struct timespec const &  ts)
inlineconstexprnoexcept

Definition at line 577 of file time.h.

◆ Timestamp() [3/5]

constexpr zth::Timestamp::Timestamp ( time_t  sec,
long  nsec = 0 
)
inlineexplicitconstexprnoexcept

Definition at line 581 of file time.h.

◆ Timestamp() [4/5]

zth::Timestamp::Timestamp ( TimeInterval const &  ti)
inline

Definition at line 589 of file time.h.

◆ Timestamp() [5/5]

template<typename Duration >
zth::Timestamp::Timestamp ( std::chrono::time_point< monotonic_clock, Duration >  tp)
inline

Definition at line 728 of file time.h.

Member Function Documentation

◆ add()

constexpr void zth::Timestamp::add ( TimeInterval const &  dt)
inlineconstexprnoexcept

Definition at line 678 of file time.h.

◆ hasPassed()

bool zth::Timestamp::hasPassed ( ) const
inlinenoexcept

Definition at line 624 of file time.h.

◆ isAfter()

constexpr bool zth::Timestamp::isAfter ( Timestamp const &  t) const
inlineconstexprnoexcept

Definition at line 619 of file time.h.

◆ isBefore()

constexpr bool zth::Timestamp::isBefore ( Timestamp const &  t) const
inlineconstexprnoexcept

Definition at line 613 of file time.h.

◆ isNull()

constexpr bool zth::Timestamp::isNull ( ) const
inlineconstexprnoexcept

Definition at line 720 of file time.h.

◆ now()

static Timestamp zth::Timestamp::now ( )
inlinestatic
Examples
3_coop.cpp, 5_perf.cpp, daemon_pattern.cpp, fsm14.cpp, and measure.cpp.

Definition at line 595 of file time.h.

◆ null()

static constexpr Timestamp zth::Timestamp::null ( )
inlinestaticconstexprnoexcept

Definition at line 715 of file time.h.

◆ operator std::chrono::time_point< monotonic_clock >()

zth::Timestamp::operator std::chrono::time_point< monotonic_clock > ( ) const
inline

Definition at line 736 of file time.h.

◆ operator struct timespec const &()

constexpr zth::Timestamp::operator struct timespec const & ( ) const
inlineconstexprnoexcept

Definition at line 608 of file time.h.

◆ operator!=()

constexpr bool zth::Timestamp::operator!= ( Timestamp const &  rhs) const
inlineconstexprnoexcept

Definition at line 634 of file time.h.

◆ operator+()

constexpr Timestamp zth::Timestamp::operator+ ( TimeInterval const &  dt) const
inlineconstexprnoexcept

Definition at line 692 of file time.h.

◆ operator+=()

constexpr Timestamp & zth::Timestamp::operator+= ( TimeInterval const &  dt)
inlineconstexprnoexcept

Definition at line 686 of file time.h.

◆ operator-() [1/2]

constexpr Timestamp zth::Timestamp::operator- ( TimeInterval const &  dt) const
inlineconstexprnoexcept

Definition at line 704 of file time.h.

◆ operator-() [2/2]

constexpr TimeInterval zth::Timestamp::operator- ( Timestamp const &  rhs) const
inlineconstexprnoexcept

Definition at line 710 of file time.h.

◆ operator-=()

constexpr Timestamp & zth::Timestamp::operator-= ( TimeInterval const &  dt)
inlineconstexprnoexcept

Definition at line 698 of file time.h.

◆ operator<()

constexpr bool zth::Timestamp::operator< ( Timestamp const &  rhs) const
inlineconstexprnoexcept

Definition at line 638 of file time.h.

◆ operator<=()

constexpr bool zth::Timestamp::operator<= ( Timestamp const &  rhs) const
inlineconstexprnoexcept

Definition at line 642 of file time.h.

◆ operator==()

constexpr bool zth::Timestamp::operator== ( Timestamp const &  rhs) const
inlineconstexprnoexcept

Definition at line 629 of file time.h.

◆ operator>()

constexpr bool zth::Timestamp::operator> ( Timestamp const &  rhs) const
inlineconstexprnoexcept

Definition at line 646 of file time.h.

◆ operator>=()

constexpr bool zth::Timestamp::operator>= ( Timestamp const &  rhs) const
inlineconstexprnoexcept

Definition at line 650 of file time.h.

◆ passed()

TimeInterval zth::Timestamp::passed ( ) const
inline

Definition at line 661 of file time.h.

◆ timeTo()

constexpr TimeInterval zth::Timestamp::timeTo ( Timestamp const &  t) const
inlineconstexpr

Definition at line 655 of file time.h.

◆ ts()

constexpr struct timespec const & zth::Timestamp::ts ( ) const
inlinenoexcept

Definition at line 604 of file time.h.


The documentation for this class was generated from the following file: