Public Member Functions | Static Public Member Functions | Private Types | Private Attributes | Friends | List of all members
corbo::Time Class Reference

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
 
Timeoperator+= (const Duration &rhs)
 
Time operator- (const Duration &rhs) const
 
Duration operator- (const Time &rhs) const
 
Timeoperator-= (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...
 
template<typename ChronoTimePoint >
 Time (const ChronoTimePoint &timepoint)
 Construct time from std::chrono::time_point object. More...
 
 Time (double t)
 Construct time object from double (seconds) More...
 
 Time (int t)
 Construct time object from integer (seconds) 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)
 

Detailed Description

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

See also
Duration Rate
Author
Christoph Rösmann (chris.nosp@m.toph.nosp@m..roes.nosp@m.mann.nosp@m.@tu-d.nosp@m.ortm.nosp@m.und.d.nosp@m.e)

Definition at line 273 of file time.h.

Member Typedef Documentation

◆ Clock

using corbo::Time::Clock = std::chrono::high_resolution_clock
private

Datatype for the clock.

Definition at line 346 of file time.h.

◆ TimePoint

using corbo::Time::TimePoint = Clock::time_point
private

Datatype for the timepoint.

Definition at line 348 of file time.h.

Constructor & Destructor Documentation

◆ Time() [1/4]

corbo::Time::Time ( )
inline

Default constructor.

Definition at line 277 of file time.h.

◆ Time() [2/4]

corbo::Time::Time ( int  t)
inlineexplicit

Construct time object from integer (seconds)

Definition at line 280 of file time.h.

◆ Time() [3/4]

corbo::Time::Time ( double  t)
inlineexplicit

Construct time object from double (seconds)

Definition at line 282 of file time.h.

◆ Time() [4/4]

template<typename ChronoTimePoint >
corbo::Time::Time ( const ChronoTimePoint &  timepoint)
inlineexplicit

Construct time from std::chrono::time_point object.

Parameters
[in]timepointobject of template type ChronoTimePoint
Template Parameters
ChronoTimePointTemplate for a specific std::chrono::time_point<> type

Definition at line 291 of file time.h.

Member Function Documentation

◆ fromChrono()

template<typename ChronoTimePoint >
void corbo::Time::fromChrono ( const ChronoTimePoint &  timepoint)
inline

Set time stamp from std::chrono::time_stamp type.

Definition at line 309 of file time.h.

◆ fromSec()

void corbo::Time::fromSec ( double  t)
inline

Set time stamp from seconds.

Definition at line 305 of file time.h.

◆ now()

static Time corbo::Time::now ( )
inlinestatic

Retrieve current system time.

Definition at line 297 of file time.h.

◆ operator!=()

bool corbo::Time::operator!= ( const Time rhs) const
inline

Definition at line 331 of file time.h.

◆ operator+()

Time corbo::Time::operator+ ( const Duration rhs) const
inline

Definition at line 318 of file time.h.

◆ operator+=()

Time& corbo::Time::operator+= ( const Duration rhs)
inline

Definition at line 320 of file time.h.

◆ operator-() [1/2]

Time corbo::Time::operator- ( const Duration rhs) const
inline

Definition at line 319 of file time.h.

◆ operator-() [2/2]

Duration corbo::Time::operator- ( const Time rhs) const
inline

Definition at line 317 of file time.h.

◆ operator-=()

Time& corbo::Time::operator-= ( const Duration rhs)
inline

Definition at line 325 of file time.h.

◆ operator<()

bool corbo::Time::operator< ( const Time rhs) const
inline

Definition at line 333 of file time.h.

◆ operator<=()

bool corbo::Time::operator<= ( const Time rhs) const
inline

Definition at line 335 of file time.h.

◆ operator==()

bool corbo::Time::operator== ( const Time rhs) const
inline

Definition at line 330 of file time.h.

◆ operator>()

bool corbo::Time::operator> ( const Time rhs) const
inline

Definition at line 332 of file time.h.

◆ operator>=()

bool corbo::Time::operator>= ( const Time rhs) const
inline

Definition at line 334 of file time.h.

◆ sleepUntil()

static void corbo::Time::sleepUntil ( const Time time)
inlinestatic

Sleep (current thread) until the specified timestamp.

Definition at line 300 of file time.h.

◆ toSec()

double corbo::Time::toSec ( ) const
inline

Cast time stamp to seconds.

Definition at line 303 of file time.h.

Friends And Related Function Documentation

◆ operator<<

std::ostream& operator<< ( std::ostream &  os,
const Time rhs 
)
friend

Definition at line 337 of file time.h.

Member Data Documentation

◆ _timepoint

TimePoint corbo::Time::_timepoint
private

Definition at line 350 of file time.h.


The documentation for this class was generated from the following file:


control_box_rst
Author(s): Christoph Rösmann
autogenerated on Wed Mar 2 2022 00:07:21