Namespaces | |
osvr::util::time | |
Functionality related to time and the OSVR_TimeValue abstraction.Note that this is for C API-bordering areas. For purely C++ code, please use std::chrono for your time needs. | |
Classes | |
struct | OSVR_TimeValue |
Standardized, portable parallel to struct timeval for representing both absolute times and time intervals. More... | |
Typedefs | |
typedef int64_t | OSVR_TimeValue_Seconds |
The signed integer type storing the seconds in a struct OSVR_TimeValue. | |
typedef int32_t | OSVR_TimeValue_Microseconds |
The signed integer type storing the microseconds in a struct OSVR_TimeValue. | |
typedef struct OSVR_TimeValue | OSVR_TimeValue |
Standardized, portable parallel to struct timeval for representing both absolute times and time intervals. More... | |
Functions | |
void | osvrTimeValueGetNow (OSVR_TimeValue *dest) |
Gets the current time in the TimeValue. Parallel to gettimeofday. | |
void | osvrTimeValueToStructTimeval (struct timeval *dest, const OSVR_TimeValue *src) |
Converts from a TimeValue struct to your system's struct timeval. More... | |
void | osvrStructTimevalToTimeValue (OSVR_TimeValue *dest, const struct timeval *src) |
Converts from a TimeValue struct to your system's struct timeval. More... | |
void | osvrTimeValueNormalize (OSVR_TimeValue *tv) |
"Normalizes" a time value so that the absolute number of microseconds is less than 1,000,000, and that the sign of both components is the same. More... | |
void | osvrTimeValueSum (OSVR_TimeValue *tvA, const OSVR_TimeValue *tvB) |
Sums two time values, replacing the first with the result. More... | |
void | osvrTimeValueDifference (OSVR_TimeValue *tvA, const OSVR_TimeValue *tvB) |
Computes the difference between two time values, replacing the first with the result. More... | |
int | osvrTimeValueCmp (const OSVR_TimeValue *tvA, const OSVR_TimeValue *tvB) |
Compares two time values (assumed to be normalized), returning the same values as strcmp. More... | |
OSVR_EXTERN_C_END double | osvrTimeValueDurationSeconds (const OSVR_TimeValue *tvA, const OSVR_TimeValue *tvB) |
Compute the difference between the two time values, returning the duration as a double-precision floating-point number of seconds. More... | |
OSVR_CBool | osvrTimeValueGreater (const OSVR_TimeValue *tvA, const OSVR_TimeValue *tvB) |
True if A is later than B. | |
bool | osvrTimeValueIsNormalized (const OSVR_TimeValue &tv) |
Returns true if the time value is normalized. Typically used in assertions. | |
bool | osvrTimeValueGreater (const OSVR_TimeValue &tvA, const OSVR_TimeValue &tvB) |
True if A is later than B. | |
bool | operator> (const OSVR_TimeValue &tvA, const OSVR_TimeValue &tvB) |
Operator > overload for time values. | |
bool | operator< (const OSVR_TimeValue &tvA, const OSVR_TimeValue &tvB) |
Operator < overload for time values. | |
bool | operator== (const OSVR_TimeValue &tvA, const OSVR_TimeValue &tvB) |
Operator == overload for time values. | |
bool | operator!= (const OSVR_TimeValue &tvA, const OSVR_TimeValue &tvB) |
Operator == overload for time values. | |
This provides a level of interoperability with struct timeval on systems with that facility. It provides a neutral representation with sufficiently large types.
For C++ code, use of std::chrono or boost::chrono instead is recommended.
Note that these time values may not necessarily correlate between processes so should not be used to estimate or measure latency, etc.
typedef struct OSVR_TimeValue OSVR_TimeValue |
#include <osvr/Util/TimeValueC.h>
Standardized, portable parallel to struct timeval for representing both absolute times and time intervals.
Where interpreted as an absolute time, its meaning is to be considered the same as that of the POSIX struct timeval: time since 00:00 Coordinated Universal Time (UTC), January 1, 1970.
For best results, please keep normalized. Output of all functions here is normalized.
void osvrTimeValueToStructTimeval | ( | struct timeval * | dest, |
const OSVR_TimeValue * | src | ||
) |
#include <osvr/Util/TimeValueC.h>
Converts from a TimeValue struct to your system's struct timeval.
dest | Pointer to an empty struct timeval for your platform. |
src | A pointer to an OSVR_TimeValue you'd like to convert from. |
If either parameter is NULL, the function will return without doing anything.
void osvrStructTimevalToTimeValue | ( | OSVR_TimeValue * | dest, |
const struct timeval * | src | ||
) |
#include <osvr/Util/TimeValueC.h>
Converts from a TimeValue struct to your system's struct timeval.
dest | An OSVR_TimeValue destination pointer. |
src | Pointer to a struct timeval you'd like to convert from. |
The result is normalized.
If either parameter is NULL, the function will return without doing anything.
void osvrTimeValueNormalize | ( | OSVR_TimeValue * | tv | ) |
#include <osvr/Util/TimeValueC.h>
"Normalizes" a time value so that the absolute number of microseconds is less than 1,000,000, and that the sign of both components is the same.
tv | Address of a struct TimeValue to normalize in place. |
If the given pointer is NULL, this function returns without doing anything.
void osvrTimeValueSum | ( | OSVR_TimeValue * | tvA, |
const OSVR_TimeValue * | tvB | ||
) |
#include <osvr/Util/TimeValueC.h>
Sums two time values, replacing the first with the result.
tvA | Destination and first source. |
tvB | second source |
If a given pointer is NULL, this function returns without doing anything.
Both parameters are expected to be in normalized form.
void osvrTimeValueDifference | ( | OSVR_TimeValue * | tvA, |
const OSVR_TimeValue * | tvB | ||
) |
#include <osvr/Util/TimeValueC.h>
Computes the difference between two time values, replacing the first with the result.
Effectively, *tvA = *tvA - *tvB
tvA | Destination and first source. |
tvB | second source |
If a given pointer is NULL, this function returns without doing anything.
Both parameters are expected to be in normalized form.
int osvrTimeValueCmp | ( | const OSVR_TimeValue * | tvA, |
const OSVR_TimeValue * | tvB | ||
) |
#include <osvr/Util/TimeValueC.h>
Compares two time values (assumed to be normalized), returning the same values as strcmp.
OSVR_EXTERN_C_END double osvrTimeValueDurationSeconds | ( | const OSVR_TimeValue * | tvA, |
const OSVR_TimeValue * | tvB | ||
) |
#include <osvr/Util/TimeValueC.h>
Compute the difference between the two time values, returning the duration as a double-precision floating-point number of seconds.
Effectively, ret = *tvA - *tvB
tvA | first source. |
tvB | second source |
Definition at line 185 of file TimeValueC.h.