Monado OpenXR Runtime
|
Public Member Functions | |
u_id_ringbuffer (uint32_t capacity_) | |
struct u_id_ringbuffer * | u_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 |
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.
capacity |
void u_id_ringbuffer_destroy | ( | struct u_id_ringbuffer ** | ptr_to_uirb | ) |
Destroy an ID ring buffer.
Does null checks.
ptr_to_uirb | Address of your ring buffer pointer. Will be set to zero. |
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.
uirb | self pointer | |
search_id | the ID to search for. | |
[out] | out_id | Where to store the ID found, if successful (optional) |
[out] | out_index | Where to store the ring buffer index (not the inner index) found, if successful (optional) |
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
uirb | self pointer | |
age | the distance from the back (0 is the same as back, 1 is previous, etc) | |
[out] | out_id | Where to store the ID, if successful (optional) |
References xrt::auxiliary::util::detail::RingBufferHelper::age_to_inner_index().
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.
uirb | self pointer | |
age | the distance from the back (0 is the same as back, 1 is previous, etc) | |
[out] | out_id | Where to store the ID, if successful (optional) |
References xrt::auxiliary::util::detail::RingBufferHelper::clamped_age_to_inner_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.
uirb | self pointer | |
index | the distance from the front (0 is the same as front, 1 is newer, etc) | |
[out] | out_id | Where to store the ID, if successful (optional) |
References xrt::auxiliary::util::detail::RingBufferHelper::index_to_inner_index().
int32_t u_id_ringbuffer_get_back | ( | struct u_id_ringbuffer * | uirb, |
uint64_t * | out_id | ||
) |
Get the back (most recent) of the buffer.
uirb | self pointer | |
[out] | out_id | Where to store the back ID |
References xrt::auxiliary::util::detail::RingBufferHelper::back_inner_index().
int32_t u_id_ringbuffer_get_front | ( | struct u_id_ringbuffer * | uirb, |
uint64_t * | out_id | ||
) |
Get the front (least recent) of the buffer.
uirb | self pointer | |
[out] | out_id | Where to store the front ID |
References xrt::auxiliary::util::detail::RingBufferHelper::front_inner_index().
uint32_t u_id_ringbuffer_get_size | ( | struct u_id_ringbuffer const * | uirb | ) |
Get the number of elements in the buffer.
uirb | self pointer |
References xrt::auxiliary::util::detail::RingBufferHelper::size().
bool u_id_ringbuffer_is_empty | ( | struct u_id_ringbuffer const * | uirb | ) |
Get whether the buffer is empty.
uirb | self pointer |
References xrt::auxiliary::util::detail::RingBufferHelper::empty().
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
)
uirb | self pointer | |
search_id | the ID to search for. | |
[out] | out_id | Where to store the ID found, if successful (optional) |
[out] | out_index | Where to store the ring buffer index (not the inner index) found, if successful (optional) |
void u_id_ringbuffer_pop_back | ( | struct u_id_ringbuffer * | uirb | ) |
Pop an element from the back, if any.
uirb | self pointer. |
References xrt::auxiliary::util::detail::RingBufferHelper::pop_back().
void u_id_ringbuffer_pop_front | ( | struct u_id_ringbuffer * | uirb | ) |
Pop an element from the front, if any.
uirb | self pointer. |
References xrt::auxiliary::util::detail::RingBufferHelper::pop_front().
int64_t u_id_ringbuffer_push_back | ( | struct u_id_ringbuffer * | uirb, |
uint64_t | id | ||
) |
Push a new element to the back.
uirb | self pointer |
id | The ID to push back. It is your responsibility to make sure you insert in order if you want to use ordered methods. |
References xrt::auxiliary::util::detail::RingBufferHelper::push_back_location().