![]() |
CUGL 2.3
Cornell University Game Library
|
#include <CUTimestamp.h>
Public Member Functions | |
Timestamp () | |
Timestamp (const Timestamp &stamp) | |
const Timestamp & | operator= (const Timestamp &stamp) |
const Timestamp & | set (const Timestamp &stamp) |
void | mark () |
timestamp_t | getTime () const |
Uint64 | ellapsedMillis (const Timestamp &stamp) const |
Uint64 | ellapsedMicros (const Timestamp &stamp) const |
Uint64 | ellapsedNanos (const Timestamp &stamp) |
Timestamp & | operator+= (Uint32 millis) |
Timestamp & | operator-= (Uint32 millis) |
const Timestamp | operator+ (Uint32 millis) const |
const Timestamp | operator- (Uint32 millis) const |
bool | operator< (const Timestamp &other) const |
Static Public Member Functions | |
static Uint64 | ellapsedMillis (const Timestamp &start, const Timestamp &end) |
static Uint64 | ellapsedMicros (const Timestamp &start, const Timestamp &end) |
static Uint64 | ellapsedNanos (const Timestamp &start, const Timestamp &end) |
Protected Attributes | |
timestamp_t | _time |
Class to mark a moment in time.
The advantage of using this class over timestamp_t is that it has many built-in methods for converting the timestamp to milliseconds, nanoseconds, and so on. It is a lot easier to use this class that to use the more arcane chrono package in C++.
While this is a class, this is meant to be created on the stack. Therefore there is no support for shared pointers or initialization like in our other, more heavy-weight classes.
|
inline |
Constructs a new time stamp.
The constructor marks the exact moment that it was created.
|
inline |
Constructs a copy of the given time stamp.
The constructor does not mark the time it copies, but instead uses the value taken from stamp.
stamp | The time stamp to copy |
|
inline |
Returns the ellapsed time from the provided time.
This method measures the time from stamp until the current time. Hence the current time is the end of the interval.
The value is returned in microseconds.
stamp | The start time |
|
inlinestatic |
Returns the ellapsed time between the given two timestamps.
The value is returned in microseconds.
start | The start time |
end | The finish time |
|
inline |
Returns the ellapsed time from the provided time.
This method measures the time from stamp until the current time. Hence the current time is the end of the interval.
The value is returned in milliseconds.
stamp | The start time |
|
inlinestatic |
Returns the ellapsed time between the given two timestamps.
The value is returned in milliseconds.
start | The start time |
end | The finish time |
|
inline |
Returns the ellapsed time from the provided time.
This method measures the time from stamp until the current time. Hence the current time is the end of the interval.
The value is returned in nanoseconds.
stamp | The start time |
|
inlinestatic |
Returns the ellapsed time between the given two timestamps.
The value is returned in nanoseconds.
start | The start time |
end | The finish time |
|
inline |
Returns the current time stamp in its internal format
This format is not much use by itself. It only allows you to use functions in chrono not supported by this class. For most purposes you should used one of the ellapsed methods instead.
|
inline |
Sets this time stamp to be the current moment in time.
The previous value of this time stamp will be erased.
|
inline |
Returns a copy of this time stamp incremented by the number of milliseconds
While we can support timestamps more accurate than milliseconds, SDL events only mark time increments at the millisecond level. As this is the primary reason for incrementing a time stamp by a integer value, we only support milliseconds for this operation.
millis | The number of milliseconds to increment |
|
inline |
Increments this time stamp by the given number of milliseconds
While we can support timestamps more accurate than milliseconds, SDL events only mark time increments at the millisecond level. As this is the primary reason for incrementing a time stamp by a integer value, we only support milliseconds for this operation.
millis | The number of milliseconds to increment |
|
inline |
Returns a copy of this time stamp decremented by the number of milliseconds
While we can support timestamps more accurate than milliseconds, SDL events only mark time increments at the millisecond level. As this is the primary reason for incrementing a time stamp by a integer value, we only support milliseconds for this operation.
millis | The number of milliseconds to decrement |
|
inline |
Decrements this time stamp by the given number of milliseconds
While we can support timestamps more accurate than milliseconds, SDL events only mark time increments at the millisecond level. As this is the primary reason for incrementing a time stamp by a integer value, we only support milliseconds for this operation.
millis | The number of milliseconds to decrement |
|
inline |
Returns whether this timestamp is less than another timestamp.
other | The timestamp to compare |
Sets this time stamp to be a copy of stamp.
This operator does not mark the time it copies, but instead uses the value taken from stamp.
stamp | The time stamp to copy |
Sets this time stamp to be a copy of stamp.
This operator does not mark the time it copies, but instead uses the value taken from stamp.
stamp | The time stamp to copy |
|
protected |
The current timestamp using the steady clock from chrono.