C++ TargetRTS
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Public Attributes | Static Public Attributes | List of all members
RTTimespec Struct Reference

A time value which can represent either an absolute or relative time. More...

#include <RTTimespec.h>

Public Member Functions

 RTTimespec (void)
 Construct a zero time value.
 
 RTTimespec (long s, long ns)
 Construct a new time value.
 
 RTTimespec (const RTInterval &)
 
 RTTimespec (const RTTime &)
 
 RTTimespec (const RTTimespec &)
 
void normalize (void)
 Normalize the time value so that as many seconds as possible are stored in the tv_sec field and remaining nanoseconds in the tv_nsec field.
 
RTTimespecoperator= (const RTTimespec &)
 
RTTimespecoperator+= (const RTTimespec &)
 
RTTimespecoperator-= (const RTTimespec &)
 
long ticksFromNow (long nanoseconds_per_tick) const
 Get the number of "ticks" which is between this time value and the current time.
 

Static Public Member Functions

static void getclock (RTTimespec &tspec)
 Get the current time.
 

Public Attributes

long tv_sec
 Seconds.
 
long tv_nsec
 Nanoseconds.
 

Static Public Attributes

static const RTTimespec zero
 Static constant for a zero time value.
 
static const RTObject_class classData
 Type descriptor for an RTTimespec.
 

Detailed Description

A time value which can represent either an absolute or relative time.

For an absolute time the representation uses Unix time, i.e. the number of seconds and nanoseconds that have passed since 1 January 1970.

Constructor & Destructor Documentation

◆ RTTimespec()

RTTimespec::RTTimespec ( long  s,
long  ns 
)

Construct a new time value.

Parameters
[in]sNumber of seconds
[in]nsNumber of nanoseconds

Member Function Documentation

◆ getclock()

static void RTTimespec::getclock ( RTTimespec tspec)
static

Get the current time.

Parameters
[out]tspecRTTimespec object to write the current time to.

◆ normalize()

void RTTimespec::normalize ( void  )

Normalize the time value so that as many seconds as possible are stored in the tv_sec field and remaining nanoseconds in the tv_nsec field.

After calling this function it's guaranteed that tv_nsec < 1000000000.

◆ ticksFromNow()

long RTTimespec::ticksFromNow ( long  nanoseconds_per_tick) const

Get the number of "ticks" which is between this time value and the current time.

Parameters
[in]nanoseconds_per_tickDefines the length of a "tick" in nanoseconds
Returns
The number of "ticks" until this time value is reached. 0 if this time value is before the current time.

The documentation for this struct was generated from the following files: