RTI Connext Modern C++ API  Version 6.0.1
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
dds::core::Duration Class Reference

<<value-type>> Represents a time interval More...

#include <Duration.hpp>

Public Member Functions

 Duration ()
 Create a Duration elapsing zero seconds.
 
 Duration (int32_t sec, uint32_t nanosec=0)
 Create a duration elapsing a specific amount of time.
 
template<typename Rep , typename Period >
 Duration (const std::chrono::duration< Rep, Period > &duration)
 <<C++11>> <<extension>> Allow implicit creation from std::chrono::duration
 
int32_t sec () const
 Get the number of seconds represented by this Duration object.
 
void sec (int32_t s)
 Set the number of seconds represented by this Duration object.
 
uint32_t nanosec () const
 Get the number of nanoseconds represented by this Duration object.
 
void nanosec (uint32_t ns)
 Set the number of nanoseconds represented by this Duration object.
 
int compare (const Duration &that) const
 Compare two Duration objects.
 
bool operator> (const Duration &that) const
 Check if this Duration is greater than another.
 
bool operator>= (const Duration &that) const
 Check if this Duration is greater than or equal another.
 
bool operator== (const Duration &that) const
 Check if this Duration is equal to another.
 
bool operator!= (const Duration &other) const
 Check if this Duration is not equal to another.
 
bool operator<= (const Duration &that) const
 Check if this Duration is less than or equal another.
 
bool operator< (const Duration &that) const
 Check if this Duration is less than another.
 
Durationoperator+= (const Duration &a_ti)
 Add a Duration to this Duration.
 
Durationoperator-= (const Duration &a_ti)
 Subtract a Duration from this Duration.
 
Duration operator+ (const Duration &other) const
 Add two Duration objects.
 
Duration operator- (const Duration &other) const
 Subtract a Duration.
 
uint64_t to_millisecs () const
 Returns this Duration in milliseconds.
 
uint64_t to_microsecs () const
 Returns this Duration in microseconds.
 
double to_secs () const
 Returns this Duration in seconds.
 
std::chrono::nanoseconds to_chrono () const
 <<C++11>> <<extension>> Converts to std::chrono::nanoseconds
 

Static Public Member Functions

static Duration zero ()
 Returns a zero duration.
 
static Duration infinite ()
 Special value that represents an infinite Duration.
 
static Duration automatic ()
 Special value that indicates that RTI Connext will automatically assign a value.
 
static Duration from_microsecs (uint64_t microseconds)
 Create a Duration elapsing a specific number of microseconds.
 
static Duration from_millisecs (uint64_t milliseconds)
 Create a Duration elapsing a specific number of milliseconds.
 
static Duration from_secs (double seconds)
 Create a Duration elapsing a specific number of seconds.
 

Related Functions

(Note that these are not member functions.)

Duration operator* (uint32_t lhs, const Duration &rhs)
 Multiply a Duration object by an unsigned integer.
 
Duration operator* (const Duration &lhs, uint32_t rhs)
 Multiply a Duration object by an unsigned integer.
 
Duration operator/ (const Duration &lhs, uint32_t rhs)
 Divide a Duration object by an unsigned integer.
 
void swap (Duration &lhs, Duration &rhs) OMG_NOEXCEPT
 Swap the contents of two Duration objects.
 

Detailed Description

<<value-type>> Represents a time interval

Examples:
Foo_publisher.cxx, and Foo_subscriber.cxx.

Constructor & Destructor Documentation

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

Create a Duration elapsing zero seconds.

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

Create a duration elapsing a specific amount of time.

Parameters
secThe number of seconds to represent
nanosecThe number of nanoseconds to represent
template<typename Rep , typename Period >
dds::core::Duration::Duration ( const std::chrono::duration< Rep, Period > &  duration)
inline

<<C++11>> <<extension>> Allow implicit creation from std::chrono::duration

For example:

// ...
waitset.wait(std::chrono::seconds(1) + std::chrono::milliseconds(250));

Member Function Documentation

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

Returns a zero duration.

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

Special value that represents an infinite Duration.

static Duration dds::core::Duration::automatic ( )
static

Special value that indicates that RTI Connext will automatically assign a value.

static Duration dds::core::Duration::from_microsecs ( uint64_t  microseconds)
static

Create a Duration elapsing a specific number of microseconds.

Parameters
microsecondsThe number of microseconds to construct the object from
Returns
A newly constructed Duration object
static Duration dds::core::Duration::from_millisecs ( uint64_t  milliseconds)
static

Create a Duration elapsing a specific number of milliseconds.

Parameters
millisecondsThe number of milliseconds to construct the object from
Returns
A newly constructed Duration object
static Duration dds::core::Duration::from_secs ( double  seconds)
static

Create a Duration elapsing a specific number of seconds.

Parameters
secondsThe number of seconds to construct the object from
Returns
A newly constructed Duration object
int32_t dds::core::Duration::sec ( ) const

Get the number of seconds represented by this Duration object.

Returns
The number of seconds (excluding the nanoseconds)
void dds::core::Duration::sec ( int32_t  s)

Set the number of seconds represented by this Duration object.

Parameters
sThe number of seconds to set
uint32_t dds::core::Duration::nanosec ( ) const

Get the number of nanoseconds represented by this Duration object.

Returns
The number of nanoseconds (excluding the seconds)
void dds::core::Duration::nanosec ( uint32_t  ns)

Set the number of nanoseconds represented by this Duration object.

Parameters
nsThe number of nanoseconds to set
int dds::core::Duration::compare ( const Duration that) const

Compare two Duration objects.

Parameters
thatThe Duration object to compare with this Duration.
Returns
int The result of the comparison can be: -1 if this Duration is less than other; 0 if they are equal; 1 if this Duration is greater than other
bool dds::core::Duration::operator> ( const Duration that) const

Check if this Duration is greater than another.

Parameters
thatThe Duration to compare with this Duration.
Returns
bool false if this Duration is less than or equal to the other object, true otherwise.
bool dds::core::Duration::operator>= ( const Duration that) const

Check if this Duration is greater than or equal another.

Parameters
thatThe Duration to compare with this Duration.
Returns
bool false if this Duration is less than to the other object, true otherwise.
bool dds::core::Duration::operator== ( const Duration that) const

Check if this Duration is equal to another.

Parameters
thatThe Duration to compare with this Duration.
Returns
bool false if this Duration is not equal to the other object, true otherwise.
bool dds::core::Duration::operator!= ( const Duration other) const

Check if this Duration is not equal to another.

Parameters
otherThe Duration to compare with this Duration.
Returns
bool false if this Duration is equal to the other object, true otherwise.
bool dds::core::Duration::operator<= ( const Duration that) const

Check if this Duration is less than or equal another.

Parameters
thatThe Duration to compare with this Duration.
Returns
bool false if this Duration is greater than to the other object, true otherwise.
bool dds::core::Duration::operator< ( const Duration that) const

Check if this Duration is less than another.

Parameters
thatThe Duration to compare with this Duration.
Returns
bool false if this Duration is greater than or equal to the other object, true otherwise.
Duration& dds::core::Duration::operator+= ( const Duration a_ti)

Add a Duration to this Duration.

Parameters
a_tiThe Duration to add
Returns
Duration& This Duration, with the added Duration
Duration& dds::core::Duration::operator-= ( const Duration a_ti)

Subtract a Duration from this Duration.

Parameters
a_tiThe Duration to subtract
Returns
Duration& This Duration, after the subtraction
Duration dds::core::Duration::operator+ ( const Duration other) const

Add two Duration objects.

Parameters
otherThe other Duration to add to this one
Returns
The result of the addition
Duration dds::core::Duration::operator- ( const Duration other) const

Subtract a Duration.

Parameters
otherThe Duration to subract from this one
Returns
The result of the subtraction
uint64_t dds::core::Duration::to_millisecs ( ) const

Returns this Duration in milliseconds.

Returns
the Duration in milliseconds
uint64_t dds::core::Duration::to_microsecs ( ) const

Returns this Duration in microseconds.

Returns
the Duration in microseconds
double dds::core::Duration::to_secs ( ) const

Returns this Duration in seconds.

Returns
the Duration in seconds
std::chrono::nanoseconds dds::core::Duration::to_chrono ( ) const
inline

<<C++11>> <<extension>> Converts to std::chrono::nanoseconds

Returns
The Duration in nanoseconds.

Friends And Related Function Documentation

Duration operator* ( uint32_t  lhs,
const Duration rhs 
)
related

Multiply a Duration object by an unsigned integer.

Parameters
lhsThe unsigned integer to multiply the Duration object by
rhsThe Duration object to multiply
Returns
Duration The result of the multiplication
Duration operator* ( const Duration lhs,
uint32_t  rhs 
)
related

Multiply a Duration object by an unsigned integer.

Parameters
lhsThe Duration object to multiply
rhsThe unsigned integer to multiply the Duration object by
Returns
Duration The result of the multiplication
Duration operator/ ( const Duration lhs,
uint32_t  rhs 
)
related

Divide a Duration object by an unsigned integer.

Parameters
lhsThe dividend
rhsThe divisor
Returns
Duration The result of dividing the two Duration objects
void swap ( Duration lhs,
Duration rhs 
)
related

Swap the contents of two Duration objects.

Parameters
lhsOne of the Duration objects
rhsOne of the Duration objects
Examples:
Foo.hpp.

RTI Connext Modern C++ API Version 6.0.1 Copyright © Sat Nov 23 2019 Real-Time Innovations, Inc