Monado OpenXR Runtime
u_id_ringbuffer Struct Reference
Collaboration diagram for u_id_ringbuffer:

Public Member Functions

 u_id_ringbuffer (uint32_t capacity_)
 
struct u_id_ringbufferu_id_ringbuffer_create (uint32_t capacity)
 Create a ringbuffer for storing IDs. More...
 
int64_t u_id_ringbuffer_push_back (struct u_id_ringbuffer *uirb, uint64_t id)
 Push a new element to the back. More...
 
void u_id_ringbuffer_pop_front (struct u_id_ringbuffer *uirb)
 Pop an element from the front, if any. More...
 
void u_id_ringbuffer_pop_back (struct u_id_ringbuffer *uirb)
 Pop an element from the back, if any. More...
 
int32_t u_id_ringbuffer_get_back (struct u_id_ringbuffer *uirb, uint64_t *out_id)
 Get the back (most recent) of the buffer. More...
 
int32_t u_id_ringbuffer_get_front (struct u_id_ringbuffer *uirb, uint64_t *out_id)
 Get the front (least recent) of the buffer. More...
 
uint32_t u_id_ringbuffer_get_size (struct u_id_ringbuffer const *uirb)
 Get the number of elements in the buffer. More...
 
bool u_id_ringbuffer_is_empty (struct u_id_ringbuffer const *uirb)
 Get whether the buffer is empty. More...
 
int32_t u_id_ringbuffer_get_at_age (struct u_id_ringbuffer *uirb, uint32_t age, uint64_t *out_id)
 Get an element a certain distance ("age") from the back of the buffer. More...
 
int32_t u_id_ringbuffer_get_at_clamped_age (struct u_id_ringbuffer *uirb, uint32_t age, uint64_t *out_id)
 Get an element a certain distance ("age") from the back of the buffer, clamping age to stay in bounds as long as the buffer is not empty. More...
 
int32_t u_id_ringbuffer_get_at_index (struct u_id_ringbuffer *uirb, uint32_t index, uint64_t *out_id)
 Get an element a certain index from the front of the (logical) buffer. More...
 
int32_t u_id_ringbuffer_lower_bound_id (struct u_id_ringbuffer *uirb, uint64_t search_id, uint64_t *out_id, uint32_t *out_index)
 Find the latest element not less than the supplied ID search_id . More...
 
int32_t u_id_ringbuffer_find_id_unordered (struct u_id_ringbuffer *uirb, uint64_t search_id, uint64_t *out_id, uint32_t *out_index)
 Find the element with the supplied ID search_id in an unordered buffer. More...
 
void u_id_ringbuffer_destroy (struct u_id_ringbuffer **ptr_to_uirb)
 Destroy an ID ring buffer. More...
 

Data Fields

RingBufferHelper helper
 
std::vector< id_value_type > ids
 
uint32_t capacity
 

Member Function Documentation

◆ u_id_ringbuffer_create()

struct u_id_ringbuffer * u_id_ringbuffer_create ( uint32_t  capacity)

Create a ringbuffer for storing IDs.

You might keep an array of equivalent capacity locally: methods of this container will tell you which index in that array to interact with.

Parameters
capacity
Returns
struct u_id_ringbuffer*

◆ u_id_ringbuffer_destroy()

void u_id_ringbuffer_destroy ( struct u_id_ringbuffer **  ptr_to_uirb)

Destroy an ID ring buffer.

Does null checks.

Parameters
ptr_to_uirbAddress of your ring buffer pointer. Will be set to zero.

◆ u_id_ringbuffer_find_id_unordered()

int32_t u_id_ringbuffer_find_id_unordered ( struct u_id_ringbuffer uirb,
uint64_t  search_id,
uint64_t *  out_id,
uint32_t *  out_index 
)

Find the element with the supplied ID search_id in an unordered buffer.

This does not depend on order so does a linear search. If you are keeping your IDs in ascending order, use u_id_ringbuffer_lower_bound_id() instead.

Parameters
uirbself pointer
search_idthe ID to search for.
[out]out_idWhere to store the ID found, if successful (optional)
[out]out_indexWhere to store the ring buffer index (not the inner index) found, if successful (optional)
Returns
the "inner" index in your array with any associated data, or negative if error (empty, etc).

◆ u_id_ringbuffer_get_at_age()

int32_t u_id_ringbuffer_get_at_age ( struct u_id_ringbuffer uirb,
uint32_t  age,
uint64_t *  out_id 
)

Get an element a certain distance ("age") from the back of the buffer.

See u_id_ringbuffer_get_at_clamped_age() if you want to clamp the age

Parameters
uirbself pointer
agethe distance from the back (0 is the same as back, 1 is previous, etc)
[out]out_idWhere to store the ID, if successful (optional)
Returns
the "inner" index in your array with any associated data, or negative if error (empty, out of range, etc).

References xrt::auxiliary::util::detail::RingBufferHelper::age_to_inner_index().

◆ u_id_ringbuffer_get_at_clamped_age()

int32_t u_id_ringbuffer_get_at_clamped_age ( struct u_id_ringbuffer uirb,
uint32_t  age,
uint64_t *  out_id 
)

Get an element a certain distance ("age") from the back of the buffer, clamping age to stay in bounds as long as the buffer is not empty.

See u_id_ringbuffer_get_at_age() if you don't want clamping.

Parameters
uirbself pointer
agethe distance from the back (0 is the same as back, 1 is previous, etc)
[out]out_idWhere to store the ID, if successful (optional)
Returns
the "inner" index in your array with any associated data, or negative if error (empty, etc).

References xrt::auxiliary::util::detail::RingBufferHelper::clamped_age_to_inner_index().

◆ u_id_ringbuffer_get_at_index()

int32_t u_id_ringbuffer_get_at_index ( struct u_id_ringbuffer uirb,
uint32_t  index,
uint64_t *  out_id 
)

Get an element a certain index from the front of the (logical) buffer.

Parameters
uirbself pointer
indexthe distance from the front (0 is the same as front, 1 is newer, etc)
[out]out_idWhere to store the ID, if successful (optional)
Returns
the "inner" index in your array with any associated data, or negative if error (empty, out of range, etc).

References xrt::auxiliary::util::detail::RingBufferHelper::index_to_inner_index().

◆ u_id_ringbuffer_get_back()

int32_t u_id_ringbuffer_get_back ( struct u_id_ringbuffer uirb,
uint64_t *  out_id 
)

Get the back (most recent) of the buffer.

Parameters
uirbself pointer
[out]out_idWhere to store the back ID
Returns
the "inner" index in your array with any associated data, or negative if error (empty, etc).

References xrt::auxiliary::util::detail::RingBufferHelper::back_inner_index().

◆ u_id_ringbuffer_get_front()

int32_t u_id_ringbuffer_get_front ( struct u_id_ringbuffer uirb,
uint64_t *  out_id 
)

Get the front (least recent) of the buffer.

Parameters
uirbself pointer
[out]out_idWhere to store the front ID
Returns
the "inner" index in your array with any associated data, or negative if error (empty, etc).

References xrt::auxiliary::util::detail::RingBufferHelper::front_inner_index().

◆ u_id_ringbuffer_get_size()

uint32_t u_id_ringbuffer_get_size ( struct u_id_ringbuffer const *  uirb)

Get the number of elements in the buffer.

Parameters
uirbself pointer
Returns
the size

References xrt::auxiliary::util::detail::RingBufferHelper::size().

◆ u_id_ringbuffer_is_empty()

bool u_id_ringbuffer_is_empty ( struct u_id_ringbuffer const *  uirb)

Get whether the buffer is empty.

Parameters
uirbself pointer
Returns
true if empty

References xrt::auxiliary::util::detail::RingBufferHelper::empty().

◆ u_id_ringbuffer_lower_bound_id()

int32_t u_id_ringbuffer_lower_bound_id ( struct u_id_ringbuffer uirb,
uint64_t  search_id,
uint64_t *  out_id,
uint32_t *  out_index 
)

Find the latest element not less than the supplied ID search_id .

Assumes/depends on your maintenance of entries in ascending order. If you aren't ensuring this, use u_id_ringbuffer_find_id_unordered() instead.

(Wraps std::lower_bound)

Parameters
uirbself pointer
search_idthe ID to search for.
[out]out_idWhere to store the ID found, if successful (optional)
[out]out_indexWhere to store the ring buffer index (not the inner index) found, if successful (optional)
Returns
the "inner" index in your array with any associated data, or negative if error (empty, etc).

◆ u_id_ringbuffer_pop_back()

void u_id_ringbuffer_pop_back ( struct u_id_ringbuffer uirb)

Pop an element from the back, if any.

Parameters
uirbself pointer.

References xrt::auxiliary::util::detail::RingBufferHelper::pop_back().

◆ u_id_ringbuffer_pop_front()

void u_id_ringbuffer_pop_front ( struct u_id_ringbuffer uirb)

Pop an element from the front, if any.

Parameters
uirbself pointer.

References xrt::auxiliary::util::detail::RingBufferHelper::pop_front().

◆ u_id_ringbuffer_push_back()

int64_t u_id_ringbuffer_push_back ( struct u_id_ringbuffer uirb,
uint64_t  id 
)

Push a new element to the back.

Parameters
uirbself pointer
idThe ID to push back. It is your responsibility to make sure you insert in order if you want to use ordered methods.
Returns
the "inner" index in your array to store any associated data, or negative if error.

References xrt::auxiliary::util::detail::RingBufferHelper::push_back_location().


The documentation for this struct was generated from the following files: