plumbing::time_value Class Reference

#include <time_value.h>

Public Member Functions

 ~time_value ()
 time_value ()
 time_value (long seconds, long microseconds=0)
 time_value (int seconds)
 time_value (double seconds)
 time_value (const char *str)
 time_value (const time_value &)
time_valueoperator= (const time_value &rhs)
time_valueoperator= (double)
time_valueoperator= (long sec)
long get_seconds () const
 operator double () const
int get_time_of_day ()
std::string representation () const
time_valueoperator+= (const time_value &)
time_value operator+ (const time_value &) const
time_valueoperator-= (const time_value &)
time_value operator- (const time_value &) const
time_value operator- () const
time_valueoperator*= (double)
time_value operator* (double) const
time_valueoperator*= (long)
time_value operator* (long) const
bool operator== (const time_value &) const
bool operator!= (const time_value &) const
bool operator< (const time_value &) const
bool operator<= (const time_value &) const
bool operator> (const time_value &) const
bool operator>= (const time_value &) const

Static Public Member Functions

static time_value now ()

Private Member Functions

bool in_normal_form () const

Detailed Description

The time_value class is used to represent a time in seconds and microseconds.

Definition at line 30 of file time_value.h.


Constructor & Destructor Documentation

plumbing::time_value::~time_value (  )  [inline]

The destructor.

It isn't virtual. Thou shalt not derive from this class.

Definition at line 39 of file time_value.h.

plumbing::time_value::time_value (  )  [inline]

The default constructor.

The object will be initialized to exactly 0.0 seconds.

Definition at line 46 of file time_value.h.

plumbing::time_value::time_value ( long  seconds,
long  microseconds = 0 
)

The constructor.

Parameters:
seconds The time value in seconds
microseconds The time value in microseconds. If this isn't in normal form (0..999999) it will be normalized - which is why this method is not inline.
plumbing::time_value::time_value ( int  seconds  )  [inline]

The constructor.

Parameters:
seconds The time value in seconds

Definition at line 66 of file time_value.h.

plumbing::time_value::time_value ( double  seconds  ) 

The constructor.

Parameters:
seconds The value in seconds. It will be rounded to the closest microsecond.
plumbing::time_value::time_value ( const char *  str  ) 

The constructor.

Parameters:
str String to parse for time value. Will be set to zero on error.
plumbing::time_value::time_value ( const time_value  ) 

The copy constructor.


Member Function Documentation

long plumbing::time_value::get_seconds (  )  const [inline]

The get_seconds method is used to obtain the number of whole seconds in this time value.

Definition at line 125 of file time_value.h.

int plumbing::time_value::get_time_of_day (  ) 

The get_time_of_day method may be used to set the value of this time to be the value returned by the settimeofdae system call.

Returns:
The result of the gettimeofday system call: 0 in success, -1 on failure (with errno set).
bool plumbing::time_value::in_normal_form (  )  const [inline, private]

The in_normal_form method is used within asserts to guarantee that the internal data structure contains value values.

Note:
The microseconds are always positive. For example: the value -2.5 is represented as -3 + 0.5

Definition at line 184 of file time_value.h.

static time_value plumbing::time_value::now (  )  [static]

The now class method may be used to obtain the current time.

Note:
error reported by get_time_of_day will exit via plumbing::log.fatal_error - this isn't usually a problem.
plumbing::time_value::operator double (  )  const

The double operator may be used to cast a time value into a real number of seconds.

bool plumbing::time_value::operator!= ( const time_value  )  const
time_value plumbing::time_value::operator* ( long   )  const
time_value plumbing::time_value::operator* ( double   )  const
time_value& plumbing::time_value::operator*= ( long   ) 
time_value& plumbing::time_value::operator*= ( double   ) 
time_value plumbing::time_value::operator+ ( const time_value  )  const
time_value& plumbing::time_value::operator+= ( const time_value  ) 
time_value plumbing::time_value::operator- (  )  const
time_value plumbing::time_value::operator- ( const time_value  )  const
time_value& plumbing::time_value::operator-= ( const time_value  ) 
bool plumbing::time_value::operator< ( const time_value  )  const
bool plumbing::time_value::operator<= ( const time_value  )  const
time_value& plumbing::time_value::operator= ( long  sec  )  [inline]

The assignment operator.

Definition at line 114 of file time_value.h.

time_value& plumbing::time_value::operator= ( double   ) 

The assignment operator.

time_value& plumbing::time_value::operator= ( const time_value rhs  )  [inline]

The assignment operator.

Definition at line 95 of file time_value.h.

bool plumbing::time_value::operator== ( const time_value  )  const
bool plumbing::time_value::operator> ( const time_value  )  const
bool plumbing::time_value::operator>= ( const time_value  )  const
std::string plumbing::time_value::representation (  )  const

The representation method is used to form a human-readable representation of the time value.


The documentation for this class was generated from the following file:
Generated on Thu Sep 16 14:32:12 2010 for Plumbing by  doxygen 1.6.3