The Gaudi Framework  master (ff829712)
Loading...
Searching...
No Matches
Gaudi::TimeSpan Class Reference

Based on seal::TimeSpan. More...

#include <GaudiKernel/Time.h>

Public Types

typedef long long ValueType
 

Public Member Functions

 TimeSpan ()=default
 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 () const
 Get the number of complete days in the span.
 
int hours () const
 Get the number of complete hours in the span.
 
int minutes () const
 Get the number of complete minutes in the span.
 
ValueType seconds () const
 Get the number of complete seconds in the span.
 
int lastHours () const
 Get the number of complete hours in the last incomplete day of the span.
 
int lastMinutes () const
 Get the number of complete minutes in the last incomplete hour of the span.
 
int lastSeconds () const
 Get the number of complete seconds in the last incomplete minute of the span.
 
int lastNSeconds () const
 Get the number of nanoseconds in the last incomplete second of the span.
 
TimeSpanoperator+= (const TimeSpan &x)
 Add to a time span.
 
TimeSpanoperator-= (const TimeSpan &x)
 Subtract from a time span.
 
TimeSpanoperator*= (const TimeSpan &n)
 Multiply a time span.
 
TimeSpanoperator/= (const TimeSpan &n)
 Divide a time span.
 
TimeSpanoperator%= (const TimeSpan &n)
 Compute a modulo of a time span.
 
ValueType ns () const
 Return the time span as nanoseconds.
 

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 56 of file Time.h.

Member Typedef Documentation

◆ ValueType

typedef long long Gaudi::TimeSpan::ValueType

Definition at line 60 of file Time.h.

Constructor & Destructor Documentation

◆ TimeSpan() [1/5]

Gaudi::TimeSpan::TimeSpan ( )
default

Initialize an empty (zero) time difference.

◆ TimeSpan() [2/5]

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

Initialize a time span from Time t.

Definition at line 71 of file Time.icpp.

71: m_nsecs( t.m_nsecs ) {}
ValueType m_nsecs
Definition Time.h:109

◆ TimeSpan() [3/5]

Gaudi::TimeSpan::TimeSpan ( ValueType nsecs)
inline

Initialize a time span to a specific length.

Definition at line 74 of file Time.icpp.

74: m_nsecs( nsecs ) {}

◆ TimeSpan() [4/5]

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 84 of file Time.icpp.

84: m_nsecs( secs * Time::SEC_NSECS + nsecs ) {}
static const ValueType SEC_NSECS
Nanoseconds in one second.
Definition Time.h:264

◆ TimeSpan() [5/5]

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 97 of file Time.icpp.

97 {
98 m_nsecs = ( secs + 60 * ( mins + 60 * ( hours + 24 * days ) ) ) * Time::SEC_NSECS + nsecs;
99 }
int days() const
Get the number of complete days in the span.
Definition Time.icpp:102
int hours() const
Get the number of complete hours in the span.
Definition Time.icpp:105

Member Function Documentation

◆ days()

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

Get the number of complete days in the span.

Definition at line 102 of file Time.icpp.

102{ return int( m_nsecs / Time::SEC_NSECS / Time::SECS_PER_DAY ); }
static const int SECS_PER_DAY
Seconds in 24 hours.
Definition Time.h:258

◆ hours()

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

Get the number of complete hours in the span.

Definition at line 105 of file Time.icpp.

105{ 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:261

◆ lastHours()

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

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

Definition at line 118 of file Time.icpp.

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

◆ lastMinutes()

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

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

Definition at line 122 of file Time.icpp.

122{ return minutes() - hours() * 60; }
int minutes() const
Get the number of complete minutes in the span.
Definition Time.icpp:108

◆ lastNSeconds()

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

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

Definition at line 130 of file Time.icpp.

130{ return int( m_nsecs % Time::SEC_NSECS ); }

◆ lastSeconds()

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

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

Definition at line 126 of file Time.icpp.

126{ return int( seconds() - ( (ValueType)minutes() * (ValueType)60 ) ); }
ValueType seconds() const
Get the number of complete seconds in the span.
Definition Time.icpp:111
long long ValueType
Definition Time.h:60

◆ minutes()

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

Get the number of complete minutes in the span.

Definition at line 108 of file Time.icpp.

108{ return int( m_nsecs / Time::SEC_NSECS / 60 ); }

◆ ns()

TimeSpan::ValueType Gaudi::TimeSpan::ns ( ) const
inline

Return the time span as nanoseconds.

Definition at line 114 of file Time.icpp.

114{ return m_nsecs; }

◆ operator%=()

TimeSpan & Gaudi::TimeSpan::operator%= ( const TimeSpan & n)
inline

Compute a modulo of a time span.

Definition at line 157 of file Time.icpp.

157 {
158 m_nsecs %= x.m_nsecs;
159 return *this;
160 }

◆ operator*=()

TimeSpan & Gaudi::TimeSpan::operator*= ( const TimeSpan & n)
inline

Multiply a time span.

Definition at line 145 of file Time.icpp.

145 {
146 m_nsecs *= x.m_nsecs;
147 return *this;
148 }

◆ operator+=()

TimeSpan & Gaudi::TimeSpan::operator+= ( const TimeSpan & x)
inline

Add to a time span.

Definition at line 133 of file Time.icpp.

133 {
134 m_nsecs += x.m_nsecs;
135 return *this;
136 }

◆ operator-=()

TimeSpan & Gaudi::TimeSpan::operator-= ( const TimeSpan & x)
inline

Subtract from a time span.

Definition at line 139 of file Time.icpp.

139 {
140 m_nsecs -= x.m_nsecs;
141 return *this;
142 }

◆ operator/=()

TimeSpan & Gaudi::TimeSpan::operator/= ( const TimeSpan & n)
inline

Divide a time span.

Definition at line 151 of file Time.icpp.

151 {
152 m_nsecs /= x.m_nsecs;
153 return *this;
154 }

◆ seconds()

TimeSpan::ValueType Gaudi::TimeSpan::seconds ( ) const
inline

Get the number of complete seconds in the span.

Definition at line 111 of file Time.icpp.

111{ return m_nsecs / Time::SEC_NSECS; }

Friends And Related Symbol Documentation

◆ operator!=

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(); }
TemplatedAlg< int, std::vector< std::string > > t1
TemplatedAlg< double, bool > t2

◆ operator+

Gaudi::TimeSpan operator+ ( const Gaudi::TimeSpan & ts1,
const Gaudi::TimeSpan & ts2 )
friend

Definition at line 100 of file Time.h.

100 {
101 return Gaudi::TimeSpan( ts1.ns() + ts2.ns() );
102 }
ValueType ns() const
Return the time span as nanoseconds.
Definition Time.icpp:114

◆ operator-

Gaudi::TimeSpan operator- ( const Gaudi::TimeSpan & ts1,
const Gaudi::TimeSpan & ts2 )
friend

Definition at line 104 of file Time.h.

104 {
105 return Gaudi::TimeSpan( ts1.ns() - ts2.ns() );
106 }

◆ operator<

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(); }

◆ operator<=

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(); }

◆ operator==

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(); }

◆ operator>

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(); }

◆ operator>=

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(); }

◆ Time

friend class Time
friend

Definition at line 57 of file Time.h.

Member Data Documentation

◆ m_nsecs

ValueType Gaudi::TimeSpan::m_nsecs = 0
private

Definition at line 109 of file Time.h.


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