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

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

Static Public Member Functions

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

Related Functions

(Note that these are not member functions.)

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

Detailed Description

<<extension>> Represents a point in time

Constructor & Destructor Documentation

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

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

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.

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

Copy-construct a Time object from another Time object.

Member Function Documentation

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.
static Time dds::core::Time::zero ( )
static

Get a Time object representing zero time.

Returns
const Time A Time object representing zero time.
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.
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
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
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
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
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.
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
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.
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
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.
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.
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.
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.
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.
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.
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
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
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.
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.
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

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
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
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
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();

RTI Connext Modern C++ API Version 5.3.0 Copyright © Sun Jun 25 2017 Real-Time Innovations, Inc