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

Based on seal::TimeSpan. More...

#include <GaudiKernel/Time.h>

Public Types

using ValueType = std::int64_t
 

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
 
auto operator<=> (const Gaudi::TimeSpan &t1, const Gaudi::TimeSpan &t2)=default
 
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 63 of file Time.h.

Member Typedef Documentation

◆ ValueType

using Gaudi::TimeSpan::ValueType = std::int64_t

Definition at line 67 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 375 of file Time.h.

375: m_nsecs( t.m_nsecs ) {}
ValueType m_nsecs
Definition Time.h:106

◆ TimeSpan() [3/5]

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

Initialize a time span to a specific length.

Definition at line 378 of file Time.h.

378: 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 388 of file Time.h.

388: m_nsecs( secs * Time::SEC_NSECS + nsecs ) {}
static constexpr ValueType SEC_NSECS
Nanoseconds in one second.
Definition Time.h:261

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

401 {
402 m_nsecs = ( secs + 60 * ( mins + 60 * ( hours + 24 * days ) ) ) * Time::SEC_NSECS + nsecs;
403 }
int days() const
Get the number of complete days in the span.
Definition Time.h:406
int hours() const
Get the number of complete hours in the span.
Definition Time.h:409

Member Function Documentation

◆ days()

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

Get the number of complete days in the span.

Definition at line 406 of file Time.h.

406{ return int( m_nsecs / Time::SEC_NSECS / Time::SECS_PER_DAY ); }
static constexpr int SECS_PER_DAY
Seconds in 24 hours.
Definition Time.h:255

◆ hours()

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

Get the number of complete hours in the span.

Definition at line 409 of file Time.h.

409{ return int( m_nsecs / Time::SEC_NSECS / Time::SECS_PER_HOUR ); }
static constexpr int SECS_PER_HOUR
Seconds in one hour hour.
Definition Time.h:258

◆ lastHours()

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

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

Definition at line 422 of file Time.h.

422{ 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 426 of file Time.h.

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

◆ lastNSeconds()

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

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

Definition at line 434 of file Time.h.

434{ 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 430 of file Time.h.

430{ return int( seconds() - ( (ValueType)minutes() * (ValueType)60 ) ); }
ValueType seconds() const
Get the number of complete seconds in the span.
Definition Time.h:415
std::int64_t ValueType
Definition Time.h:67

◆ minutes()

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

Get the number of complete minutes in the span.

Definition at line 412 of file Time.h.

412{ 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 418 of file Time.h.

418{ return m_nsecs; }

◆ operator%=()

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

Compute a modulo of a time span.

Definition at line 461 of file Time.h.

461 {
462 m_nsecs %= x.m_nsecs;
463 return *this;
464 }

◆ operator*=()

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

Multiply a time span.

Definition at line 449 of file Time.h.

449 {
450 m_nsecs *= x.m_nsecs;
451 return *this;
452 }

◆ operator+=()

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

Add to a time span.

Definition at line 437 of file Time.h.

437 {
438 m_nsecs += x.m_nsecs;
439 return *this;
440 }

◆ operator-=()

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

Subtract from a time span.

Definition at line 443 of file Time.h.

443 {
444 m_nsecs -= x.m_nsecs;
445 return *this;
446 }

◆ operator/=()

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

Divide a time span.

Definition at line 455 of file Time.h.

455 {
456 m_nsecs /= x.m_nsecs;
457 return *this;
458 }

◆ seconds()

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

Get the number of complete seconds in the span.

Definition at line 415 of file Time.h.

415{ return m_nsecs / Time::SEC_NSECS; }

Friends And Related Symbol Documentation

◆ operator+

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

Definition at line 97 of file Time.h.

97 {
98 return Gaudi::TimeSpan( ts1.ns() + ts2.ns() );
99 }
ValueType ns() const
Return the time span as nanoseconds.
Definition Time.h:418

◆ operator-

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

Definition at line 101 of file Time.h.

101 {
102 return Gaudi::TimeSpan( ts1.ns() - ts2.ns() );
103 }

◆ operator<=>

auto operator<=> ( const Gaudi::TimeSpan & t1,
const Gaudi::TimeSpan & t2 )
friend

◆ Time

friend class Time
friend

Definition at line 64 of file Time.h.

Member Data Documentation

◆ m_nsecs

ValueType Gaudi::TimeSpan::m_nsecs = 0
private

Definition at line 106 of file Time.h.


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