| # Gaudi Framework, version v21r10p1 |

Home |  | Generated: 29 Jul 2010

# Gaudi::TimeSpan Class Reference

Based on seal::TimeSpan. More...

`#include <GaudiKernel/Time.h>`

Collaboration diagram for Gaudi::TimeSpan:

[legend]

List of all members.

## Public Types
typedef longlong | ValueType
## Public Member Functions
| TimeSpan (void)
| Initialize an empty (zero) time difference.
| TimeSpan (Time t)
| Initialize a time span from Time t.
| TimeSpan (ValueType nsecs)
| Initialize a time span to a specific length.
| TimeSpan (ValueType secs, int nsecs)
| Initialise a time span to a specific length.
| TimeSpan (int days, int hours, int mins, int secs, int nsecs)
| Initialise a time span to a specific length.
int | days (void) const
| Get the number of complete days in the span.
int | hours (void) const
| Get the number of complete hours in the span.
int | minutes (void) const
| Get the number of complete minutes in the span.
ValueType | seconds (void) const
| Get the number of complete seconds in the span.
int | lastHours (void) const
| Get the number of complete hours in the last incomplete day of the span.
int | lastMinutes (void) const
| Get the number of complete minutes in the last incomplete hour of the span.
int | lastSeconds (void) const
| Get the number of complete seconds in the last incomplete minute of the span.
int | lastNSeconds (void) const
| Get the number of nanoseconds in the last incomplete second of the span.
TimeSpan & | operator+= (const TimeSpan &x)
| Add to a time span.
TimeSpan & | operator-= (const TimeSpan &x)
| Subtract from a time span.
TimeSpan & | operator*= (const TimeSpan &n)
| Multiply a time span.
TimeSpan & | operator/= (const TimeSpan &n)
| Divide a time span.
TimeSpan & | operator%= (const TimeSpan &n)
| Compute a modulo of a time span.
ValueType | ns (void) const
| Return the time span as nanoseconds.
## Private Attributes
ValueType | m_nsecs
## Friends
class | Time

## Detailed Description

Based on seal::TimeSpan.

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.

(Documentation taken from original SEAL class)

Author:
  Marco Clemencic

Date:
  2005-12-15

Definition at line 57 of file Time.h.

## Member Typedef Documentation

typedef longlong Gaudi::TimeSpan::ValueType

Definition at line 60 of file Time.h.

## Constructor & Destructor Documentation

Gaudi::TimeSpan::TimeSpan | ( | void |  | ) | `[inline]`

Initialize an empty (zero) time difference.

Definition at line 74 of file Time.icpp.

    00074 : m_nsecs(0) {}

Gaudi::TimeSpan::TimeSpan | ( | Time | t | ) | `[inline]`

Initialize a time span from Time t.

Definition at line 77 of file Time.icpp.

    00077 : m_nsecs (t.m_nsecs) {}

Gaudi::TimeSpan::TimeSpan | ( | ValueType | nsecs | ) | `[inline]`

Initialize a time span to a specific length.

Definition at line 80 of file Time.icpp.

    00080 : m_nsecs (nsecs) {}

Gaudi::TimeSpan::TimeSpan | ( | ValueType | secs,
|  | int | 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 90 of file Time.icpp.

    00091     : m_nsecs(secs * Time::SEC_NSECS + nsecs) {}

Gaudi::TimeSpan::TimeSpan | ( | int | days,
|  | int | hours,
|  | int | mins,
|  | int | secs,
|  | int | 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 104 of file Time.icpp.

    00104                                                                                {
    00105     m_nsecs = (secs + 60 * (mins + 60 * (hours + 24*days)))*Time::SEC_NSECS + nsecs;
    00106   }

## Member Function Documentation

int Gaudi::TimeSpan::days | ( | void |  | ) | const`[inline]`

Get the number of complete days in the span.

Definition at line 109 of file Time.icpp.

    00109                                        {
    00110     return int(m_nsecs / Time::SEC_NSECS / Time::SECS_PER_DAY);
    00111   }

int Gaudi::TimeSpan::hours | ( | void |  | ) | const`[inline]`

Get the number of complete hours in the span.

Definition at line 114 of file Time.icpp.

    00114                                         {
    00115     return int(m_nsecs / Time::SEC_NSECS / Time::SECS_PER_HOUR);
    00116   }

int Gaudi::TimeSpan::minutes | ( | void |  | ) | const`[inline]`

Get the number of complete minutes in the span.

Definition at line 119 of file Time.icpp.

    00119                                           {
    00120     return int(m_nsecs / Time::SEC_NSECS / 60);
    00121   }

TimeSpan::ValueType Gaudi::TimeSpan::seconds | ( | void |  | ) | const`[inline]`

Get the number of complete seconds in the span.

Definition at line 124 of file Time.icpp.

    00124                                                         {
    00125     return m_nsecs / Time::SEC_NSECS;
    00126   }

int Gaudi::TimeSpan::lastHours | ( | void |  | ) | const`[inline]`

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

Definition at line 135 of file Time.icpp.

    00135                                             {
    00136     return hours () - days () * 24;
    00137   }

int Gaudi::TimeSpan::lastMinutes | ( | void |  | ) | const`[inline]`

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

Definition at line 141 of file Time.icpp.

    00141                                               {
    00142     return minutes () - hours () * 60;
    00143   }

int Gaudi::TimeSpan::lastSeconds | ( | void |  | ) | const`[inline]`

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

Definition at line 147 of file Time.icpp.

    00147                                               {
    00148     return int(seconds() - ( (ValueType)minutes() * (ValueType)60 ));
    00149   }

int Gaudi::TimeSpan::lastNSeconds | ( | void |  | ) | const`[inline]`

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

Definition at line 153 of file Time.icpp.

    00153                                                {
    00154     return int(m_nsecs % Time::SEC_NSECS);
    00155   }

TimeSpan & Gaudi::TimeSpan::operator+= | ( | const TimeSpan & | x | ) | `[inline]`

Add to a time span.

Definition at line 158 of file Time.icpp.

    00158                                                           {
    00159     m_nsecs += x.m_nsecs;
    00160     return *this;
    00161   }

TimeSpan & Gaudi::TimeSpan::operator-= | ( | const TimeSpan & | x | ) | `[inline]`

Subtract from a time span.

Definition at line 164 of file Time.icpp.

    00164                                                            {
    00165     m_nsecs -= x.m_nsecs;
    00166     return *this;
    00167   }

TimeSpan & Gaudi::TimeSpan::operator*= | ( | const TimeSpan & | x | ) | `[inline]`

Multiply a time span.

Definition at line 170 of file Time.icpp.

    00170                                                            {
    00171     m_nsecs *= x.m_nsecs;
    00172     return *this;
    00173   }

TimeSpan & Gaudi::TimeSpan::operator/= | ( | const TimeSpan & | x | ) | `[inline]`

Divide a time span.

Definition at line 176 of file Time.icpp.

    00176                                                            {
    00177     m_nsecs /= x.m_nsecs; return *this;
    00178   }

TimeSpan & Gaudi::TimeSpan::operator%= | ( | const TimeSpan & | x | ) | `[inline]`

Compute a modulo of a time span.

Definition at line 181 of file Time.icpp.

    00181                                                            {
    00182     m_nsecs %= x.m_nsecs; return *this;
    00183   }

TimeSpan::ValueType Gaudi::TimeSpan::ns | ( | void |  | ) | const`[inline]`

Return the time span as nanoseconds.

Definition at line 129 of file Time.icpp.

    00129                                                    {
    00130     return m_nsecs;
    00131   }

## Friends And Related Function Documentation

friend class Time`[friend]`

Definition at line 58 of file Time.h.

## Member Data Documentation

ValueType Gaudi::TimeSpan::m_nsecs`[private]`

Definition at line 87 of file Time.h.

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

- /afs/cern.ch/sw/Gaudi/releases/GAUDI/GAUDI_v21r10p1/GaudiKernel/GaudiKernel/Time.h
- /afs/cern.ch/sw/Gaudi/releases/GAUDI/GAUDI_v21r10p1/GaudiKernel/GaudiKernel/Time.icpp