Class CacheBufferInterface

Inheritance Relationships

Derived Types

Class Documentation

class CacheBufferInterface

This class provides the interface for all CacheBuffer implementations. The role of these buffers is store messages that are received via topic subscriptions before they are written to the bagfile.

Any class that implements CacheBufferInterface is reponsible for handling synchronization that is needed for the buffer to operate properly.

Subclassed by rosbag2_cpp::cache::MessageCacheBuffer, rosbag2_cpp::cache::MessageCacheCircularBuffer

Public Types

using buffer_element_t = std::shared_ptr<const rosbag2_storage::SerializedBagMessage>

Public Functions

inline virtual ~CacheBufferInterface()
virtual bool push(buffer_element_t msg) = 0

Pushes a SerializedBagMessage into the cache buffer.


msg – SerializedBagMessage to add to the buffer.


whether message was successfully added to the cache.

virtual void clear() = 0

Clears the buffer by removing all remaining messages.

virtual size_t size() = 0

Check the buffer message count.


number of elements in the buffer.

virtual const std::vector<buffer_element_t> &data() = 0

Get the data/messages stored in the buffer. This should only be called once no more messages are being added to the buffer.


a vector containing messages in the buffer.