CppTest  Version 2.0.0
Public Member Functions | Static Public Member Functions | Friends | Related Functions | List of all members
Test::Time Class Reference

#include <cpptest-time.h>

Public Member Functions

 Time ()
 
 Time (unsigned int sec, unsigned int usec)
 
unsigned int seconds () const
 
unsigned int microseconds () const
 

Static Public Member Functions

static Time current ()
 

Friends

Time operator+ (const Time &t1, const Time &t2)
 
Time operator- (const Time &t1, const Time &t2)
 
std::ostream & operator<< (std::ostream &os, const Time &t)
 

Related Functions

(Note that these are not member functions.)

Time operator- (const Time &t1, const Time &t2)
 
Time operator+ (const Time &t1, const Time &t2)
 
ostream & operator<< (ostream &os, const Time &t)
 

Detailed Description

Time representation.

Encapsulates a time value with microsecond resolution. It is possible to retrieve the current time, add and subtract time values, and output the time to an output stream.

Constructor & Destructor Documentation

◆ Time() [1/2]

Test::Time::Time ( )

Constructs a time object with zeroed time.

Referenced by current().

◆ Time() [2/2]

Test::Time::Time ( unsigned int  sec,
unsigned int  usec 
)

Constructs a time object.

Parameters
secSeconds.
usecMicro-seconds.

Member Function Documentation

◆ seconds()

unsigned int Test::Time::seconds ( ) const
Returns
Seconds.

Referenced by operator<<().

◆ microseconds()

unsigned int Test::Time::microseconds ( ) const
Returns
Micro-seconds.

Referenced by operator<<().

◆ current()

Time Test::Time::current ( )
static
Returns
The current time.

References Time().

Friends And Related Function Documentation

◆ operator-()

Time operator- ( const Time t1,
const Time t2 
)
related

Computes the time elapsed between two time values.

Parameters
t1Left-hand time, should be greater than t2.
t2Right-hand time, should be less than t1.
Returns
Computed time value.

◆ operator+()

Time operator+ ( const Time t1,
const Time t2 
)
related

Adds two time values.

Parameters
t1Left-hand time.
t2Right-hand time.
Returns
Computed time value.

◆ operator<<()

ostream & operator<< ( ostream &  os,
const Time t 
)
related

Outputs a time to an output stream.

Parameters
osOutput stream to write to.
tTime to output.
Returns
A reference to the given output stream.

References microseconds(), and seconds().


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