libxr 1.0
Want to be the best embedded framework
Loading...
Searching...
No Matches
LibXR::TimestampUS Class Reference

表示微秒级时间戳的类。Class representing a timestamp in microseconds. More...

#include <libxr_time.hpp>

Data Structures

class  TimeDiffUS
 表示微秒级时间差的类。Class representing a time difference in microseconds. More...
 

Public Member Functions

 TimestampUS ()
 默认构造函数,初始化时间戳为 0。 Default constructor initializing the timestamp to 0.
 
 TimestampUS (uint64_t microsecond)
 以给定的微秒值构造时间戳。 Constructor initializing the timestamp with a given microsecond value.
 
 operator uint64_t () const
 转换运算符,将时间戳转换为 uint64_t。 Conversion operator to uint64_t.
 
TimeDiffUS operator- (const TimestampUS &old_microsecond) const
 计算两个时间戳之间的时间差。 Computes the time difference between two timestamps.
 
TimestampUSoperator= (const TimestampUS &other)
 赋值运算符重载。 Assignment operator overload.
 

Private Attributes

uint64_t microsecond_
 以微秒存储的时间戳。Timestamp stored in microseconds.
 

Detailed Description

表示微秒级时间戳的类。Class representing a timestamp in microseconds.

Definition at line 18 of file libxr_time.hpp.

Constructor & Destructor Documentation

◆ TimestampUS() [1/2]

LibXR::TimestampUS::TimestampUS ( )
inline

默认构造函数,初始化时间戳为 0。 Default constructor initializing the timestamp to 0.

Definition at line 25 of file libxr_time.hpp.

25: microsecond_(0) {}
uint64_t microsecond_
以微秒存储的时间戳。Timestamp stored in microseconds.

◆ TimestampUS() [2/2]

LibXR::TimestampUS::TimestampUS ( uint64_t  microsecond)
inline

以给定的微秒值构造时间戳。 Constructor initializing the timestamp with a given microsecond value.

Parameters
microsecond以微秒表示的时间值。Time value in microseconds.

Definition at line 32 of file libxr_time.hpp.

constexpr auto min(T1 a, T2 b) -> typename std::common_type< T1, T2 >::type
计算两个数的最小值

Member Function Documentation

◆ operator uint64_t()

LibXR::TimestampUS::operator uint64_t ( ) const
inline

转换运算符,将时间戳转换为 uint64_t。 Conversion operator to uint64_t.

Definition at line 38 of file libxr_time.hpp.

38{ return microsecond_; }

◆ operator-()

TimeDiffUS LibXR::TimestampUS::operator- ( const TimestampUS old_microsecond) const
inline

计算两个时间戳之间的时间差。 Computes the time difference between two timestamps.

Parameters
old_microsecond旧的时间戳。The older timestamp.
Returns
TimeDiffUS 计算得到的时间差。Computed time difference.

Definition at line 94 of file libxr_time.hpp.

95 {
96 uint64_t diff; // NOLINT
97
98 if (microsecond_ >= old_microsecond.microsecond_)
99 {
100 diff = microsecond_ - old_microsecond.microsecond_;
101 }
102 else
103 {
104 diff = microsecond_ + (libxr_timebase_max_valid_us - old_microsecond.microsecond_);
105 }
106
107 ASSERT(diff <= libxr_timebase_max_valid_us);
108
109 return TimeDiffUS(diff);
110 }

◆ operator=()

TimestampUS & LibXR::TimestampUS::operator= ( const TimestampUS other)
inline

赋值运算符重载。 Assignment operator overload.

Parameters
other另一个 TimestampUS 对象。Another TimestampUS object.
Returns
返回当前对象的引用。Returns a reference to the current object.

Definition at line 118 of file libxr_time.hpp.

119 {
120 if (this != &other)
121 {
122 microsecond_ = other.microsecond_;
123 }
124 return *this;
125 }

Field Documentation

◆ microsecond_

uint64_t LibXR::TimestampUS::microsecond_
private

以微秒存储的时间戳。Timestamp stored in microseconds.

Definition at line 128 of file libxr_time.hpp.


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