Monado OpenXR Runtime
|
All the bookkeeping for adapting a fixed-size array to a ring buffer. More...
#include <util/u_template_historybuf_impl_helpers.hpp>
Public Member Functions | |
constexpr | RingBufferHelper (size_t capacity) |
Construct for a given size. More... | |
RingBufferHelper (RingBufferHelper const &)=default | |
RingBufferHelper (RingBufferHelper &&)=default | |
RingBufferHelper & | operator= (RingBufferHelper const &)=default |
RingBufferHelper & | operator= (RingBufferHelper &&)=default |
bool | age_to_inner_index (size_t age, size_t &out_inner_idx) const noexcept |
Get the inner index for a given age (if possible) More... | |
bool | clamped_age_to_inner_index (size_t age, size_t &out_inner_idx) const noexcept |
Get the inner index for a given age, clamping it if out of bounds. More... | |
bool | index_to_inner_index (size_t index, size_t &out_inner_idx) const noexcept |
Get the inner index for a given index (if possible) More... | |
bool | empty () const noexcept |
Is the buffer empty? More... | |
size_t | size () const noexcept |
How many elements are in the buffer? More... | |
size_t | push_back_location () noexcept |
Update internal state for pushing an element to the back, and return the inner index to store the element at. More... | |
void | pop_front () noexcept |
Record the logical removal of the front element, if any. More... | |
bool | pop_back () noexcept |
Record the logical removal of the back element, if any. More... | |
size_t | front_inner_index () const noexcept |
Get the inner index of the front (oldest) value, or capacity_ if empty. More... | |
size_t | back_inner_index () const noexcept |
Get the inner index of the back (newest) value, or capacity_ if empty. More... | |
void | clear () |
All the bookkeeping for adapting a fixed-size array to a ring buffer.
This is all the guts of the ring buffer except for the actual buffer. We split it out to
There are a few types of "index":
|
inlineexplicitconstexpr |
Construct for a given size.
|
inlinenoexcept |
Get the inner index for a given age (if possible)
References empty().
Referenced by clamped_age_to_inner_index(), and u_id_ringbuffer::u_id_ringbuffer_get_at_age().
|
inlinenoexcept |
Get the inner index of the back (newest) value, or capacity_ if empty.
References empty().
Referenced by u_id_ringbuffer::u_id_ringbuffer_get_back().
|
inlinenoexcept |
Get the inner index for a given age, clamping it if out of bounds.
References age_to_inner_index(), and empty().
Referenced by xrt::auxiliary::util::HistoryBuffer< T, MaxSize >::get_at_clamped_age(), and u_id_ringbuffer::u_id_ringbuffer_get_at_clamped_age().
|
inlinenoexcept |
Is the buffer empty?
Referenced by age_to_inner_index(), back_inner_index(), clamped_age_to_inner_index(), front_inner_index(), index_to_inner_index(), pop_back(), pop_front(), and u_id_ringbuffer::u_id_ringbuffer_is_empty().
|
inlinenoexcept |
Get the inner index of the front (oldest) value, or capacity_ if empty.
References empty().
Referenced by u_id_ringbuffer::u_id_ringbuffer_get_front().
|
inlinenoexcept |
Get the inner index for a given index (if possible)
References empty().
Referenced by u_id_ringbuffer::u_id_ringbuffer_get_at_index().
|
inlinenoexcept |
Record the logical removal of the back element, if any.
Returns false if the buffer is empty. Does not actually modify the value stored in the backing array.
References empty().
Referenced by xrt::auxiliary::util::HistoryBuffer< T, MaxSize >::pop_back(), and u_id_ringbuffer::u_id_ringbuffer_pop_back().
|
inlinenoexcept |
Record the logical removal of the front element, if any.
Does nothing if the buffer is empty. Does not actually modify the value stored in the backing array.
References empty().
Referenced by xrt::auxiliary::util::HistoryBuffer< T, MaxSize >::pop_front(), and u_id_ringbuffer::u_id_ringbuffer_pop_front().
|
inlinenoexcept |
Update internal state for pushing an element to the back, and return the inner index to store the element at.
This is the implementation of "push_back" excluding all the messy "actually dealing with the data" part ;-)
Referenced by u_id_ringbuffer::u_id_ringbuffer_push_back().
|
inlinenoexcept |
How many elements are in the buffer?
Referenced by u_id_ringbuffer::u_id_ringbuffer_get_size().