Template Class RingBufferImplementation

Inheritance Relationships

Base Type

Class Documentation

template<typename BufferT>
class RingBufferImplementation : public rclcpp::experimental::buffers::BufferImplementationBase<BufferT>

Store elements in a fixed-size, FIFO buffer.

All public member functions are thread-safe.

Public Functions

inline explicit RingBufferImplementation(size_t capacity)
inline virtual ~RingBufferImplementation()
inline virtual void enqueue(BufferT request)

Add a new element to store in the ring buffer.

This member function is thread-safe.

Parameters:

request – the element to be stored in the ring buffer

inline virtual BufferT dequeue()

Remove the oldest element from ring buffer.

This member function is thread-safe.

Returns:

the element that is being removed from the ring buffer

inline size_t next(size_t val)

Get the next index value for the ring buffer.

This member function is thread-safe.

Parameters:

val – the current index value

Returns:

the next index value

inline virtual bool has_data() const

Get if the ring buffer has at least one element stored.

This member function is thread-safe.

Returns:

true if there is data and false otherwise

inline bool is_full() const

Get if the size of the buffer is equal to its capacity.

This member function is thread-safe.

Returns:

true if the size of the buffer is equal is capacity and false otherwise

inline virtual void clear()