The Gaudi Framework  v29r0 (ff2e7097)
Gaudi::TimeSpan Class Reference

Based on seal::TimeSpan. More...

#include <GaudiKernel/Time.h>

Collaboration diagram for Gaudi::TimeSpan:

Public Types

typedef longlong ValueType
 

Public Member Functions

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

Private Attributes

ValueType m_nsecs = 0
 

Friends

class Time
 
bool operator== (const Gaudi::TimeSpan &t1, const Gaudi::TimeSpan &t2)
 
bool operator!= (const Gaudi::TimeSpan &t1, const Gaudi::TimeSpan &t2)
 
bool operator< (const Gaudi::TimeSpan &t1, const Gaudi::TimeSpan &t2)
 
bool operator<= (const Gaudi::TimeSpan &t1, const Gaudi::TimeSpan &t2)
 
bool operator> (const Gaudi::TimeSpan &t1, const Gaudi::TimeSpan &t2)
 
bool operator>= (const Gaudi::TimeSpan &t1, const Gaudi::TimeSpan &t2)
 
Gaudi::TimeSpan operator+ (const Gaudi::TimeSpan &ts1, const Gaudi::TimeSpan &ts2)
 
Gaudi::TimeSpan operator- (const Gaudi::TimeSpan &ts1, const Gaudi::TimeSpan &ts2)
 

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 55 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 ( )
default

Initialize an empty (zero) time difference.

Gaudi::TimeSpan::TimeSpan ( Time  t)
inline

Initialize a time span from Time t.

Definition at line 69 of file Time.icpp.

69 : m_nsecs( t.m_nsecs ) {}
ValueType m_nsecs
Definition: Time.h:111
Gaudi::TimeSpan::TimeSpan ( ValueType  nsecs)
inline

Initialize a time span to a specific length.

Definition at line 72 of file Time.icpp.

72 : m_nsecs( nsecs ) {}
ValueType m_nsecs
Definition: Time.h:111
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
secsSeconds.
nsecsNanoseconds.

Definition at line 82 of file Time.icpp.

82 : m_nsecs( secs * Time::SEC_NSECS + nsecs ) {}
ValueType m_nsecs
Definition: Time.h:111
static const ValueType SEC_NSECS
Nanoseconds in one second.
Definition: Time.h:267
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
daysWhole days.
hoursWhole hours.
minsWhole minutes.
secsWhole seconds.
nsecsNanoseconds.

Definition at line 95 of file Time.icpp.

96  {
97  m_nsecs = ( secs + 60 * ( mins + 60 * ( hours + 24 * days ) ) ) * Time::SEC_NSECS + nsecs;
98  }
ValueType m_nsecs
Definition: Time.h:111
static const ValueType SEC_NSECS
Nanoseconds in one second.
Definition: Time.h:267
int days() const
Get the number of complete days in the span.
Definition: Time.icpp:101
int hours() const
Get the number of complete hours in the span.
Definition: Time.icpp:104

Member Function Documentation

int Gaudi::TimeSpan::days ( ) const
inline

Get the number of complete days in the span.

Definition at line 101 of file Time.icpp.

101 { return int( m_nsecs / Time::SEC_NSECS / Time::SECS_PER_DAY ); }
ValueType m_nsecs
Definition: Time.h:111
static const ValueType SEC_NSECS
Nanoseconds in one second.
Definition: Time.h:267
static const int SECS_PER_DAY
Seconds in 24 hours.
Definition: Time.h:261
int Gaudi::TimeSpan::hours ( ) const
inline

Get the number of complete hours in the span.

Definition at line 104 of file Time.icpp.

104 { return int( m_nsecs / Time::SEC_NSECS / Time::SECS_PER_HOUR ); }
static const int SECS_PER_HOUR
Seconds in one hour hour.
Definition: Time.h:264
ValueType m_nsecs
Definition: Time.h:111
static const ValueType SEC_NSECS
Nanoseconds in one second.
Definition: Time.h:267
int Gaudi::TimeSpan::lastHours ( ) const
inline

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

Definition at line 117 of file Time.icpp.

117 { return hours() - days() * 24; }
int days() const
Get the number of complete days in the span.
Definition: Time.icpp:101
int hours() const
Get the number of complete hours in the span.
Definition: Time.icpp:104
int Gaudi::TimeSpan::lastMinutes ( ) const
inline

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

Definition at line 121 of file Time.icpp.

121 { return minutes() - hours() * 60; }
int hours() const
Get the number of complete hours in the span.
Definition: Time.icpp:104
int minutes() const
Get the number of complete minutes in the span.
Definition: Time.icpp:107
int Gaudi::TimeSpan::lastNSeconds ( ) const
inline

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

Definition at line 129 of file Time.icpp.

129 { return int( m_nsecs % Time::SEC_NSECS ); }
ValueType m_nsecs
Definition: Time.h:111
static const ValueType SEC_NSECS
Nanoseconds in one second.
Definition: Time.h:267
int Gaudi::TimeSpan::lastSeconds ( ) const
inline

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

Definition at line 125 of file Time.icpp.

125 { return int( seconds() - ( (ValueType)minutes() * (ValueType)60 ) ); }
longlong ValueType
Definition: Time.h:60
ValueType seconds() const
Get the number of complete seconds in the span.
Definition: Time.icpp:110
int minutes() const
Get the number of complete minutes in the span.
Definition: Time.icpp:107
int Gaudi::TimeSpan::minutes ( ) const
inline

Get the number of complete minutes in the span.

Definition at line 107 of file Time.icpp.

107 { return int( m_nsecs / Time::SEC_NSECS / 60 ); }
ValueType m_nsecs
Definition: Time.h:111
static const ValueType SEC_NSECS
Nanoseconds in one second.
Definition: Time.h:267
TimeSpan::ValueType Gaudi::TimeSpan::ns ( ) const
inline

Return the time span as nanoseconds.

Definition at line 113 of file Time.icpp.

113 { return m_nsecs; }
ValueType m_nsecs
Definition: Time.h:111
TimeSpan & Gaudi::TimeSpan::operator%= ( const TimeSpan x)
inline

Compute a modulo of a time span.

Definition at line 160 of file Time.icpp.

161  {
162  m_nsecs %= x.m_nsecs;
163  return *this;
164  }
ValueType m_nsecs
Definition: Time.h:111
TimeSpan & Gaudi::TimeSpan::operator*= ( const TimeSpan x)
inline

Multiply a time span.

Definition at line 146 of file Time.icpp.

147  {
148  m_nsecs *= x.m_nsecs;
149  return *this;
150  }
ValueType m_nsecs
Definition: Time.h:111
TimeSpan & Gaudi::TimeSpan::operator+= ( const TimeSpan x)
inline

Add to a time span.

Definition at line 132 of file Time.icpp.

133  {
134  m_nsecs += x.m_nsecs;
135  return *this;
136  }
ValueType m_nsecs
Definition: Time.h:111
TimeSpan & Gaudi::TimeSpan::operator-= ( const TimeSpan x)
inline

Subtract from a time span.

Definition at line 139 of file Time.icpp.

140  {
141  m_nsecs -= x.m_nsecs;
142  return *this;
143  }
ValueType m_nsecs
Definition: Time.h:111
TimeSpan & Gaudi::TimeSpan::operator/= ( const TimeSpan x)
inline

Divide a time span.

Definition at line 153 of file Time.icpp.

154  {
155  m_nsecs /= x.m_nsecs;
156  return *this;
157  }
ValueType m_nsecs
Definition: Time.h:111
TimeSpan::ValueType Gaudi::TimeSpan::seconds ( ) const
inline

Get the number of complete seconds in the span.

Definition at line 110 of file Time.icpp.

110 { return m_nsecs / Time::SEC_NSECS; }
ValueType m_nsecs
Definition: Time.h:111
static const ValueType SEC_NSECS
Nanoseconds in one second.
Definition: Time.h:267

Friends And Related Function Documentation

bool operator!= ( const Gaudi::TimeSpan t1,
const Gaudi::TimeSpan t2 
)
friend

Definition at line 90 of file Time.h.

90 { return t1.ns() != t2.ns(); }
ValueType ns() const
Return the time span as nanoseconds.
Definition: Time.icpp:113
Gaudi::TimeSpan operator+ ( const Gaudi::TimeSpan ts1,
const Gaudi::TimeSpan ts2 
)
friend

Definition at line 100 of file Time.h.

101  {
102  return Gaudi::TimeSpan( ts1.ns() + ts2.ns() );
103  }
ValueType ns() const
Return the time span as nanoseconds.
Definition: Time.icpp:113
Based on seal::TimeSpan.
Definition: Time.h:55
Gaudi::TimeSpan operator- ( const Gaudi::TimeSpan ts1,
const Gaudi::TimeSpan ts2 
)
friend

Definition at line 105 of file Time.h.

106  {
107  return Gaudi::TimeSpan( ts1.ns() - ts2.ns() );
108  }
ValueType ns() const
Return the time span as nanoseconds.
Definition: Time.icpp:113
Based on seal::TimeSpan.
Definition: Time.h:55
bool operator< ( const Gaudi::TimeSpan t1,
const Gaudi::TimeSpan t2 
)
friend

Definition at line 92 of file Time.h.

92 { return t1.ns() < t2.ns(); }
ValueType ns() const
Return the time span as nanoseconds.
Definition: Time.icpp:113
bool operator<= ( const Gaudi::TimeSpan t1,
const Gaudi::TimeSpan t2 
)
friend

Definition at line 94 of file Time.h.

94 { return t1.ns() <= t2.ns(); }
ValueType ns() const
Return the time span as nanoseconds.
Definition: Time.icpp:113
bool operator== ( const Gaudi::TimeSpan t1,
const Gaudi::TimeSpan t2 
)
friend

Definition at line 88 of file Time.h.

88 { return t1.ns() == t2.ns(); }
ValueType ns() const
Return the time span as nanoseconds.
Definition: Time.icpp:113
bool operator> ( const Gaudi::TimeSpan t1,
const Gaudi::TimeSpan t2 
)
friend

Definition at line 96 of file Time.h.

96 { return t1.ns() > t2.ns(); }
ValueType ns() const
Return the time span as nanoseconds.
Definition: Time.icpp:113
bool operator>= ( const Gaudi::TimeSpan t1,
const Gaudi::TimeSpan t2 
)
friend

Definition at line 98 of file Time.h.

98 { return t1.ns() >= t2.ns(); }
ValueType ns() const
Return the time span as nanoseconds.
Definition: Time.icpp:113
friend class Time
friend

Definition at line 57 of file Time.h.

Member Data Documentation

ValueType Gaudi::TimeSpan::m_nsecs = 0
private

Definition at line 111 of file Time.h.


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