Class MessageCacheBuffer

Inheritance Relationships

Base Type

Class Documentation

class MessageCacheBuffer : public rosbag2_cpp::cache::CacheBufferInterface

This class implements a single buffer for message cache. The buffer is byte size limited and won’t accept any messages when current buffer byte size is already over the limit set by max_cache_size. This means that buffer can at times use more memory than max_cache_size, but never by more than a single message. When the buffer is full, the next incoming message is dropped.

Note that it could be reused as a template with any class that has ->byte_size() - like interface

Public Functions

explicit MessageCacheBuffer(size_t max_cache_size)
virtual bool push(CacheBufferInterface::buffer_element_t msg) override

If buffer size got some space left, we push message regardless of its size, but if this results in exceeding buffer size, we mark buffer to drop all new incoming messages. This flag is cleared when buffers are swapped.

virtual void clear() override

Clear buffer.

virtual size_t size() override

Get number of elements in the buffer.

virtual const std::vector<CacheBufferInterface::buffer_element_t> &data() override

Get buffer data.