Timeval Class Reference

Timeval extends the struct timeval and adds useful methods. More...

#include <timeval_decls.h>

List of all members.

Public Member Functions

 Timeval ()
 Construct an uninitialized(!) Timeval.
 Timeval (const timeval &o)
 Construct a Timeval by copying a timeval instance.
 Timeval (void *)
 This constructor uses an ignored dummy parameter to initialize with gettimeofday().
 Timeval (time_t sec)
 Construct a Timeval by setting it to sec seconds.
 Timeval (time_t sec, suseconds_t usec)
 Construct a Timeval by setting it to sec + 0.000001 * usec.
 Timeval (float sec)
 Construct a Timeval by setting it to sec.
 Timeval (double sec)
 Construct a Timeval by setting it to sec.
Timevaloperator= (const timeval &o)
 Assigns o to this Timeval.
Timevaloperator= (time_t sec)
 Assigns sec to this Timeval.
Timevaloperator= (float sec)
 Assigns sec to this Timeval.
Timevaloperator= (double sec)
 Assigns sec to this Timeval.
Timevalgettimeofday ()
 Sets this to the current time by invoking gettimeofday.
 operator time_t () const
 Converts Timeval to time_t by rounding down to seconds.
 operator float () const
 Converts Timeval to float.
 operator double () const
 Converts Timeval to double.
unsigned int milliseconds () const
 Converts Timeval to an unsigned int of milliseconds.
bool operator> (const timeval &o) const
 Checks whether this is larger than o.
bool operator>= (const timeval &o) const
 Checks whether this is larger than or equal to o.
bool operator== (const timeval &o) const
 Checks whether this is equal to o.
bool operator<= (const timeval &o) const
 Checks whether this is smaller than or equal to o.
bool operator< (const timeval &o) const
 Checks whether this is smaller than o.
bool operator!= (const timeval &o) const
 Checks whether this is not equal to o.
Timeval operator+ (const timeval &o) const
 Returns the sum of this and o.
Timeval operator+ (time_t sec) const
 Returns the sum of this and sec.
Timeval operator+ (float sec) const
 Returns the sum of this and sec.
Timeval operator+ (double sec) const
 Returns the sum of this and sec.
Timevaloperator+= (const timeval &o)
 Adds o to this Timeval.
Timevaloperator+= (time_t sec)
 Adds sec in seconds to this Timeval.
Timevaloperator+= (float sec)
 Adds sec in seconds to this Timeval.
Timevaloperator+= (double sec)
 Adds sec in seconds to this Timeval.
Timeval operator- (const timeval &o) const
 Returns the difference of this and o.
Timeval operator- (time_t sec) const
 Returns the difference of this and sec.
Timeval operator- (float sec) const
 Returns the difference of this and sec.
Timeval operator- (double sec) const
 Returns the difference of this and sec.
Timevaloperator-= (const timeval &o)
 Substracts o from this Timeval.
Timevaloperator-= (time_t sec)
 Substracts sec seconds from this Timeval.
Timevaloperator-= (float sec)
 Substracts sec seconds from this Timeval.
Timevaloperator-= (double sec)
 Substracts sec seconds from this Timeval.


Detailed Description

Timeval extends the struct timeval and adds useful methods.


Constructor & Destructor Documentation

Timeval::Timeval ( const timeval &  o  )  [inline]

Construct a Timeval by copying a timeval instance.

As Timeval is derived from timeval this also covers the copy constructor.

Parameters:
o is the timeval to copy.

Timeval::Timeval ( void *   )  [inline]

This constructor uses an ignored dummy parameter to initialize with gettimeofday().

The macro TimevalNow should be passed to use this constructor.

Timeval::Timeval ( time_t  sec  )  [inline]

Construct a Timeval by setting it to sec seconds.

Parameters:
sec time in seconds to initialize with

Timeval::Timeval ( time_t  sec,
suseconds_t  usec 
) [inline]

Construct a Timeval by setting it to sec + 0.000001 * usec.

Parameters:
sec time in seconds
usec time in microseconds

Timeval::Timeval ( float  sec  )  [inline]

Construct a Timeval by setting it to sec.

Parameters:
sec is a float in seconds

Timeval::Timeval ( double  sec  )  [inline]

Construct a Timeval by setting it to sec.

Parameters:
sec is a double in seconds


Member Function Documentation

Timeval & Timeval::operator= ( const timeval &  o  )  [inline]

Assigns o to this Timeval.

As Timeval is derived from timeval this also covers copying Timevals.

Parameters:
o is the timeval to copy
Returns:
*this

Timeval & Timeval::operator= ( time_t  sec  )  [inline]

Assigns sec to this Timeval.

Parameters:
sec is the time in seconds
Returns:
*this

Timeval & Timeval::operator= ( float  sec  )  [inline]

Assigns sec to this Timeval.

Parameters:
sec is the time in seconds
Returns:
*this

Timeval & Timeval::operator= ( double  sec  )  [inline]

Assigns sec to this Timeval.

Parameters:
sec is the time in seconds
Returns:
*this

Timeval & Timeval::gettimeofday (  )  [inline]

Sets this to the current time by invoking gettimeofday.

Returns:
*this

Timeval::operator time_t (  )  const [inline]

Converts Timeval to time_t by rounding down to seconds.

Returns:
rounded down seconds

Timeval::operator float (  )  const [inline]

Converts Timeval to float.

The result will be inexact.

Returns:
seconds of this Timeval as float

Timeval::operator double (  )  const [inline]

Converts Timeval to double.

The result will be inexact.

Returns:
seconds of this Timeval as double

unsigned int Timeval::milliseconds (  )  const [inline]

Converts Timeval to an unsigned int of milliseconds.

It does not check for overflows.

Returns:
the milliseconds of this Timeval as unsigned int

bool Timeval::operator> ( const timeval &  o  )  const [inline]

Checks whether this is larger than o.

Parameters:
o the timeval to compare with
Returns:
true if this > o

bool Timeval::operator>= ( const timeval &  o  )  const [inline]

Checks whether this is larger than or equal to o.

Parameters:
o the timeval to compare with
Returns:
true if this >= o

bool Timeval::operator== ( const timeval &  o  )  const [inline]

Checks whether this is equal to o.

This will as with floats almost always give false.

Parameters:
o the timeval to compare with
Returns:
true if this == o

bool Timeval::operator<= ( const timeval &  o  )  const [inline]

Checks whether this is smaller than or equal to o.

Parameters:
o the timeval to compare with
Returns:
true if this <= o

bool Timeval::operator< ( const timeval &  o  )  const [inline]

Checks whether this is smaller than o.

Parameters:
o the timeval to compare with
Returns:
true if this < o

bool Timeval::operator!= ( const timeval &  o  )  const [inline]

Checks whether this is not equal to o.

This will as with floats almost always give true.

Parameters:
o the timeval to compare with
Returns:
true if this != o

Timeval Timeval::operator+ ( const timeval &  o  )  const [inline]

Returns the sum of this and o.

Neither this nor o will be modified.

Parameters:
o is the timeval to be added
Returns:
a new Timeval that equals to this + o

Timeval Timeval::operator+ ( time_t  sec  )  const [inline]

Returns the sum of this and sec.

Neither this nor sec will be modified.

Parameters:
sec is the time in seconds to be added
Returns:
a new Timeval that equals to this + sec

Timeval Timeval::operator+ ( float  sec  )  const [inline]

Returns the sum of this and sec.

Neither this nor sec will be modified.

Parameters:
sec is the time in seconds to be added
Returns:
a new Timeval that equals to this + sec

Timeval Timeval::operator+ ( double  sec  )  const [inline]

Returns the sum of this and sec.

Neither this nor sec will be modified.

Parameters:
sec is the time in seconds to be added
Returns:
a Timeval that equals to this + sec

Timeval & Timeval::operator+= ( const timeval &  o  )  [inline]

Adds o to this Timeval.

This also works for Timeval as it is derived from timeval.

Parameters:
o is the timeval to be added
Returns:
this modified object

Timeval & Timeval::operator+= ( time_t  sec  )  [inline]

Adds sec in seconds to this Timeval.

Parameters:
sec is the time in seconds to add
Returns:
this modified object

Timeval & Timeval::operator+= ( float  sec  )  [inline]

Adds sec in seconds to this Timeval.

Parameters:
sec is the time in seconds to add
Returns:
this modified object

Timeval & Timeval::operator+= ( double  sec  )  [inline]

Adds sec in seconds to this Timeval.

Parameters:
sec is the time in seconds to add
Returns:
this modified object

Timeval Timeval::operator- ( const timeval &  o  )  const [inline]

Returns the difference of this and o.

The result is undefined if this < o. Neither this nor o will be modified.

Parameters:
o is the timeval to be substracted
Returns:
a Timeval that equals to this + o

Timeval Timeval::operator- ( time_t  sec  )  const [inline]

Returns the difference of this and sec.

The result is undefined if this < sec. Neither this nor sec will be modified.

Parameters:
sec is the time in seconds to be substracted
Returns:
a Timeval that equals to this + sec

Timeval Timeval::operator- ( float  sec  )  const [inline]

Returns the difference of this and sec.

The result is undefined if this < sec. Neither this nor sec will be modified.

Parameters:
sec is the time in seconds to be substracted
Returns:
a Timeval that equals to this + sec

Timeval Timeval::operator- ( double  sec  )  const [inline]

Returns the difference of this and sec.

The result is undefined if this < sec. Neither this nor sec will be modified.

Parameters:
sec is the time in seconds to be substracted
Returns:
a Timeval that equals to this + sec

Timeval & Timeval::operator-= ( const timeval &  o  )  [inline]

Substracts o from this Timeval.

This also works for Timeval as it is derived from timeval.

Parameters:
o is the timeval to be substracted
Returns:
this modified object

Timeval & Timeval::operator-= ( time_t  sec  )  [inline]

Substracts sec seconds from this Timeval.

Parameters:
sec is the time in seconds to be substracted
Returns:
this modified object

Timeval & Timeval::operator-= ( float  sec  )  [inline]

Substracts sec seconds from this Timeval.

Parameters:
sec is the time in seconds to be substracted
Returns:
this modified object

Timeval & Timeval::operator-= ( double  sec  )  [inline]

Substracts sec seconds from this Timeval.

Parameters:
sec is the time in seconds to be substracted
Returns:
this modified object


The documentation for this class was generated from the following files:
Generated on Sat Feb 7 01:26:51 2009 by  doxygen 1.5.1