DUDS
Distributed Update of Data from Something
duds::time::interstellar::TimePoint< Clock, Duration > Class Template Reference

An extention to the C++ std::chrono::time_point template to make time points easier to work with. More...

#include <Interstellar.hpp>

Inheritance diagram for duds::time::interstellar::TimePoint< Clock, Duration >:
Collaboration diagram for duds::time::interstellar::TimePoint< Clock, Duration >:

Public Member Functions

constexpr TimePoint ()=default
 
 TimePoint (const TimePoint &)=default
 
template<class OtherRep , class OtherPeriod >
constexpr TimePoint (const std::chrono::duration< OtherRep, OtherPeriod > &od)
 Constructs a TimePoint from a duration. More...
 
template<class OtherClock , class OtherDuration >
constexpr TimePoint (const std::chrono::time_point< OtherClock, OtherDuration > &otp)
 Constructs a TimePoint from a std::chrono::time_point. More...
 
TimePointoperator= (const TimePoint &)=default
 
template<class OtherClock , class OtherDuration >
TimePointoperator= (const TimePoint< OtherClock, OtherDuration > &otp)
 Assigns a new time from another TimePoint using different template parameters. More...
 

Static Public Member Functions

static constexpr TimePoint max ()
 Returns the latest time that can be represented. More...
 
static constexpr TimePoint min ()
 Returns the earlist time that can be represented. More...
 

Detailed Description

template<class Clock, class Duration>
class duds::time::interstellar::TimePoint< Clock, Duration >

An extention to the C++ std::chrono::time_point template to make time points easier to work with.

I found the inclusion of the clock type to be rather bothersome since the DUDS library doesn't use types to track the origin of information. This class avoids that issue, and allows easier type conversions and cross-type assignments with a lot less typing. I find it is also eaiser to write code that doesn't result in compile-time errors using this template rather than using the C++ one directly.

Warning
This template allows implicit conversions that result in a loss of precision. For example, a time in nanoseconds can be converted to seconds. This is not the case with std::chrono::time_point.
Template Parameters
ClockA clock class.
DurationA duration class.
Author
Jeff Jackowski

Definition at line 53 of file Interstellar.hpp.

Constructor & Destructor Documentation

◆ TimePoint() [1/4]

◆ TimePoint() [2/4]

template<class Clock, class Duration>
duds::time::interstellar::TimePoint< Clock, Duration >::TimePoint ( const TimePoint< Clock, Duration > &  )
default

◆ TimePoint() [3/4]

template<class Clock, class Duration>
template<class OtherRep , class OtherPeriod >
constexpr duds::time::interstellar::TimePoint< Clock, Duration >::TimePoint ( const std::chrono::duration< OtherRep, OtherPeriod > &  od)
inline

Constructs a TimePoint from a duration.

Parameters
odA duration from time-zero, epoch, whatever you want to call it.

Definition at line 62 of file Interstellar.hpp.

◆ TimePoint() [4/4]

template<class Clock, class Duration>
template<class OtherClock , class OtherDuration >
constexpr duds::time::interstellar::TimePoint< Clock, Duration >::TimePoint ( const std::chrono::time_point< OtherClock, OtherDuration > &  otp)
inline

Constructs a TimePoint from a std::chrono::time_point.

Parameters
otpThe source time point. It may use a different period and a a different clock type.

Definition at line 84 of file Interstellar.hpp.

Member Function Documentation

◆ max()

template<class Clock, class Duration>
static constexpr TimePoint duds::time::interstellar::TimePoint< Clock, Duration >::max ( )
inlinestatic

Returns the latest time that can be represented.

Definition at line 111 of file Interstellar.hpp.

Referenced by duds::time::planetary::LeapSeconds::getLeapBounds().

◆ min()

template<class Clock, class Duration>
static constexpr TimePoint duds::time::interstellar::TimePoint< Clock, Duration >::min ( )
inlinestatic

Returns the earlist time that can be represented.

Definition at line 103 of file Interstellar.hpp.

Referenced by duds::time::planetary::LeapSeconds::getLeapBounds().

◆ operator=() [1/2]

template<class Clock, class Duration>
TimePoint& duds::time::interstellar::TimePoint< Clock, Duration >::operator= ( const TimePoint< Clock, Duration > &  )
default

◆ operator=() [2/2]

template<class Clock, class Duration>
template<class OtherClock , class OtherDuration >
TimePoint& duds::time::interstellar::TimePoint< Clock, Duration >::operator= ( const TimePoint< OtherClock, OtherDuration > &  otp)
inline

Assigns a new time from another TimePoint using different template parameters.

Parameters
otpThe source TimePoint. It may use a different period and a a different clock type.

Definition at line 96 of file Interstellar.hpp.


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