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

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

#include <libxr_time.hpp>

Data Structures

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

Public Member Functions

 MicrosecondTimestamp ()
 默认构造函数,初始化时间戳为 0。 Default constructor initializing the timestamp to 0.
 
 MicrosecondTimestamp (uint64_t microsecond)
 以给定的微秒值构造时间戳。 Constructor initializing the timestamp with a given microsecond value.
 
 operator uint64_t () const
 转换运算符,将时间戳转换为 uint64_t。 Conversion operator to uint64_t.
 
Duration operator- (const MicrosecondTimestamp &old_microsecond) const
 计算两个时间戳之间的时间差。 Computes the time difference between two timestamps.
 
MicrosecondTimestampoperator= (const MicrosecondTimestamp &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

◆ MicrosecondTimestamp() [1/2]

MicrosecondTimestamp::MicrosecondTimestamp ( )

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

Definition at line 8 of file libxr_time.cpp.

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

◆ MicrosecondTimestamp() [2/2]

MicrosecondTimestamp::MicrosecondTimestamp ( uint64_t microsecond)

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

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

Definition at line 10 of file libxr_time.cpp.

11 : microsecond_(microsecond)
12{
13}

Member Function Documentation

◆ operator uint64_t()

MicrosecondTimestamp::operator uint64_t ( ) const

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

Definition at line 15 of file libxr_time.cpp.

15{ return microsecond_; }

◆ operator-()

MicrosecondTimestamp::Duration MicrosecondTimestamp::operator- ( const MicrosecondTimestamp & old_microsecond) const

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

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

Definition at line 41 of file libxr_time.cpp.

43{
44 uint64_t diff; // NOLINT
45
46 if (microsecond_ >= old_microsecond.microsecond_)
47 {
48 diff = microsecond_ - old_microsecond.microsecond_;
49 }
50 else
51 {
52 diff = microsecond_ + (libxr_timebase_max_valid_us - old_microsecond.microsecond_);
53 }
54
55 ASSERT(diff <= libxr_timebase_max_valid_us);
56
57 return Duration(diff);
58}

◆ operator=()

MicrosecondTimestamp & MicrosecondTimestamp::operator= ( const MicrosecondTimestamp & other)

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

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

Definition at line 60 of file libxr_time.cpp.

61{
62 if (this != &other)
63 {
65 }
66 return *this;
67}

Field Documentation

◆ microsecond_

uint64_t LibXR::MicrosecondTimestamp::microsecond_
private

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

Definition at line 105 of file libxr_time.hpp.


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