Representation of time stamps. More...
#include <time.h>
Public Member Functions | |
| template<typename ChronoTimePoint > | |
| void | fromChrono (const ChronoTimePoint &timepoint) |
| Set time stamp from std::chrono::time_stamp type. More... | |
| void | fromSec (double t) |
| Set time stamp from seconds. More... | |
| bool | operator!= (const Time &rhs) const |
| Time | operator+ (const Duration &rhs) const |
| Time & | operator+= (const Duration &rhs) |
| Duration | operator- (const Time &rhs) const |
| Time | operator- (const Duration &rhs) const |
| Time & | operator-= (const Duration &rhs) |
| bool | operator< (const Time &rhs) const |
| bool | operator<= (const Time &rhs) const |
| bool | operator== (const Time &rhs) const |
| bool | operator> (const Time &rhs) const |
| bool | operator>= (const Time &rhs) const |
| Time () | |
| Default constructor. More... | |
| Time (int t) | |
| Construct time object from integer (seconds) More... | |
| Time (double t) | |
| Construct time object from double (seconds) More... | |
| template<typename ChronoTimePoint > | |
| Time (const ChronoTimePoint &timepoint) | |
| Construct time from std::chrono::time_point object. More... | |
| double | toSec () const |
| Cast time stamp to seconds. More... | |
Static Public Member Functions | |
| static Time | now () |
| Retrieve current system time. More... | |
| static void | sleepUntil (const Time &time) |
| Sleep (current thread) until the specified timestamp. More... | |
Private Types | |
| using | Clock = std::chrono::high_resolution_clock |
| Datatype for the clock. More... | |
| using | TimePoint = Clock::time_point |
| Datatype for the timepoint. More... | |
Private Attributes | |
| TimePoint | _timepoint |
Friends | |
| std::ostream & | operator<< (std::ostream &os, const Time &rhs) |
Representation of time stamps.
This object stores time stamps and provides convenient methods and operator overloads for common operations with time and durations.
A time object can be constructed from a value given in seconds or in a generic way from a std::chrono<>::time_point type.
In comparison to durations, actual time stamps are managed with the Time class. The internal high-resolution (system) clock is used for precise time measurement.
The following arithmetic operators (in combination with Time objects) are provided:
Time - Time = Duration Time + Duration = Time Time - Duration = Time Time == Time = bool Time > Time == bool Time < Time == bool
This class is inspired and based on the ROS class ros::Time http://wiki.ros.org/roscpp/Overview/Time
|
private |
|
private |
|
inlineexplicit |
|
inlineexplicit |
|
inlineexplicit |
|
inline |
|
inline |
|
inlinestatic |
|
inline |
|
inline |
|
inline |
|
inline |
|
inlinestatic |
|
inline |
|
friend |