class::chrono::ClockTime

class chrono::ClockTime
  : public api::InfoObject

The ClockTime class is a helper class for using struct timespec times. This is a 64-bit time with a 32-bit seconds element and a 32-bit nanoseconds element.

Summary

[ClockTime](#classchrono_1_1_clock_time_1a6adc340cf56ed784f2efc62f9c6b71f3)(  

const Seconds & seconds,
const Nanoseconds & nanoseconds
)

[ClockTime](#classchrono_1_1_clock_time_1aea99cd12b5902b78023b01f42332629e)(  

const struct timespec & nano_time
)

ClockTime(

const MicroTime & micro_time
)

[ClockTime](#classchrono_1_1_clock_time_1a51a9adda995138258191a9dadd615c78)()

ClockTime age() const

bool is_valid() const

s32 nanoseconds() const

bool operator !=(

const ClockTime & a
) const

ClockTime operator -(

const ClockTime & a
) const

ClockTime & operator -=(

const ClockTime & a
)

bool operator >(

const ClockTime & a
) const

bool operator >=(

const ClockTime & a
) const

[operator const struct timespec *](#classchrono_1_1_clock_time_1acfcf465ec8ef2096bb63ddeca4a21b70)() *const*

[operator struct timespec *](#classchrono_1_1_clock_time_1a520da0fa2521a738de465d42e66af736)()

ClockTime operator+(

const ClockTime & a
) const

ClockTime & operator+=(

const ClockTime & a
)

bool operator<(

const ClockTime & a
) const

ClockTime & operator<<(

const Seconds & seconds
)

ClockTime & operator<<(

const Nanoseconds & nanoseconds
)

bool operator<=(

const ClockTime & a
) const

bool operator==(

const ClockTime & a
) const

void reset()

s32 seconds() const

void set(

const Seconds & seconds,
const Nanoseconds & nanoseconds
)

struct timespec * timespec()

const struct timespec * timespec() const

static ClockTime from_seconds(

u32 seconds
)

static ClockTime invalid()

Members

ClockTime(

const Seconds & seconds,
const Nanoseconds & nanoseconds
)

Constructs a ClockTime object from seconds and nanoseconds.


ClockTime(

const struct timespec & nano_time
)

Constructs a clock time object based on the timespec.


ClockTime(

const MicroTime & micro_time
)

Contructs an object from a micro time object.


ClockTime()

Constructs a zero value ClockTime object.


ClockTime age() const

Returns the age of this object as a ClockTime value.

This will read the current time using Clock::get_time() and returns the difference between the present time and the time held by this object.

#include <sapi/chrono.hpp>

ClockTime instant = Clock::get_time();
ClockTime::wait_seconds(5);
printf("Age is %d\n", instant.age().seconds());

bool is_valid() const

Returns true if the time is set to a valid value.


s32 nanoseconds() const

Returns the nanoseconds component.


bool operator !=(

const ClockTime & a
) const

Returns true if this is not equal to a.


ClockTime operator -(

const ClockTime & a
) const

Returns the difference of this object and a.


ClockTime & operator -=(

const ClockTime & a
)

Subracts from this and assigned to this.


bool operator >(

const ClockTime & a
) const

Returns true if this is greater than a.


bool operator >=(

const ClockTime & a
) const

Returns true if this is greater than or equal to a.


operator const struct timespec *() const

Returns a pointer to the struct timespec.

This allows the object to be passed directly to functions that required a pointer to struct timespec (read-only)


operator struct timespec *()

Returns a pointer to the struct timespec.

This allows the object to be passed directly to functions that required a pointer to struct timespec (read-write)


ClockTime operator+(

const ClockTime & a
) const

Returns the sum of this object and a.


ClockTime & operator+=(

const ClockTime & a
)

Adds to this and assigned to this.


bool operator<(

const ClockTime & a
) const

Returns true if this is less than a.


ClockTime & operator<<(

const Seconds & seconds
)


ClockTime & operator<<(

const Nanoseconds & nanoseconds
)


bool operator<=(

const ClockTime & a
) const

Returns true if this is less than or equal to a.


bool operator==(

const ClockTime & a
) const

Returns true if this is equal to a.


void reset()

Resets the value of the clock to zero.


s32 seconds() const

Returns the seconds component.


void set(

const Seconds & seconds,
const Nanoseconds & nanoseconds
)

Sets the value of the clock time.


struct timespec * timespec()

Returns a pointer to a strut timespec.


const struct timespec * timespec() const

Returns a pointer to a strut timespec (read-only).


static ClockTime from_seconds(

u32 seconds
)


static ClockTime invalid()

Returns a MicroTime object set to the invalid time.


X

Thanks for Coming!

Subscribe to news and updates