Zth (libzth)
zth::TimeInterval Class Reference

Convenient wrapper around struct timespec that contains a time interval. More...

#include <time.h>

Inheritance diagram for zth::TimeInterval:
zth::fsm::GuardPollInterval

Public Member Functions

constexpr TimeInterval () noexcept
 
constexpr TimeInterval (time_t s, long ns=0, bool negative=false) noexcept
 
constexpr TimeInterval (struct timespec const &ts) noexcept
 
TimeIntervaloperator= (TimeInterval const &t) noexcept
 
constexpr TimeInterval (TimeInterval const &t) noexcept
 
 TimeInterval (float dt)
 
 TimeInterval (double dt)
 
 TimeInterval (long double dt)
 
template<typename T >
constexpr TimeInterval (T dt) noexcept
 
constexpr bool isNormal () const noexcept
 
constexpr bool isNegative () const noexcept
 
constexpr bool isPositive () const noexcept
 
constexpr bool isNull () const noexcept
 
constexpr bool isInfinite () const noexcept
 
constexpr bool hasPassed () const noexcept
 
constexpr struct timespec const & ts () const noexcept
 
constexpr double s () const noexcept
 
template<typename T >
constexpr T s () const noexcept
 
constexpr bool isAbsBiggerThan (TimeInterval const &t) const noexcept
 
constexpr bool isBiggerThan (TimeInterval const &t) const noexcept
 
constexpr bool operator== (TimeInterval const &rhs) const noexcept
 
constexpr bool operator> (TimeInterval const &rhs) const noexcept
 
constexpr bool operator>= (TimeInterval const &rhs) const noexcept
 
constexpr bool operator< (TimeInterval const &rhs) const noexcept
 
constexpr bool operator<= (TimeInterval const &rhs) const noexcept
 
constexpr void add (TimeInterval const &t) noexcept
 
constexpr void sub (TimeInterval const &t) noexcept
 
template<typename T >
constexpr void mul (T x) noexcept
 
constexpr TimeIntervaloperator+= (TimeInterval const &rhs) noexcept
 
constexpr TimeInterval operator+ (TimeInterval const &rhs) const noexcept
 
constexpr TimeIntervaloperator-= (TimeInterval const &rhs) noexcept
 
constexpr TimeInterval operator- (TimeInterval const &rhs) const noexcept
 
constexpr TimeInterval operator- () const noexcept
 
template<typename T >
constexpr TimeIntervaloperator*= (T x) noexcept
 
template<typename T >
constexpr TimeInterval operator* (T x) const noexcept
 
template<typename T >
constexpr TimeIntervaloperator/= (T x) noexcept
 
template<typename T >
constexpr TimeInterval operator/ (T x) const noexcept
 
string str () const
 

Static Public Member Functions

constexpr static TimeInterval infinity () noexcept
 
constexpr static TimeInterval null () noexcept
 
template<typename T >
static constexpr TimeInterval from_s (T s)
 
template<typename T >
static constexpr TimeInterval from_ms (T ms)
 
template<typename T >
static constexpr TimeInterval from_us (T us)
 
template<typename T >
static constexpr TimeInterval from_ns (T ns)
 

Static Public Attributes

static long const BILLION = 1000000000L
 

Detailed Description

Convenient wrapper around struct timespec that contains a time interval.

Examples
5_perf.cpp, daemon_pattern.cpp, and measure.cpp.

Definition at line 52 of file time.h.

Constructor & Destructor Documentation

◆ TimeInterval() [1/8]

constexpr zth::TimeInterval::TimeInterval ( )
inlineconstexprnoexcept

Definition at line 71 of file time.h.

◆ TimeInterval() [2/8]

constexpr zth::TimeInterval::TimeInterval ( time_t  s,
long  ns = 0,
bool  negative = false 
)
inlineconstexprnoexcept

Definition at line 78 of file time.h.

◆ TimeInterval() [3/8]

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

Definition at line 95 of file time.h.

◆ TimeInterval() [4/8]

constexpr zth::TimeInterval::TimeInterval ( TimeInterval const &  t)
inlineconstexprnoexcept

Definition at line 107 of file time.h.

◆ TimeInterval() [5/8]

zth::TimeInterval::TimeInterval ( float  dt)
inline

Definition at line 113 of file time.h.

◆ TimeInterval() [6/8]

zth::TimeInterval::TimeInterval ( double  dt)
inline

Definition at line 121 of file time.h.

◆ TimeInterval() [7/8]

zth::TimeInterval::TimeInterval ( long double  dt)
inline

Definition at line 129 of file time.h.

◆ TimeInterval() [8/8]

template<typename T >
constexpr zth::TimeInterval::TimeInterval ( dt)
inlineconstexprnoexcept

Definition at line 138 of file time.h.

Member Function Documentation

◆ add()

constexpr void zth::TimeInterval::add ( TimeInterval const &  t)
inlineconstexprnoexcept

Definition at line 302 of file time.h.

◆ from_ms()

template<typename T >
static constexpr TimeInterval zth::TimeInterval::from_ms ( ms)
inlinestaticconstexpr

Definition at line 155 of file time.h.

◆ from_ns()

template<typename T >
static constexpr TimeInterval zth::TimeInterval::from_ns ( ns)
inlinestaticconstexpr

Definition at line 175 of file time.h.

◆ from_s()

template<typename T >
static constexpr TimeInterval zth::TimeInterval::from_s ( s)
inlinestaticconstexpr

Definition at line 146 of file time.h.

◆ from_us()

template<typename T >
static constexpr TimeInterval zth::TimeInterval::from_us ( us)
inlinestaticconstexpr

Definition at line 165 of file time.h.

◆ hasPassed()

constexpr bool zth::TimeInterval::hasPassed ( ) const
inlineconstexprnoexcept

Definition at line 239 of file time.h.

◆ infinity()

constexpr static TimeInterval zth::TimeInterval::infinity ( )
inlinestaticconstexprnoexcept

Definition at line 61 of file time.h.

◆ isAbsBiggerThan()

constexpr bool zth::TimeInterval::isAbsBiggerThan ( TimeInterval const &  t) const
inlineconstexprnoexcept

Definition at line 263 of file time.h.

◆ isBiggerThan()

constexpr bool zth::TimeInterval::isBiggerThan ( TimeInterval const &  t) const
inlineconstexprnoexcept

Definition at line 269 of file time.h.

◆ isInfinite()

constexpr bool zth::TimeInterval::isInfinite ( ) const
inlineconstexprnoexcept

Definition at line 234 of file time.h.

◆ isNegative()

constexpr bool zth::TimeInterval::isNegative ( ) const
inlineconstexprnoexcept
Examples
daemon_pattern.cpp.

Definition at line 219 of file time.h.

◆ isNormal()

constexpr bool zth::TimeInterval::isNormal ( ) const
inlineconstexprnoexcept

Definition at line 214 of file time.h.

◆ isNull()

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

Definition at line 229 of file time.h.

◆ isPositive()

constexpr bool zth::TimeInterval::isPositive ( ) const
inlineconstexprnoexcept

Definition at line 224 of file time.h.

◆ mul()

template<typename T >
constexpr void zth::TimeInterval::mul ( x)
inlineconstexprnoexcept

Definition at line 342 of file time.h.

◆ null()

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

Definition at line 66 of file time.h.

◆ operator*()

template<typename T >
constexpr TimeInterval zth::TimeInterval::operator* ( x) const
inlineconstexprnoexcept

Definition at line 386 of file time.h.

◆ operator*=()

template<typename T >
constexpr TimeInterval& zth::TimeInterval::operator*= ( x)
inlineconstexprnoexcept

Definition at line 379 of file time.h.

◆ operator+()

constexpr TimeInterval zth::TimeInterval::operator+ ( TimeInterval const &  rhs) const
inlineconstexprnoexcept

Definition at line 353 of file time.h.

◆ operator+=()

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

Definition at line 347 of file time.h.

◆ operator-() [1/2]

constexpr TimeInterval zth::TimeInterval::operator- ( ) const
inlineconstexprnoexcept

Definition at line 373 of file time.h.

◆ operator-() [2/2]

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

Definition at line 366 of file time.h.

◆ operator-=()

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

Definition at line 360 of file time.h.

◆ operator/()

template<typename T >
constexpr TimeInterval zth::TimeInterval::operator/ ( x) const
inlineconstexprnoexcept

Definition at line 399 of file time.h.

◆ operator/=()

template<typename T >
constexpr TimeInterval& zth::TimeInterval::operator/= ( x)
inlineconstexprnoexcept

Definition at line 392 of file time.h.

◆ operator<()

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

Definition at line 292 of file time.h.

◆ operator<=()

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

Definition at line 297 of file time.h.

◆ operator=()

TimeInterval& zth::TimeInterval::operator= ( TimeInterval const &  t)
inlinenoexcept

Definition at line 100 of file time.h.

◆ operator==()

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

Definition at line 276 of file time.h.

◆ operator>()

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

Definition at line 282 of file time.h.

◆ operator>=()

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

Definition at line 287 of file time.h.

◆ s() [1/2]

constexpr double zth::TimeInterval::s ( ) const
inlineconstexprnoexcept

Definition at line 249 of file time.h.

◆ s() [2/2]

template<typename T >
constexpr T zth::TimeInterval::s ( ) const
inlineconstexprnoexcept

Definition at line 255 of file time.h.

◆ str()

string zth::TimeInterval::str ( ) const
inline
Examples
5_perf.cpp.

Definition at line 404 of file time.h.

◆ sub()

constexpr void zth::TimeInterval::sub ( TimeInterval const &  t)
inlineconstexprnoexcept

Definition at line 336 of file time.h.

◆ ts()

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

Definition at line 244 of file time.h.

Member Data Documentation

◆ BILLION

long const zth::TimeInterval::BILLION = 1000000000L
static

Definition at line 59 of file time.h.


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