RTI Connext Modern C++ API  Version 6.1.0

<<extension>> Represents a point in time More...

#include <Time.hpp>

Public Member Functions

 Time ()
 Create a default Time object. The constructed Time object will represent 0 seconds and 0 nanoseconds. More...
 
 Time (int32_t sec, uint32_t nanosec=0)
 Create a Time object. The constructed Time object will represent the given amount of time. More...
 
int32_t sec () const
 Get the number of seconds that are represented by this Time object. More...
 
void sec (int32_t s)
 Set the number of seconds that are represented by this Time object. More...
 
uint32_t nanosec () const
 Get the number of nanoseconds that are represented by this Time object. More...
 
void nanosec (uint32_t ns)
 Set the number of nanoseconds that are represented by this Time object. More...
 
int compare (const Time &other) const
 Compare two Time objects. More...
 
bool operator> (const Time &other) const
 Check if this Time is greater than another. More...
 
bool operator>= (const Time &other) const
 Check if this Time is greater than or equal another. More...
 
bool operator== (const Time &other) const
 Check if this Time of Time is equal to another. More...
 
bool operator!= (const Time &other) const
 Check if this Time is not equal to another. More...
 
bool operator<= (const Time &other) const
 Check if this Time is less than or equal another. More...
 
bool operator< (const Time &other) const
 Check if this Time is less than another. More...
 
Timeoperator+= (const Duration &duration)
 Add a Duration to this Time object. More...
 
Timeoperator-= (const Duration &duration)
 Subtract a Duration from this Time object. More...
 
uint64_t to_millisecs () const
 Convert this Time to milliseconds. More...
 
uint64_t to_microsecs () const
 Convert this Time to microseconds. More...
 
double to_secs () const
 Convert this Time to seconds. More...
 

Static Public Member Functions

static Time invalid ()
 Get a Time object representing an invalid amount of time. More...
 
static Time zero ()
 Get a Time object representing zero time. More...
 
static Time maximum ()
 Get a Time object representing the maximum amount of time. More...
 
static Time from_microsecs (uint64_t microseconds)
 Create a Time object from microseconds. More...
 
static Time from_millisecs (uint64_t milliseconds)
 Create a Time object from milliseconds. More...
 
static Time from_secs (double seconds)
 Create a Time object from seconds. More...
 

Related Functions

(Note that these are not member functions.)

Time operator+ (const Time &time, const Duration &duration)
 Add a Time and a Duration together. More...
 
Time operator+ (const Duration &duration, const Time &time)
 Add a Time and a Duration together. More...
 
Time operator- (const Time &time, const Duration &duration)
 Subtract a Duration from a Time. More...
 
Duration operator- (const Time &time1, const Time &time2)
 Calculate the duration between two times. More...
 

Detailed Description

<<extension>> Represents a point in time

Constructor & Destructor Documentation

◆ Time() [1/2]

dds::core::Time::Time ( )

Create a default Time object. The constructed Time object will represent 0 seconds and 0 nanoseconds.

◆ Time() [2/2]

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

Create a Time object. The constructed Time object will represent the given amount of time.

Member Function Documentation

◆ invalid()

static Time dds::core::Time::invalid ( )
static

Get a Time object representing an invalid amount of time.

Returns
const Time A Time object representing an invalid amount of time.

◆ zero()

static Time dds::core::Time::zero ( )
static

Get a Time object representing zero time.

Returns
const Time A Time object representing zero time.

◆ maximum()

static Time dds::core::Time::maximum ( )
static

Get a Time object representing the maximum amount of time.

Returns
const Time A Time object representing the maximum amount of time.

◆ from_microsecs()

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

Create a Time object from microseconds.

Parameters
microsecondsHow many microseconds this Time represent
Returns
Time A new instance of Time representing the given microseconds

◆ from_millisecs()

static Time dds::core::Time::from_millisecs ( uint64_t  milliseconds)
static

Create a Time object from milliseconds.

Parameters
millisecondsHow many milliseconds this Time should represent
Returns
Time A new instance of Time representing the given milliseconds

◆ from_secs()

static Time dds::core::Time::from_secs ( double  seconds)
static

Create a Time object from seconds.

Parameters
secondsHow many seconds this Time should represent
Returns
Time A new instance of Time representing the given seconds

◆ sec() [1/2]

int32_t dds::core::Time::sec ( ) const

Get the number of seconds that are represented by this Time object.

Returns
int32_t The number of seconds

◆ sec() [2/2]

void dds::core::Time::sec ( int32_t  s)

Set the number of seconds that are represented by this Time object.

Parameters
sThe number of seconds to set.

◆ nanosec() [1/2]

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

Get the number of nanoseconds that are represented by this Time object.

Returns
uint32_t The number of nanoseconds

◆ nanosec() [2/2]

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

Set the number of nanoseconds that are represented by this Time object.

Parameters
nsThe number of nanoseconds to set.

◆ compare()

int dds::core::Time::compare ( const Time other) const

Compare two Time objects.

Parameters
otherThe Time object to compare with this Time.
Returns
int The result of the comparison can be: -1 if this Time is less than other; 0 if they are equal; 1 if this Time is greater than other

◆ operator>()

bool dds::core::Time::operator> ( const Time other) const

Check if this Time is greater than another.

Parameters
otherThe Time object to compare with this Time.
Returns
bool false if this Time is less than or equal to the other object, true otherwise.

◆ operator>=()

bool dds::core::Time::operator>= ( const Time other) const

Check if this Time is greater than or equal another.

Parameters
otherThe Time object to compare with this Time.
Returns
bool false if this Time is less than to the other object, true otherwise.

◆ operator==()

bool dds::core::Time::operator== ( const Time other) const

Check if this Time of Time is equal to another.

Parameters
otherThe Time object to compare with this Time.
Returns
bool false if this Time is not equal to the other object, true otherwise.

◆ operator!=()

bool dds::core::Time::operator!= ( const Time other) const

Check if this Time is not equal to another.

Parameters
otherThe Time object to compare with this Time.
Returns
bool false if this Time is equal to the other object, true otherwise.

◆ operator<=()

bool dds::core::Time::operator<= ( const Time other) const

Check if this Time is less than or equal another.

Parameters
otherThe Time object to compare with this Time.
Returns
bool false if this Time is greater than to the other object, true otherwise.

◆ operator<()

bool dds::core::Time::operator< ( const Time other) const

Check if this Time is less than another.

Parameters
otherThe Time object to compare with this Time.
Returns
bool false if this Time is greater than or equal to the other object, true otherwise.

◆ operator+=()

Time& dds::core::Time::operator+= ( const Duration duration)

Add a Duration to this Time object.

Parameters
durationThe Duration to add
Returns
Time& This Time, with the added Duration

◆ operator-=()

Time& dds::core::Time::operator-= ( const Duration duration)

Subtract a Duration from this Time object.

Parameters
durationThe Duration to subtract
Returns
Time& This Time, with the subtracted Duration

◆ to_millisecs()

uint64_t dds::core::Time::to_millisecs ( ) const

Convert this Time to milliseconds.

Returns
uint64_t The number of milliseconds represented by this Time object.

◆ to_microsecs()

uint64_t dds::core::Time::to_microsecs ( ) const

Convert this Time to microseconds.

Returns
uint64_t The number of microseconds represented by this Time object.

◆ to_secs()

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

Convert this Time to seconds.

Returns
double The number of seconds represented by this Time object.

Friends And Related Function Documentation

◆ operator+() [1/2]

Time operator+ ( const Time time,
const Duration duration 
)
related

Add a Time and a Duration together.

Parameters
timeThe Time object to add
durationThe Duration object to add
Returns
Time The result of the addition represented as a Time object

◆ operator+() [2/2]

Time operator+ ( const Duration duration,
const Time time 
)
related

Add a Time and a Duration together.

Parameters
durationThe Duration object to add
timeThe Time object to add
Returns
Time The result of the addition represented as a Time object

◆ operator-() [1/2]

Time operator- ( const Time time,
const Duration duration 
)
related

Subtract a Duration from a Time.

Parameters
timeThe Time object to subtract from
durationThe Duration object to subtract
Returns
Time The result of the subtraction represented as a Time object

◆ operator-() [2/2]

Duration operator- ( const Time time1,
const Time time2 
)
related

Calculate the duration between two times.

Parameters
time1The first ("before") time
time2The second ("after") time
Returns
The duration elapsed between time1 and time2. If time1 > time2 the duration is zero. If time1 is Time::maximum(), the duration is Duration::infinite();