OpenDDS  Snapshot(2023/04/07-19:43)
Public Types | Public Member Functions | Static Public Member Functions | Static Public Attributes | Protected Attributes | Static Protected Attributes | List of all members
OpenDDS::DCPS::TimePoint_T< AceClock > Class Template Reference

#include <TimePoint_T.h>

Inheritance diagram for OpenDDS::DCPS::TimePoint_T< AceClock >:
Inheritance graph
[legend]
Collaboration diagram for OpenDDS::DCPS::TimePoint_T< AceClock >:
Collaboration graph
[legend]

Public Types

typedef AceClock ClockType
 
typedef ACE_Time_Value_T< AceClock > ValueType
 
- Public Types inherited from OpenDDS::DCPS::SafeBoolBase
typedef void(SafeBoolBase::* BoolType) () const
 

Public Member Functions

 TimePoint_T ()
 
bool is_zero () const
 
bool boolean_test () const
 
bool is_max () const
 
void set_to_now ()
 
DDS::Time_t to_dds_time () const
 
MonotonicTime_t to_monotonic_time () const
 
TimePoint_T< AceClock > & operator+= (const TimeDuration &td)
 
TimePoint_T< AceClock > & operator-= (const TimeDuration &td)
 
 TimePoint_T (const ACE_Time_Value &ace_time_value)
 
 TimePoint_T (const ACE_Time_Value_T< AceClock > &ace_time_value)
 
 TimePoint_T (const DDS::Time_t &dds_time)
 
const ACE_Time_Value_T< AceClock > & value () const
 
void value (const ACE_Time_Value_T< AceClock > &ace_time_value)
 
- Public Member Functions inherited from OpenDDS::DCPS::SafeBool_T< TimePoint_T< AceClock > >
 operator BoolType () const
 
- Public Member Functions inherited from OpenDDS::DCPS::SafeBoolBase
void this_type_does_not_support_comparisons () const
 

Static Public Member Functions

static TimePoint_T< AceClock > now ()
 

Static Public Attributes

static const TimePoint_T< AceClock > zero_value
 
static const TimePoint_T< AceClock > max_value
 

Protected Attributes

ValueType value_
 

Static Protected Attributes

static ClockType clock
 

Additional Inherited Members

- Protected Member Functions inherited from OpenDDS::DCPS::SafeBool_T< TimePoint_T< AceClock > >
 ~SafeBool_T ()
 
- Protected Member Functions inherited from OpenDDS::DCPS::SafeBoolBase
 SafeBoolBase ()
 
 SafeBoolBase (const SafeBoolBase &)
 
SafeBoolBaseoperator= (const SafeBoolBase &)
 
 ~SafeBoolBase ()
 

Detailed Description

template<typename AceClock>
class OpenDDS::DCPS::TimePoint_T< AceClock >

Represents a specific time in reference to a ACE_Time_Policy and is based on C++11 std::chrono::time_point.

This wraps an ACE_Time_Value, but is designed to enforce the logic that this represents a specific point in time. For example, you can't directly add two TimePoints like you can add two ACE_Time_Values, because that wouldn't make sense. Following this theme, all the constructors are to be explicit to avoid careless implicit conversions.

See https://opendds.readthedocs.io/en/master/internal/dev_guidelines.html#time (or docs/internal/dev_guidelines.rst) for background and reasoning for this class.

Definition at line 35 of file TimePoint_T.h.

Member Typedef Documentation

◆ ClockType

template<typename AceClock>
typedef AceClock OpenDDS::DCPS::TimePoint_T< AceClock >::ClockType

Definition at line 37 of file TimePoint_T.h.

◆ ValueType

template<typename AceClock>
typedef ACE_Time_Value_T<AceClock> OpenDDS::DCPS::TimePoint_T< AceClock >::ValueType

Definition at line 38 of file TimePoint_T.h.

Constructor & Destructor Documentation

◆ TimePoint_T() [1/4]

template<typename AceClock >
ACE_INLINE OpenDDS::DCPS::TimePoint_T< AceClock >::TimePoint_T ( )

Set to zero_value, which is equal to the epoch (the starting point) of the AceClock.

Definition at line 12 of file TimePoint_T.inl.

13 : value_(zero_value.value())
14 {
15 }
static const TimePoint_T< AceClock > zero_value
Definition: TimePoint_T.h:40

◆ TimePoint_T() [2/4]

template<typename AceClock >
ACE_INLINE OpenDDS::DCPS::TimePoint_T< AceClock >::TimePoint_T ( const ACE_Time_Value ace_time_value)
explicit

Assign the value directly to the inner value doing conversions as necessary.

Warning
Use these carefully. Make sure ACE_Time_Value is a point in time and of the right clock type. DDS::Time_t should be in system clock time and so shouldn't be used with MonotonicTimePoint.

Definition at line 19 of file TimePoint_T.inl.

20 : value_(ace_time_value)
21 {
22 }

◆ TimePoint_T() [3/4]

template<typename AceClock>
ACE_INLINE OpenDDS::DCPS::TimePoint_T< AceClock >::TimePoint_T ( const ACE_Time_Value_T< AceClock > &  ace_time_value)
explicit

Assign the value directly to the inner value doing conversions as necessary.

Warning
Use these carefully. Make sure ACE_Time_Value is a point in time and of the right clock type. DDS::Time_t should be in system clock time and so shouldn't be used with MonotonicTimePoint.

Definition at line 26 of file TimePoint_T.inl.

27 : value_(ace_time_value)
28 {
29 }

◆ TimePoint_T() [4/4]

template<typename AceClock>
ACE_INLINE OpenDDS::DCPS::TimePoint_T< AceClock >::TimePoint_T ( const DDS::Time_t dds_time)
explicit

Assign the value directly to the inner value doing conversions as necessary.

Warning
Use these carefully. Make sure ACE_Time_Value is a point in time and of the right clock type. DDS::Time_t should be in system clock time and so shouldn't be used with MonotonicTimePoint.

Definition at line 33 of file TimePoint_T.inl.

34 : value_(time_to_time_value(dds_time))
35 {
36 }
ACE_INLINE OpenDDS_Dcps_Export ACE_Time_Value time_to_time_value(const DDS::Time_t &t)

Member Function Documentation

◆ boolean_test()

template<typename AceClock>
bool OpenDDS::DCPS::TimePoint_T< AceClock >::boolean_test ( ) const
inline

Definition at line 83 of file TimePoint_T.h.

84  {
85  return *this != zero_value;
86  }
static const TimePoint_T< AceClock > zero_value
Definition: TimePoint_T.h:40

◆ is_max()

template<typename AceClock >
ACE_INLINE bool OpenDDS::DCPS::TimePoint_T< AceClock >::is_max ( ) const

Is the object equal to the maximum possible value, max_value?

Definition at line 73 of file TimePoint_T.inl.

Referenced by OpenDDS::DCPS::TimePoint_T< SystemClock >::boolean_test().

74 {
75  return *this == max_value;
76 }
static const TimePoint_T< AceClock > max_value
Definition: TimePoint_T.h:41

◆ is_zero()

template<typename AceClock >
ACE_INLINE bool OpenDDS::DCPS::TimePoint_T< AceClock >::is_zero ( ) const

◆ now()

template<typename AceClock >
ACE_INLINE TimePoint_T< AceClock > OpenDDS::DCPS::TimePoint_T< AceClock >::now ( )
static

Get a TimePoint representing the current time of the AceClock.

Definition at line 41 of file TimePoint_T.inl.

42 {
43  return TimePoint_T<AceClock>(clock());
44 }
static ClockType clock
Definition: TimePoint_T.h:117

◆ operator+=()

template<typename AceClock >
ACE_INLINE TimePoint_T< AceClock > & OpenDDS::DCPS::TimePoint_T< AceClock >::operator+= ( const TimeDuration td)

Definition at line 105 of file TimePoint_T.inl.

Referenced by OpenDDS::DCPS::TimePoint_T< SystemClock >::boolean_test().

106 {
107  value_ += td.value();
108  return *this;
109 }

◆ operator-=()

template<typename AceClock >
ACE_INLINE TimePoint_T< AceClock > & OpenDDS::DCPS::TimePoint_T< AceClock >::operator-= ( const TimeDuration td)

Definition at line 114 of file TimePoint_T.inl.

Referenced by OpenDDS::DCPS::TimePoint_T< SystemClock >::boolean_test().

115 {
116  value_ -= td.value();
117  return *this;
118 }

◆ set_to_now()

template<typename AceClock >
ACE_INLINE void OpenDDS::DCPS::TimePoint_T< AceClock >::set_to_now ( )

◆ to_dds_time()

template<typename AceClock >
ACE_INLINE DDS::Time_t OpenDDS::DCPS::TimePoint_T< AceClock >::to_dds_time ( ) const

Convert to DDS::Time_t. This is probably only desirable for the system time version of this template class, SystemTimePoint.

Definition at line 89 of file TimePoint_T.inl.

Referenced by OpenDDS::DCPS::TimePoint_T< SystemClock >::boolean_test(), OpenDDS::DCPS::DomainParticipantImpl::get_current_time(), OpenDDS::FaceTSS::populate_header_received(), OpenDDS::DCPS::ReceivedDataElement::ReceivedDataElement(), OpenDDS::DCPS::DataWriterImpl::send_request_ack(), and OpenDDS::DCPS::DataReaderImpl_T< DynamicSample >::set_instance_state_i().

90 {
91  return time_value_to_time(value_);
92 }
ACE_INLINE OpenDDS_Dcps_Export DDS::Time_t time_value_to_time(const ACE_Time_Value &tv)

◆ to_monotonic_time()

template<typename AceClock >
ACE_INLINE MonotonicTime_t OpenDDS::DCPS::TimePoint_T< AceClock >::to_monotonic_time ( ) const

Convert to OpenDDS::DCPS::MonotonicTime_t.

Definition at line 97 of file TimePoint_T.inl.

Referenced by OpenDDS::DCPS::TimePoint_T< SystemClock >::boolean_test().

98 {
100 }
ACE_INLINE OpenDDS_Dcps_Export MonotonicTime_t time_value_to_monotonic_time(const ACE_Time_Value &tv)

◆ value() [1/2]

template<typename AceClock >
ACE_INLINE const ACE_Time_Value_T< AceClock > & OpenDDS::DCPS::TimePoint_T< AceClock >::value ( void  ) const

◆ value() [2/2]

template<typename AceClock>
ACE_INLINE void OpenDDS::DCPS::TimePoint_T< AceClock >::value ( const ACE_Time_Value_T< AceClock > &  ace_time_value)

Get and set the inner ACE_Time_Value based value. Use value() to pass this into ACE code that requires a point in time matching this ones clock type.

Definition at line 57 of file TimePoint_T.inl.

58 {
59  value_ = ace_time_value;
60 }

Member Data Documentation

◆ clock

template<typename AceClock>
AceClock OpenDDS::DCPS::TimePoint_T< AceClock >::clock
staticprotected

Strangely, ACE_Time_Policy must be objects to get their time values, so keep a static object.

Definition at line 117 of file TimePoint_T.h.

◆ max_value

template<typename AceClock>
const TimePoint_T< AceClock > OpenDDS::DCPS::TimePoint_T< AceClock >::max_value
static

Definition at line 41 of file TimePoint_T.h.

◆ value_

template<typename AceClock>
ValueType OpenDDS::DCPS::TimePoint_T< AceClock >::value_
protected

Definition at line 119 of file TimePoint_T.h.

◆ zero_value

template<typename AceClock>
const TimePoint_T< AceClock > OpenDDS::DCPS::TimePoint_T< AceClock >::zero_value
static

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