Zth (libzth)
Loading...
Searching...
No Matches
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
 
 TimeInterval (std::chrono::nanoseconds ns)
 
 operator std::chrono::nanoseconds () const
 
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

static constexpr TimeInterval infinity () noexcept
 
static constexpr 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 55 of file time.h.

Constructor & Destructor Documentation

◆ TimeInterval() [1/9]

constexpr zth::TimeInterval::TimeInterval ( )
inlineconstexprnoexcept

Definition at line 74 of file time.h.

◆ TimeInterval() [2/9]

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

Definition at line 81 of file time.h.

◆ TimeInterval() [3/9]

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

Definition at line 98 of file time.h.

◆ TimeInterval() [4/9]

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

Definition at line 110 of file time.h.

◆ TimeInterval() [5/9]

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

Definition at line 116 of file time.h.

◆ TimeInterval() [6/9]

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

Definition at line 124 of file time.h.

◆ TimeInterval() [7/9]

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

Definition at line 132 of file time.h.

◆ TimeInterval() [8/9]

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

Definition at line 141 of file time.h.

◆ TimeInterval() [9/9]

zth::TimeInterval::TimeInterval ( std::chrono::nanoseconds  ns)
inline

Definition at line 189 of file time.h.

Member Function Documentation

◆ add()

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

Definition at line 324 of file time.h.

◆ from_ms()

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

Definition at line 158 of file time.h.

◆ from_ns()

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

Definition at line 178 of file time.h.

◆ from_s()

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

Definition at line 149 of file time.h.

◆ from_us()

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

Definition at line 168 of file time.h.

◆ hasPassed()

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

Definition at line 261 of file time.h.

◆ infinity()

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

Definition at line 64 of file time.h.

◆ isAbsBiggerThan()

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

Definition at line 285 of file time.h.

◆ isBiggerThan()

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

Definition at line 291 of file time.h.

◆ isInfinite()

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

Definition at line 256 of file time.h.

◆ isNegative()

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

Definition at line 241 of file time.h.

◆ isNormal()

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

Definition at line 236 of file time.h.

◆ isNull()

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

Definition at line 251 of file time.h.

◆ isPositive()

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

Definition at line 246 of file time.h.

◆ mul()

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

Definition at line 364 of file time.h.

◆ null()

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

Definition at line 69 of file time.h.

◆ operator std::chrono::nanoseconds()

zth::TimeInterval::operator std::chrono::nanoseconds ( ) const
inline

Definition at line 194 of file time.h.

◆ operator*()

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

Definition at line 408 of file time.h.

◆ operator*=()

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

Definition at line 401 of file time.h.

◆ operator+()

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

Definition at line 375 of file time.h.

◆ operator+=()

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

Definition at line 369 of file time.h.

◆ operator-() [1/2]

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

Definition at line 395 of file time.h.

◆ operator-() [2/2]

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

Definition at line 388 of file time.h.

◆ operator-=()

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

Definition at line 382 of file time.h.

◆ operator/()

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

Definition at line 421 of file time.h.

◆ operator/=()

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

Definition at line 414 of file time.h.

◆ operator<()

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

Definition at line 314 of file time.h.

◆ operator<=()

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

Definition at line 319 of file time.h.

◆ operator=()

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

Definition at line 103 of file time.h.

◆ operator==()

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

Definition at line 298 of file time.h.

◆ operator>()

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

Definition at line 304 of file time.h.

◆ operator>=()

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

Definition at line 309 of file time.h.

◆ s() [1/2]

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

Definition at line 271 of file time.h.

◆ s() [2/2]

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

Definition at line 277 of file time.h.

◆ str()

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

Definition at line 426 of file time.h.

◆ sub()

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

Definition at line 358 of file time.h.

◆ ts()

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

Definition at line 266 of file time.h.

Member Data Documentation

◆ BILLION

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

Definition at line 62 of file time.h.


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