6#include "libxr_def.hpp"
28 QueueBase(uint16_t element_size,
size_t length, uint8_t* buffer);
38 QueueBase(uint16_t element_size,
size_t length);
52 [[nodiscard]]
void*
operator[](uint32_t index);
151 [[nodiscard]]
size_t Size()
const;
提供固定大小循环缓冲区的字节 FIFO 队列。 Byte FIFO queue providing a fixed-size circular buffer.
~QueueBase()
析构队列 / Destroy the queue.
size_t EmptySize() const
获取当前剩余空槽数 / Get the current free-slot count.
bool is_full_
当前队列是否已满 / Whether the queue is currently full.
ErrorCode PushBytes(const void *data)
按字节入队一个元素 / Enqueue one element by bytes.
const uint16_t ELEMENT_SIZE
单个元素的字节数 / Byte size of one element.
uint8_t * queue_array_
队列数据缓冲区 / Queue data buffer.
ErrorCode PopBatchBytes(void *data, size_t size)
按字节批量出队多个元素 / Dequeue multiple elements by bytes.
int GetLastElementIndex() const
获取当前最后一个已入队元素的物理槽位下标。 Get the physical slot index of the current last queued element.
void Reset()
重置队列状态 / Reset the queue state.
QueueBase(uint16_t element_size, size_t length, uint8_t *buffer)
使用外部缓冲区构造队列 / Construct the queue with an external buffer.
ErrorCode OverwriteBytes(const void *data)
清空当前状态后,用一个新元素覆盖队列内容。 Reset the queue state and overwrite it with one new element.
ErrorCode PeekBatchBytes(void *data, size_t size)
按字节批量查看多个元素但不出队。 Peek multiple elements by bytes without dequeuing them.
size_t MaxSize() const
获取队列最大容量 / Get the maximum queue capacity.
void * operator[](uint32_t index)
访问指定物理槽位的原始元素地址。 Access the raw element address of one physical slot.
size_t Size() const
获取当前已存储元素个数 / Get the current stored element count.
ErrorCode PushBatchBytes(const void *data, size_t size)
按字节批量入队多个元素 / Enqueue multiple elements by bytes.
int GetFirstElementIndex() const
获取当前第一个已入队元素的物理槽位下标。 Get the physical slot index of the current first queued element.
size_t length_
队列最大容量 / Maximum queue capacity.
size_t head_
当前队头物理槽位下标 / Physical slot index of the current head.
bool own_buffer_
是否由当前队列拥有缓冲区 / Whether this queue owns the buffer.
ErrorCode PopBytes(void *data=nullptr)
按字节出队一个元素;传空指针时仅丢弃队头。 Dequeue one element by bytes; pass null to discard the front item only.
ErrorCode PeekBytes(void *data)
按字节查看队头元素但不出队。 Peek the front element by bytes without dequeuing it.
LibXR 命名空间 / LibXR namespace.
ErrorCode
定义错误码枚举 / Defines an enumeration for error codes