Cyclone ISO C++ API Reference Guide
dds::core::Duration Class Reference

#include "Duration.hpp"

Public Member Functions

 Duration ()
 
 Duration (int32_t sec, uint32_t nanosec=0)
 
int compare (const Duration &that) const
 
uint32_t nanosec () const
 
void nanosec (uint32_t ns)
 
bool operator!= (const Duration &that) const
 
Durationoperator*= (uint64_t factor)
 
const Duration operator+ (const Duration &other) const
 
Durationoperator+= (const Duration &a_ti)
 
const Duration operator- (const Duration &other) const
 
Durationoperator-= (const Duration &a_ti)
 
bool operator< (const Duration &that) const
 
bool operator<= (const Duration &that) const
 
bool operator== (const Duration &that) const
 
bool operator> (const Duration &that) const
 
bool operator>= (const Duration &that) const
 
int64_t sec () const
 
void sec (int64_t s)
 
int64_t to_microsecs () const
 
int64_t to_millisecs () const
 
double to_secs () const
 

Static Public Member Functions

static const Duration from_microsecs (int64_t microseconds)
 
static const Duration from_millisecs (int64_t milliseconds)
 
static const Duration from_secs (double seconds)
 
static const Duration infinite ()
 
static const Duration zero ()
 

Detailed Description

Duration represents a time interval and can -

  • Can be incremented by durations expressed as seconds, nanoseconds milliseconds, or Duration objects.
  • Can be converted to and from Durations expressed in milliseconds (or other units) as integer types.

Definition at line 42 of file Duration.hpp.

Constructor & Destructor Documentation

◆ Duration() [1/2]

dds::core::Duration::Duration ( )

Create a Duration elapsing the default amount of time (zero seconds).

◆ Duration() [2/2]

dds::core::Duration::Duration ( int32_t  sec,
uint32_t  nanosec = 0 
)
explicit

Create a Duration elapsing a specific amount of time.

Parameters
secAmount of seconds for the Duration.
nanosecAmount of nanoseconds for the Duration.

Member Function Documentation

◆ compare()

int dds::core::Duration::compare ( const Duration that) const

Returns an integer value for a comparison of two Durations: 1 if this Duration is greater than the comparator (that) -1 if the Duration is less than the comparator (that) 0 if the Duration matches the comparator (that)

Parameters
thatDuration to compare
Returns
comparison result

◆ from_microsecs()

static const Duration dds::core::Duration::from_microsecs ( int64_t  microseconds)
static

Create a Duration from a number of microseconds

Parameters
microsecondsnumber of microseconds

◆ from_millisecs()

static const Duration dds::core::Duration::from_millisecs ( int64_t  milliseconds)
static

Create a Duration from a number of milliseconds

Parameters
milisecondsnumber of milliseconds

◆ from_secs()

static const Duration dds::core::Duration::from_secs ( double  seconds)
static

Create a Duration from a number of seconds

Parameters
secondsnumber of seconds

◆ infinite()

static const Duration dds::core::Duration::infinite ( )
static

Create an infinite Duration.

◆ nanosec() [1/2]

uint32_t dds::core::Duration::nanosec ( ) const

Get nanoseconds part of the Duration.

Returns
number of nanoseconds

◆ nanosec() [2/2]

void dds::core::Duration::nanosec ( uint32_t  ns)

Set number of nanoseconds

Parameters
nsnumber of nanoseconds

◆ operator!=()

bool dds::core::Duration::operator!= ( const Duration that) const

Returns true if the Duration is not equal to the comparator

Parameters
thatDuration to compare
Returns
comparison result

◆ operator*=()

Duration& dds::core::Duration::operator*= ( uint64_t  factor)

Multiply this Duration by a factor

Parameters
factorthe factor to multiply this Duration by
Returns
this Duration * factor

◆ operator+()

const Duration dds::core::Duration::operator+ ( const Duration other) const

Add a Duration to Duration

Parameters
othera Duration
Returns
Duration + other

◆ operator+=()

Duration& dds::core::Duration::operator+= ( const Duration a_ti)

Add a Duration to this Duration

Parameters
a_tiDuration to add
Returns
this Duration + a_ti

◆ operator-()

const Duration dds::core::Duration::operator- ( const Duration other) const

Subtract a Duration from Duration

Parameters
othera Duration
Returns
the Duration - other

◆ operator-=()

Duration& dds::core::Duration::operator-= ( const Duration a_ti)

Subtract a Duration from this Duration

Parameters
a_tiDuration to subtract
Returns
this Duration - a_ti

◆ operator<()

bool dds::core::Duration::operator< ( const Duration that) const

Returns true if the Duration is less than the comparator

Parameters
thatDuration to compare
Returns
comparison result

◆ operator<=()

bool dds::core::Duration::operator<= ( const Duration that) const

Returns true if the Duration is less than or equal to the comparator

Parameters
thatDuration to compare
Returns
comparison result

◆ operator==()

bool dds::core::Duration::operator== ( const Duration that) const

Returns true if the Duration is equal to the comparator

Parameters
thatDuration to compare
Returns
comparison result

◆ operator>()

bool dds::core::Duration::operator> ( const Duration that) const

Returns true if the Duration is greater than the comparator

Parameters
thatDuration to compare
Returns
comparison result

◆ operator>=()

bool dds::core::Duration::operator>= ( const Duration that) const

Returns true if the Duration is greater than or equal to the comparator

Parameters
Duration&that

◆ sec() [1/2]

int64_t dds::core::Duration::sec ( ) const

Get seconds part of the Duration.

Returns
number of seconds

◆ sec() [2/2]

void dds::core::Duration::sec ( int64_t  s)

Set number of seconds

Parameters
snumber of seconds

◆ to_microsecs()

int64_t dds::core::Duration::to_microsecs ( ) const

Returns this Duration in micro-seconds.

Returns
the duration in micro-seconds

◆ to_millisecs()

int64_t dds::core::Duration::to_millisecs ( ) const

Returns this Duration in milliseconds.

Returns
the duration in milliseconds

◆ to_secs()

double dds::core::Duration::to_secs ( ) const

Returns this Duration in seconds.

Returns
the duration in seconds

◆ zero()

static const Duration dds::core::Duration::zero ( )
static

Create a Duration elapsing zero seconds.


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