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)
 
Duration operator- (const Time &rhs) const
 
Time operator- (const Duration &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...
 
 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)
 

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 251 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 324 of file time.h.

◆ TimePoint

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

Datatype for the timepoint.

Definition at line 326 of file time.h.

Constructor & Destructor Documentation

◆ Time() [1/4]

corbo::Time::Time ( )
inline

Default constructor.

Definition at line 255 of file time.h.

◆ Time() [2/4]

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

Construct time object from integer (seconds)

Definition at line 258 of file time.h.

◆ Time() [3/4]

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

Construct time object from double (seconds)

Definition at line 260 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 269 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 287 of file time.h.

◆ fromSec()

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

Set time stamp from seconds.

Definition at line 283 of file time.h.

◆ now()

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

Retrieve current system time.

Definition at line 275 of file time.h.

◆ operator!=()

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

Definition at line 309 of file time.h.

◆ operator+()

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

Definition at line 296 of file time.h.

◆ operator+=()

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

Definition at line 298 of file time.h.

◆ operator-() [1/2]

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

Definition at line 295 of file time.h.

◆ operator-() [2/2]

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

Definition at line 297 of file time.h.

◆ operator-=()

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

Definition at line 303 of file time.h.

◆ operator<()

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

Definition at line 311 of file time.h.

◆ operator<=()

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

Definition at line 313 of file time.h.

◆ operator==()

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

Definition at line 308 of file time.h.

◆ operator>()

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

Definition at line 310 of file time.h.

◆ operator>=()

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

Definition at line 312 of file time.h.

◆ sleepUntil()

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

Sleep (current thread) until the specified timestamp.

Definition at line 278 of file time.h.

◆ toSec()

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

Cast time stamp to seconds.

Definition at line 281 of file time.h.

Friends And Related Function Documentation

◆ operator<<

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

Definition at line 315 of file time.h.

Member Data Documentation

◆ _timepoint

TimePoint corbo::Time::_timepoint
private

Definition at line 328 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 Mon Feb 28 2022 22:08:03