Autoware.Auto
autoware::prediction::Time< kTimeReferenceFrame > Class Template Reference

This class describes a time point with respect to some time reference frame. More...

#include <time.hpp>

Inheritance diagram for autoware::prediction::Time< kTimeReferenceFrame >:
Collaboration diagram for autoware::prediction::Time< kTimeReferenceFrame >:

Public Member Functions

 Time ()=default
 Default contructor. More...
 
 Time (const Base &time_point)
 Constructs a new instance from a time_point. More...
 
common::types::bool8_t is_valid () const noexcept
 Determines if the stored time_point is valid. More...
 

Friends

Time operator+ (Time time_1, const Time &time_2)
 Add an operator + for two time points. More...
 
template<typename IntT , typename DurationT >
Time operator+ (const Time &time, const std::chrono::duration< IntT, DurationT > &duration)
 Overload operator +. More...
 
template<typename IntT , typename DurationT >
Time operator- (const Time &time, const std::chrono::duration< IntT, DurationT > &duration)
 Overload operator -. More...
 

Detailed Description

template<TimeReferenceFrame kTimeReferenceFrame>
class autoware::prediction::Time< kTimeReferenceFrame >

This class describes a time point with respect to some time reference frame.

Template Parameters
kTimeReferenceFrameA reference frame for the stored time_point.

Constructor & Destructor Documentation

◆ Time() [1/2]

template<TimeReferenceFrame kTimeReferenceFrame>
autoware::prediction::Time< kTimeReferenceFrame >::Time ( )
default

Default contructor.

◆ Time() [2/2]

template<TimeReferenceFrame kTimeReferenceFrame>
autoware::prediction::Time< kTimeReferenceFrame >::Time ( const Base &  time_point)
inlineexplicit

Constructs a new instance from a time_point.

Parameters
[in]time_pointA time point.

Member Function Documentation

◆ is_valid()

template<TimeReferenceFrame kTimeReferenceFrame>
common::types::bool8_t autoware::prediction::Time< kTimeReferenceFrame >::is_valid ( ) const
inlinenoexcept

Determines if the stored time_point is valid.

Returns
True if valid, False otherwise.

Friends And Related Function Documentation

◆ operator+ [1/2]

template<TimeReferenceFrame kTimeReferenceFrame>
template<typename IntT , typename DurationT >
Time operator+ ( const Time< kTimeReferenceFrame > &  time,
const std::chrono::duration< IntT, DurationT > &  duration 
)
friend

Overload operator +.

        We cannot use the operator for the base class as we want to still return Time, not
        an ordinary std::chrono::time_point.
Parameters
[in]timeThe base time point.
[in]durationThe duration to add to the time point.
Template Parameters
IntTHelp integer type to pass into the duration template.
DurationTType of ratio used as a duration.
Returns
A new time point which represents the input time with duration added to it.
Note
This must be templated as otherwise the compiler gets confused as to which overload to pick in case the duration is not std::chrono::nanoseconds. If it does not match then the duration parameter matches better with an overload from std::chrono, while the first argument matches this class better. The compiler cannot pick the best one and throws a warning. Thus we template this function to make this choice ideal when used with Time class.

◆ operator+ [2/2]

template<TimeReferenceFrame kTimeReferenceFrame>
Time operator+ ( Time< kTimeReferenceFrame >  time_1,
const Time< kTimeReferenceFrame > &  time_2 
)
friend

Add an operator + for two time points.

Returns
A new time point which is a sum of input ones.

◆ operator-

template<TimeReferenceFrame kTimeReferenceFrame>
template<typename IntT , typename DurationT >
Time operator- ( const Time< kTimeReferenceFrame > &  time,
const std::chrono::duration< IntT, DurationT > &  duration 
)
friend

Overload operator -.

        We cannot use the operator for the base class as we want to still return Time, not
        an ordinary std::chrono::time_point.
Parameters
[in]timeThe base time point.
[in]durationThe duration to subtract from the time point.
Template Parameters
IntTHelp integer type to pass into the duration template.
DurationTType of ratio used as a duration.
Returns
A new time point which represents the input time with duration subtracted from it.
Note
This must be templated as otherwise the compiler gets confused as to which overload to pick in case the duration is not std::chrono::nanoseconds. If it does not match then the duration parameter matches better with an overload from std::chrono, while the first argument matches this class better. The compiler cannot pick the best one and throws a warning. Thus we template this function to make this choice ideal when used with Time class.

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