ROS 2 rclcpp + rcl - kilted  kilted
ROS 2 C++ Client Library with ROS Client Library
Classes | Public Member Functions | List of all members
rclcpp::experimental::buffers::RingBufferImplementation< BufferT > Class Template Reference

Store elements in a fixed-size, FIFO buffer. More...

#include <rclcpp/experimental/buffers/ring_buffer_implementation.hpp>

Inheritance diagram for rclcpp::experimental::buffers::RingBufferImplementation< BufferT >:
Inheritance graph
[legend]
Collaboration diagram for rclcpp::experimental::buffers::RingBufferImplementation< BufferT >:
Collaboration graph
[legend]

Public Member Functions

 RingBufferImplementation (size_t capacity)
 
void enqueue (BufferT request) override
 Add a new element to store in the ring buffer. More...
 
BufferT dequeue () override
 Remove the oldest element from ring buffer. More...
 
std::vector< BufferT > get_all_data () override
 Get all the elements from the ring buffer. More...
 
size_t next (size_t val)
 Get the next index value for the ring buffer. More...
 
bool has_data () const override
 Get if the ring buffer has at least one element stored. More...
 
bool is_full () const
 Get if the size of the buffer is equal to its capacity. More...
 
size_t available_capacity () const override
 Get the remaining capacity to store messages. More...
 
void clear () override
 

Detailed Description

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

Store elements in a fixed-size, FIFO buffer.

All public member functions are thread-safe.

Definition at line 43 of file ring_buffer_implementation.hpp.

Member Function Documentation

◆ available_capacity()

template<typename BufferT >
size_t rclcpp::experimental::buffers::RingBufferImplementation< BufferT >::available_capacity ( ) const
inlineoverridevirtual

Get the remaining capacity to store messages.

This member function is thread-safe.

Returns
the number of free capacity for new messages

Implements rclcpp::experimental::buffers::BufferImplementationBase< BufferT >.

Definition at line 172 of file ring_buffer_implementation.hpp.

◆ dequeue()

template<typename BufferT >
BufferT rclcpp::experimental::buffers::RingBufferImplementation< BufferT >::dequeue ( )
inlineoverridevirtual

Remove the oldest element from ring buffer.

This member function is thread-safe.

Returns
the element that is being removed from the ring buffer

Implements rclcpp::experimental::buffers::BufferImplementationBase< BufferT >.

Definition at line 96 of file ring_buffer_implementation.hpp.

◆ enqueue()

template<typename BufferT >
void rclcpp::experimental::buffers::RingBufferImplementation< BufferT >::enqueue ( BufferT  request)
inlineoverridevirtual

Add a new element to store in the ring buffer.

This member function is thread-safe.

Parameters
requestthe element to be stored in the ring buffer

Implements rclcpp::experimental::buffers::BufferImplementationBase< BufferT >.

Definition at line 70 of file ring_buffer_implementation.hpp.

◆ get_all_data()

template<typename BufferT >
std::vector<BufferT> rclcpp::experimental::buffers::RingBufferImplementation< BufferT >::get_all_data ( )
inlineoverridevirtual

Get all the elements from the ring buffer.

This member function is thread-safe.

Returns
a vector containing all the elements from the ring buffer

Implements rclcpp::experimental::buffers::BufferImplementationBase< BufferT >.

Definition at line 123 of file ring_buffer_implementation.hpp.

◆ has_data()

template<typename BufferT >
bool rclcpp::experimental::buffers::RingBufferImplementation< BufferT >::has_data ( ) const
inlineoverridevirtual

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

Implements rclcpp::experimental::buffers::BufferImplementationBase< BufferT >.

Definition at line 147 of file ring_buffer_implementation.hpp.

◆ is_full()

template<typename BufferT >
bool rclcpp::experimental::buffers::RingBufferImplementation< BufferT >::is_full ( ) const
inline

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

Definition at line 160 of file ring_buffer_implementation.hpp.

◆ next()

template<typename BufferT >
size_t rclcpp::experimental::buffers::RingBufferImplementation< BufferT >::next ( size_t  val)
inline

Get the next index value for the ring buffer.

This member function is thread-safe.

Parameters
valthe current index value
Returns
the next index value

Definition at line 135 of file ring_buffer_implementation.hpp.


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