CoreDX DDS Modern C++ API
Public Member Functions | Static Public Member Functions | List of all members
dds::core::Duration Class Reference

Duration represents a time interval and can -. More...

Public Member Functions

 Duration ()
 Create a Duration elapsing the default amount of time (zero seconds).
 
 Duration (int32_t sec, uint32_t nanosec=0)
 Create a Duration elapsing a specific amount of time. More...
 
int64_t sec () const
 Get seconds part of the Duration. More...
 
void sec (int64_t s)
 Set number of seconds. More...
 
uint32_t nanosec () const
 Get nanoseconds part of the Duration. More...
 
void nanosec (uint32_t ns)
 Set number of nanoseconds. More...
 
int 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) More...
 
bool operator> (const Duration &that) const
 Returns true if the Duration is greater than the comparator. More...
 
bool operator>= (const Duration &that) const
 Returns true if the Duration is greater than or equal to the comparator. More...
 
bool operator!= (const Duration &that) const
 Returns true if the Duration is not equal to the comparator. More...
 
bool operator== (const Duration &that) const
 Returns true if the Duration is equal to the comparator. More...
 
bool operator<= (const Duration &that) const
 Returns true if the Duration is less than or equal to the comparator. More...
 
bool operator< (const Duration &that) const
 Returns true if the Duration is less than the comparator. More...
 
Durationoperator+= (const Duration &a_ti)
 Add a Duration to this Duration. More...
 
Durationoperator-= (const Duration &a_ti)
 Subtract a Duration from this Duration. More...
 
Durationoperator*= (uint64_t factor)
 Multiply this Duration by a factor. More...
 
const Duration operator+ (const Duration &other) const
 Add a Duration to Duration. More...
 
const Duration operator- (const Duration &other) const
 Subtract a Duration from Duration. More...
 
int64_t to_millisecs () const
 Returns this Duration in milliseconds. More...
 
int64_t to_microsecs () const
 Returns this Duration in micro-seconds. More...
 
double to_secs () const
 Returns this Duration in seconds. More...
 

Static Public Member Functions

static const Duration zero ()
 Create a Duration elapsing zero seconds.
 
static const Duration infinite ()
 Create an infinite Duration.
 
static const Duration from_microsecs (int64_t microseconds)
 Create a Duration from a number of microseconds. More...
 
static const Duration from_millisecs (int64_t milliseconds)
 Create a Duration from a number of milliseconds. More...
 
static const Duration from_secs (double seconds)
 Create a Duration from a number of seconds. More...
 

Detailed Description

Duration represents a time interval and can -.

Constructor & Destructor Documentation

◆ Duration()

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
millisecondsnumber 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

◆ 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
thatDuration &

◆ 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

© 2009-2020 Twin Oaks Computing, Inc
Castle Rock, CO 80104
All rights reserved.