Apollo 10.0
自动驾驶开放平台
apollo::cyber::data::CacheBuffer< T > 模板类 参考

#include <cache_buffer.h>

apollo::cyber::data::CacheBuffer< T > 的协作图:

Public 类型

using value_type = T
 
using size_type = std::size_t
 
using FusionCallback = std::function< void(const T &)>
 

Public 成员函数

 CacheBuffer (uint64_t size)
 
 CacheBuffer (const CacheBuffer &rhs)
 
T & operator[] (const uint64_t &pos)
 
const T & at (const uint64_t &pos) const
 
uint64_t Head () const
 
uint64_t Tail () const
 
uint64_t Size () const
 
const T & Front () const
 
const T & Back () const
 
bool Empty () const
 
bool Full () const
 
uint64_t Capacity () const
 
void SetFusionCallback (const FusionCallback &callback)
 
void Fill (const T &value)
 
std::mutex & Mutex ()
 

详细描述

template<typename T>
class apollo::cyber::data::CacheBuffer< T >

在文件 cache_buffer.h30 行定义.

成员类型定义说明

◆ FusionCallback

template<typename T >
using apollo::cyber::data::CacheBuffer< T >::FusionCallback = std::function<void(const T&)>

在文件 cache_buffer.h34 行定义.

◆ size_type

template<typename T >
using apollo::cyber::data::CacheBuffer< T >::size_type = std::size_t

在文件 cache_buffer.h33 行定义.

◆ value_type

template<typename T >
using apollo::cyber::data::CacheBuffer< T >::value_type = T

在文件 cache_buffer.h32 行定义.

构造及析构函数说明

◆ CacheBuffer() [1/2]

template<typename T >
apollo::cyber::data::CacheBuffer< T >::CacheBuffer ( uint64_t  size)
inlineexplicit

在文件 cache_buffer.h36 行定义.

36 {
37 capacity_ = size + 1;
38 buffer_.resize(capacity_);
39 }

◆ CacheBuffer() [2/2]

template<typename T >
apollo::cyber::data::CacheBuffer< T >::CacheBuffer ( const CacheBuffer< T > &  rhs)
inline

在文件 cache_buffer.h41 行定义.

41 {
42 std::lock_guard<std::mutex> lg(rhs.mutex_);
43 head_ = rhs.head_;
44 tail_ = rhs.tail_;
45 buffer_ = rhs.buffer_;
46 capacity_ = rhs.capacity_;
47 fusion_callback_ = rhs.fusion_callback_;
48 }

成员函数说明

◆ at()

template<typename T >
const T & apollo::cyber::data::CacheBuffer< T >::at ( const uint64_t &  pos) const
inline

在文件 cache_buffer.h51 行定义.

51{ return buffer_[GetIndex(pos)]; }

◆ Back()

template<typename T >
const T & apollo::cyber::data::CacheBuffer< T >::Back ( ) const
inline

在文件 cache_buffer.h58 行定义.

58{ return buffer_[GetIndex(tail_)]; }

◆ Capacity()

template<typename T >
uint64_t apollo::cyber::data::CacheBuffer< T >::Capacity ( ) const
inline

在文件 cache_buffer.h62 行定义.

62{ return capacity_; }

◆ Empty()

template<typename T >
bool apollo::cyber::data::CacheBuffer< T >::Empty ( ) const
inline

在文件 cache_buffer.h60 行定义.

60{ return tail_ == 0; }

◆ Fill()

template<typename T >
void apollo::cyber::data::CacheBuffer< T >::Fill ( const T &  value)
inline

在文件 cache_buffer.h68 行定义.

68 {
69 if (fusion_callback_) {
70 fusion_callback_(value);
71 } else {
72 if (Full()) {
73 buffer_[GetIndex(head_)] = value;
74 ++head_;
75 ++tail_;
76 } else {
77 buffer_[GetIndex(tail_ + 1)] = value;
78 ++tail_;
79 }
80 }
81 }

◆ Front()

template<typename T >
const T & apollo::cyber::data::CacheBuffer< T >::Front ( ) const
inline

在文件 cache_buffer.h57 行定义.

57{ return buffer_[GetIndex(head_ + 1)]; }

◆ Full()

template<typename T >
bool apollo::cyber::data::CacheBuffer< T >::Full ( ) const
inline

在文件 cache_buffer.h61 行定义.

61{ return capacity_ - 1 == tail_ - head_; }

◆ Head()

template<typename T >
uint64_t apollo::cyber::data::CacheBuffer< T >::Head ( ) const
inline

在文件 cache_buffer.h53 行定义.

53{ return head_ + 1; }

◆ Mutex()

template<typename T >
std::mutex & apollo::cyber::data::CacheBuffer< T >::Mutex ( )
inline

在文件 cache_buffer.h83 行定义.

83{ return mutex_; }

◆ operator[]()

template<typename T >
T & apollo::cyber::data::CacheBuffer< T >::operator[] ( const uint64_t &  pos)
inline

在文件 cache_buffer.h50 行定义.

50{ return buffer_[GetIndex(pos)]; }

◆ SetFusionCallback()

template<typename T >
void apollo::cyber::data::CacheBuffer< T >::SetFusionCallback ( const FusionCallback callback)
inline

在文件 cache_buffer.h64 行定义.

64 {
65 fusion_callback_ = callback;
66 }

◆ Size()

template<typename T >
uint64_t apollo::cyber::data::CacheBuffer< T >::Size ( ) const
inline

在文件 cache_buffer.h55 行定义.

55{ return tail_ - head_; }

◆ Tail()

template<typename T >
uint64_t apollo::cyber::data::CacheBuffer< T >::Tail ( ) const
inline

在文件 cache_buffer.h54 行定义.

54{ return tail_; }

该类的文档由以下文件生成: