CMS 3D CMS Logo

lat::TimeSpan Class Reference

A difference between two Time values. More...

#include <Iguana/Utilities/classlib/utils/Time.h>

List of all members.

Public Types

typedef TimeConst::TimeValue ValueType

Public Member Functions

long days (void) const
 Get the number of complete days in the span.
long hours (void) const
 Get the number of complete hours in the span.
long lastHours (void) const
 Get the number of complete hours in the last incomplete day of the span.
long lastMinutes (void) const
 Get the number of complete minutes in the last incomplete hour of the span.
long lastNSeconds (void) const
 Get the number of nanoseconds in the last incomplete second of the span.
long lastSeconds (void) const
 Get the number of complete seconds in the last incomplete minute of the span.
long minutes (void) const
 Get the number of complete minutes in the span.
ValueType ns (void) const
 Return the time span as nanoseconds.
TimeSpanoperator *= (TimeSpan n)
 Multiply a time span.
TimeSpanoperator%= (TimeSpan n)
 Compute a modulo of a time span.
TimeSpanoperator+= (TimeSpan x)
 Add to a time span.
TimeSpanoperator-= (TimeSpan x)
 Subtract from a time span.
TimeSpanoperator/= (TimeSpan n)
 Divide a time span.
long seconds (void) const
 Get the number of complete seconds in the span.
 TimeSpan (long days, int hours, int mins, int secs, ValueType nsecs)
 Initialise a time span to a specific length.
 TimeSpan (ValueType secs, ValueType nsecs)
 Initialise a time span to a specific length.
 TimeSpan (ValueType nsecs)
 Initialize a time span to a specific length.
 TimeSpan (Time t)
 Initialize a time span from Time t.
 TimeSpan (void)
 Initialize an empty (zero) time difference.

Private Attributes

ValueType m_nsecs

Friends

class Time


Detailed Description

A difference between two Time values.

In addition to supporting normal integer artihmetic and comparisons, the span can also be converted to a number useful units.

See also:
Time.

Definition at line 39 of file Time.h.


Member Typedef Documentation

typedef TimeConst::TimeValue lat::TimeSpan::ValueType

Definition at line 43 of file Time.h.


Constructor & Destructor Documentation

lat::TimeSpan::TimeSpan ( void   )  [inline]

Initialize an empty (zero) time difference.

Definition at line 317 of file Time.h.

Referenced by lat::operator *(), lat::operator%(), lat::operator+(), lat::operator-(), and lat::operator/().

00318     : m_nsecs (0)
00319 {}

lat::TimeSpan::TimeSpan ( Time  t  )  [inline]

Initialize a time span from Time t.

Definition at line 323 of file Time.h.

00324     : m_nsecs (t.m_nsecs)
00325 {}

lat::TimeSpan::TimeSpan ( ValueType  nsecs  )  [inline]

Initialize a time span to a specific length.

Definition at line 329 of file Time.h.

00330     : m_nsecs (nsecs)
00331 {}

lat::TimeSpan::TimeSpan ( ValueType  secs,
ValueType  nsecs 
) [inline]

Initialise a time span to a specific length.

The value is initialised to the sum of the parts---the parts do not need to fall into their "natural" ranges. The values are normalised to the natural meanings (e.g. 1000 seconds - 500 nanoseconds), so be careful with signs if you are producing values from other sources.

Parameters:
secs Seconds.
nsecs Nanoseconds.

Definition at line 342 of file Time.h.

References m_nsecs, and lat::TimeConst::SEC_NSECS.

00343 { m_nsecs = secs * TimeConst::SEC_NSECS + nsecs; }

lat::TimeSpan::TimeSpan ( long  days,
int  hours,
int  mins,
int  secs,
ValueType  nsecs 
) [inline]

Initialise a time span to a specific length.

The value is initialised to the sum of the parts---the parts do not need to fall into their "natural" ranges. The values are normalised to the natural meanings (e.g. 1000 seconds - 500 nanoseconds), so be careful with signs if you are producing values from other sources.

Parameters:
days Whole days.
hours Whole hours.
mins Whole minutes.
secs Whole seconds.
nsecs Nanoseconds.

Definition at line 357 of file Time.h.

References m_nsecs, and lat::TimeConst::SEC_NSECS.

00358 { m_nsecs = (secs + 60 * (mins + 60 * (hours + 24*days)))*TimeConst::SEC_NSECS + nsecs; }


Member Function Documentation

long lat::TimeSpan::days ( void   )  const [inline]

Get the number of complete days in the span.

Definition at line 362 of file Time.h.

References m_nsecs, lat::TimeConst::SEC_NSECS, and lat::TimeConst::SECS_PER_DAY.

Referenced by lastHours().

long lat::TimeSpan::hours ( void   )  const [inline]

Get the number of complete hours in the span.

Definition at line 367 of file Time.h.

References m_nsecs, lat::TimeConst::SEC_NSECS, and lat::TimeConst::SECS_PER_HOUR.

Referenced by lastHours(), and lastMinutes().

long lat::TimeSpan::lastHours ( void   )  const [inline]

Get the number of complete hours in the last incomplete day of the span.

Definition at line 388 of file Time.h.

References days(), and hours().

00389 { return hours () - days () * 24; }

long lat::TimeSpan::lastMinutes ( void   )  const [inline]

Get the number of complete minutes in the last incomplete hour of the span.

Definition at line 394 of file Time.h.

References hours(), and minutes().

00395 { return minutes () - hours () * 60; }

long lat::TimeSpan::lastNSeconds ( void   )  const [inline]

Get the number of nanoseconds in the last incomplete second of the span.

Definition at line 406 of file Time.h.

References m_nsecs, and lat::TimeConst::SEC_NSECS.

00407 { return long(m_nsecs % TimeConst::SEC_NSECS); }

long lat::TimeSpan::lastSeconds ( void   )  const [inline]

Get the number of complete seconds in the last incomplete minute of the span.

Definition at line 400 of file Time.h.

References minutes(), and seconds().

00401 { return seconds () - minutes () * 60; }

long lat::TimeSpan::minutes ( void   )  const [inline]

Get the number of complete minutes in the span.

Definition at line 372 of file Time.h.

References m_nsecs, and lat::TimeConst::SEC_NSECS.

Referenced by lastMinutes(), and lastSeconds().

00373 { return long(m_nsecs / TimeConst::SEC_NSECS / 60); }

TimeSpan::ValueType lat::TimeSpan::ns ( void   )  const [inline]

Return the time span as nanoseconds.

Definition at line 382 of file Time.h.

References m_nsecs.

Referenced by lat::operator *(), lat::operator!(), lat::operator!=(), lat::operator%(), lat::operator+(), lat::operator-(), lat::operator/(), lat::operator<(), lat::operator<=(), lat::operator==(), lat::operator>(), and lat::operator>=().

00383 { return m_nsecs; }

TimeSpan & lat::TimeSpan::operator *= ( TimeSpan  x  )  [inline]

Multiply a time span.

Definition at line 421 of file Time.h.

References m_nsecs.

00422 { m_nsecs *= x.m_nsecs; return *this; }

TimeSpan & lat::TimeSpan::operator%= ( TimeSpan  x  )  [inline]

Compute a modulo of a time span.

Definition at line 431 of file Time.h.

References m_nsecs.

00432 { m_nsecs %= x.m_nsecs; return *this; }

TimeSpan & lat::TimeSpan::operator+= ( TimeSpan  x  )  [inline]

Add to a time span.

Definition at line 411 of file Time.h.

References m_nsecs.

00412 { m_nsecs += x.m_nsecs; return *this; }

TimeSpan & lat::TimeSpan::operator-= ( TimeSpan  x  )  [inline]

Subtract from a time span.

Definition at line 416 of file Time.h.

References m_nsecs.

00417 { m_nsecs -= x.m_nsecs; return *this; }

TimeSpan & lat::TimeSpan::operator/= ( TimeSpan  x  )  [inline]

Divide a time span.

Definition at line 426 of file Time.h.

References m_nsecs.

00427 { m_nsecs /= x.m_nsecs; return *this; }

long lat::TimeSpan::seconds ( void   )  const [inline]

Get the number of complete seconds in the span.

Definition at line 377 of file Time.h.

References m_nsecs, and lat::TimeConst::SEC_NSECS.

Referenced by lastSeconds().

00378 { return long(m_nsecs / TimeConst::SEC_NSECS); }


Friends And Related Function Documentation

friend class Time [friend]

Definition at line 41 of file Time.h.

Referenced by lat::operator+(), and lat::operator-().


Member Data Documentation

ValueType lat::TimeSpan::m_nsecs [private]

Definition at line 73 of file Time.h.

Referenced by days(), hours(), lastNSeconds(), minutes(), ns(), operator *=(), operator%=(), lat::Time::operator+=(), operator+=(), lat::Time::operator-=(), operator-=(), operator/=(), seconds(), and TimeSpan().


The documentation for this class was generated from the following file:
Generated on Tue Jun 9 18:48:36 2009 for CMSSW by  doxygen 1.5.4