wfmath  1.0.3
A math library for the Worldforge system.
WFMath::TimeDiff Class Reference

The difference between two timestamps. More...

#include <timestamp.h>

Public Member Functions

 TimeDiff ()
 construct an uninitialized TimeDiff More...
 
 TimeDiff (long msec)
 construct a TimeDiff of a given number of milliseconds More...
 
long milliseconds () const
 Get the value of a TimeDiff in milliseconds. More...
 
std::pair< long, long > full_time () const
 Get the value of a TimeDiff in (seconds, microseconds) More...
 
bool isValid () const
 
TimeDiff operator- () const
 negate a TimeDiff More...
 

Friends

TimeDiffoperator+= (TimeDiff &, const TimeDiff &)
 increment a TimeDiff More...
 
TimeDiffoperator-= (TimeDiff &, const TimeDiff &)
 decrement a TimeDiff More...
 
TimeDiff operator+ (const TimeDiff &a, const TimeDiff &b)
 add two TimeDiff instances More...
 
TimeDiff operator- (const TimeDiff &a, const TimeDiff &b)
 subtract two TimeDiff instances More...
 
TimeStampoperator+= (TimeStamp &, const TimeDiff &)
 advance a TimeStamp by a TimeDiff More...
 
TimeStampoperator-= (TimeStamp &, const TimeDiff &)
 regress a TimeStamp by a TimeDiff More...
 
TimeStamp operator+ (const TimeStamp &a, const TimeDiff &msec)
 find the result of advancing a TimeStamp More...
 
TimeStamp operator- (const TimeStamp &a, const TimeDiff &msec)
 find the result of regressing a TimeStamp More...
 
TimeDiff operator- (const TimeStamp &a, const TimeStamp &b)
 find the time difference between two time stamps More...
 
bool operator< (const TimeDiff &, const TimeDiff &)
 
bool operator== (const TimeDiff &, const TimeDiff &)
 

Detailed Description

The difference between two timestamps.

This class implements the 'generic' subset of the interface in the fake class Shape, with the exception of the stream operators. It also has the full set of comparison * operators (<, <=, >, >=, ==, !=).

Definition at line 52 of file timestamp.h.

Constructor & Destructor Documentation

◆ TimeDiff() [1/2]

WFMath::TimeDiff::TimeDiff ( )
inline

construct an uninitialized TimeDiff

Definition at line 57 of file timestamp.h.

Referenced by operator-().

◆ TimeDiff() [2/2]

WFMath::TimeDiff::TimeDiff ( long  msec)

construct a TimeDiff of a given number of milliseconds

Definition at line 69 of file timestamp.cpp.

Member Function Documentation

◆ full_time()

std::pair<long,long> WFMath::TimeDiff::full_time ( ) const
inline

Get the value of a TimeDiff in (seconds, microseconds)

Definition at line 69 of file timestamp.h.

◆ milliseconds()

long WFMath::TimeDiff::milliseconds ( ) const

Get the value of a TimeDiff in milliseconds.

WARNING! This function does not check for overflow, if the number of milliseconds is large

Definition at line 81 of file timestamp.cpp.

◆ operator-()

TimeDiff WFMath::TimeDiff::operator- ( ) const
inline

negate a TimeDiff

Definition at line 78 of file timestamp.h.

References TimeDiff().

Friends And Related Function Documentation

◆ operator+ [1/2]

TimeDiff operator+ ( const TimeDiff a,
const TimeDiff b 
)
friend

add two TimeDiff instances

Definition at line 110 of file timestamp.cpp.

◆ operator+ [2/2]

TimeStamp operator+ ( const TimeStamp a,
const TimeDiff msec 
)
friend

find the result of advancing a TimeStamp

Definition at line 212 of file timestamp.cpp.

◆ operator+= [1/2]

TimeDiff& operator+= ( TimeDiff val,
const TimeDiff d 
)
friend

increment a TimeDiff

Definition at line 86 of file timestamp.cpp.

◆ operator+= [2/2]

TimeStamp& operator+= ( TimeStamp a,
const TimeDiff d 
)
friend

advance a TimeStamp by a TimeDiff

Definition at line 190 of file timestamp.cpp.

◆ operator- [1/3]

TimeDiff operator- ( const TimeDiff a,
const TimeDiff b 
)
friend

subtract two TimeDiff instances

Definition at line 115 of file timestamp.cpp.

◆ operator- [2/3]

TimeStamp operator- ( const TimeStamp a,
const TimeDiff msec 
)
friend

find the result of regressing a TimeStamp

Definition at line 218 of file timestamp.cpp.

◆ operator- [3/3]

TimeDiff operator- ( const TimeStamp a,
const TimeStamp b 
)
friend

find the time difference between two time stamps

Definition at line 224 of file timestamp.cpp.

◆ operator-= [1/2]

TimeDiff& operator-= ( TimeDiff val,
const TimeDiff d 
)
friend

decrement a TimeDiff

Definition at line 98 of file timestamp.cpp.

◆ operator-= [2/2]

TimeStamp& operator-= ( TimeStamp a,
const TimeDiff d 
)
friend

regress a TimeStamp by a TimeDiff

Definition at line 201 of file timestamp.cpp.


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