Click
Loading...
Searching...
No Matches
Public Member Functions | List of all members
CircularBuffer Class Reference

Represents a ring buffer that automatically grows to be able to store the data and provides O(1) operations. The buffer uses a buffer pool from which it gets an initial memory chunk that it will keep big enough to store the data. More...

#include <circularbuffer.hh>

Public Member Functions

 CircularBuffer (BufferPool *bufferPool)
 Construct a CircularBuffer.
 
 ~CircularBuffer ()
 Destruct a CircularBuffer Put the buffer back into the BufferPool.
 
uint32_t getSize ()
 Return the size of the circular buffer (the size of the data in it)
 
uint32_t getCapacity ()
 Return the capacity of the circular buffer (the size of the memory chunk it uses)
 
uint32_t getStartOffset ()
 Return the start offset. Offset of the first byte in the buffer. Used to be able to manipulate sequence numbers. This offset is substracted from the requested data's position in order to obtain a position in the buffer.
 
void setStartOffset (uint32_t startOffset)
 Set the start offset. Offset of the first byte in the buffer. Used to be able to manipulate sequence numbers. This offset is substracted from the requested data's position in order to obtain a position in the buffer.
 
bool isBlank ()
 Indicate whether the buffer is blank.
 
void removeDataAtBeginning (uint32_t newStart)
 Remove data at the beginning of the buffer.
 
void addDataAtEnd (const unsigned char *data, uint32_t length)
 Add data at the end of the buffer.
 
void getData (uint32_t start, uint32_t length, Vector< unsigned char > &getBuffer)
 Retrieve data from the buffer.
 

Detailed Description

Represents a ring buffer that automatically grows to be able to store the data and provides O(1) operations. The buffer uses a buffer pool from which it gets an initial memory chunk that it will keep big enough to store the data.

Constructor & Destructor Documentation

◆ CircularBuffer()

CircularBuffer::CircularBuffer ( BufferPool *  bufferPool)

Construct a CircularBuffer.

Parameters
bufferPoolThe BufferPool from which the buffer will be retrieved

◆ ~CircularBuffer()

CircularBuffer::~CircularBuffer ( )

Destruct a CircularBuffer Put the buffer back into the BufferPool.

Member Function Documentation

◆ getSize()

uint32_t CircularBuffer::getSize ( )

Return the size of the circular buffer (the size of the data in it)

Returns
Size of the circular buffer

◆ getCapacity()

uint32_t CircularBuffer::getCapacity ( )

Return the capacity of the circular buffer (the size of the memory chunk it uses)

Returns
Capacity of the circular buffer

◆ getStartOffset()

uint32_t CircularBuffer::getStartOffset ( )

Return the start offset. Offset of the first byte in the buffer. Used to be able to manipulate sequence numbers. This offset is substracted from the requested data's position in order to obtain a position in the buffer.

Returns
The start offset

◆ setStartOffset()

void CircularBuffer::setStartOffset ( uint32_t  startOffset)

Set the start offset. Offset of the first byte in the buffer. Used to be able to manipulate sequence numbers. This offset is substracted from the requested data's position in order to obtain a position in the buffer.

Parameters
startOffsetThe start offset

◆ isBlank()

bool CircularBuffer::isBlank ( )

Indicate whether the buffer is blank.

Returns
True if the buffer is blank

◆ removeDataAtBeginning()

void CircularBuffer::removeDataAtBeginning ( uint32_t  newStart)

Remove data at the beginning of the buffer.

Parameters
newStartPosition of the new first byte in the buffer (takes into account the start offset)

◆ addDataAtEnd()

void CircularBuffer::addDataAtEnd ( const unsigned char *  data,
uint32_t  length 
)

Add data at the end of the buffer.

Parameters
dataThe data to add
lengthThe length of the data to add

◆ getData()

void CircularBuffer::getData ( uint32_t  start,
uint32_t  length,
Vector< unsigned char > &  getBuffer 
)

Retrieve data from the buffer.

Parameters
startPosition of the first byte (takes into account the start offset)
lengthThe length of the data to retrieve
getBufferBuffer in which the data will be returned. Its size will be updated

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