Representation of time durations. More...
#include <time.h>
Public Member Functions | |
| Duration () | |
| Default constructor. More... | |
| Duration (int t) | |
| Construct duration from integer (seconds) More... | |
| Duration (double t) | |
| Construct duration from double (seconds) More... | |
| template<typename ChronoDuration > | |
| Duration (const ChronoDuration &duration) | |
| Construct duration from std::chrono::duration object. More... | |
| template<typename ChronoDuration > | |
| void | fromChrono (const ChronoDuration &duration) |
| Set duration from std::chrono::duration object (see Duration(const ChronoDuration& duration)) More... | |
| void | fromSec (double t) |
| Set duration from seconds (see Duration(double t)) More... | |
| bool | operator!= (const Duration &rhs) const |
| Duration | operator* (double scale) const |
| Duration & | operator*= (double scale) |
| Duration | operator+ (const Duration &rhs) const |
| Duration & | operator+= (const Duration &rhs) |
| Duration | operator- (const Duration &rhs) const |
| Duration | operator- () const |
| Duration & | operator-= (const Duration &rhs) |
| bool | operator< (const Duration &rhs) const |
| bool | operator<= (const Duration &rhs) const |
| bool | operator== (const Duration &rhs) const |
| bool | operator> (const Duration &rhs) const |
| bool | operator>= (const Duration &rhs) const |
| void | sleep () |
| Sleep (current thread) for the specified duration. More... | |
| template<typename DurType = std::chrono::duration<double>> | |
| DurType | toChrono () |
| Convert duration to std::chrono::duration object. More... | |
| double | toSec () const |
| Return duration in seconds. More... | |
| Time | toTime (double basis_time=0) |
Private Types | |
| using | DurationType = std::chrono::nanoseconds |
Private Attributes | |
| DurationType | _duration |
Friends | |
| std::ostream & | operator<< (std::ostream &os, const Duration &rhs) |
| class | Time |
Representation of time durations.
This object stores time durations and provides convenient methods and operator overloads for common operations with time and durations.
A duration object can be constructed from a value given in seconds or in a generic way from a std::chrono<> type.
In comparison to durations, actual time stamps are managed with the Time class.
The following arithmetic operators (in combination with Time objects) are provided:
Duration + Duration = Duration Duration - Duration = Duration Duration * double = Duration Duration == Duration = bool Duration > Duration == bool Duration < Duration == bool
This class is inspired and based on the ROS class ros::Duration http://wiki.ros.org/roscpp/Overview/Time
|
private |
|
inlineexplicit |
|
inlineexplicit |
|
inlineexplicit |
Construct duration from std::chrono::duration object.
E.g.:
| [in] | duration | object of template type ChronoDuration |
| ChronoDuration | Template for a specific std::chrono::duration<> type |
|
inline |
Set duration from std::chrono::duration object (see Duration(const ChronoDuration& duration))
|
inline |
Set duration from seconds (see Duration(double t))
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
Convert duration to std::chrono::duration object.
The exact chrono type might be specified as template argument, e.g.:
|
inline |
|
friend |
|
private |