Monado OpenXR Runtime
Loading...
Searching...
No Matches
oxr_handle_array.h
Go to the documentation of this file.
1// Copyright 2026, Beyley Cardellio
2// SPDX-License-Identifier: BSL-1.0
3/*!
4 * @file
5 * @brief A dynamic array of handles.
6 * @author Beyley Cardellio <ep1cm1n10n123@gmail.com>
7 * @ingroup oxr_main
8 */
9
10#pragma once
11
12#include "os/os_threading.h"
13
14
15struct oxr_handle_base;
16
17/*!
18 * Manages an array of handles, does not have a init function but must be zero initialized where it is declared.
19 */
21{
22 struct os_mutex mutex;
23
24 struct oxr_handle_base **handles;
25 uint32_t count;
26 uint32_t capacity;
27#ifndef NDEBUG
28 bool init;
29#endif
30};
31
32/*!
33 * Initializes the array, must be called before adding handles to it.
34 */
35XrResult
36oxr_handle_array_init(struct oxr_logger *log, struct oxr_handle_array *array);
37
38/*!
39 * Destroys all handles in the array, and the array itself.
40 */
41XrResult
42oxr_handle_array_destroy(struct oxr_logger *log, struct oxr_handle_array *array, int level);
43
44/*!
45 * Adds a handle to the array.
46 */
47bool
48oxr_handle_array_add(struct oxr_handle_array *array, struct oxr_handle_base *handle);
49
50/*!
51 * Removes the handle at the given index from the array, shifting all later handles down by one.
52 */
53bool
54oxr_handle_array_remove(struct oxr_handle_array *array, uint32_t index);
Wrapper around OS threading native functions.
XrResult oxr_handle_array_init(struct oxr_logger *log, struct oxr_handle_array *array)
Initializes the array, must be called before adding handles to it.
Definition oxr_handle_array.c:22
XrResult oxr_handle_array_destroy(struct oxr_logger *log, struct oxr_handle_array *array, int level)
Destroys all handles in the array, and the array itself.
Definition oxr_handle_array.c:49
bool oxr_handle_array_add(struct oxr_handle_array *array, struct oxr_handle_base *handle)
Adds a handle to the array.
Definition oxr_handle_array.c:84
bool oxr_handle_array_remove(struct oxr_handle_array *array, uint32_t index)
Removes the handle at the given index from the array, shifting all later handles down by one.
Definition oxr_handle_array.c:118
A wrapper around a native mutex.
Definition os_threading.h:69
Manages an array of handles, does not have a init function but must be zero initialized where it is d...
Definition oxr_handle_array.h:21
A single OpenXR handle, which is a child of a parent handle holder, if any.
Definition oxr_handle_base.h:62
Logger struct that lives on the stack, one for each call client call.
Definition oxr_logger.h:44