Monado OpenXR Runtime
Loading...
Searching...
No Matches
b_app_policy.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 Helper to implement @ref xrt_app_instance and @ref xrt_app_system.
6 * @author Beyley Cardellio <ep1cm1n10n123@gmail.com>
7 * @ingroup base
8 */
9
10#pragma once
11
12#include "xrt/xrt_app_policy.h"
13
14#include "os/os_threading.h"
15
16
17#ifdef __cplusplus
18extern "C" {
19#endif
20
21
22/*!
23 * @implements xrt_app_instance
24 */
26{
27 struct xrt_app_instance base;
28
29 //! Data for stored app systems
30 struct
31 {
32 struct os_mutex mutex;
33
34 //! Number of application systems stored
35 uint32_t count;
36 //! Capacity of the storage pointer
37 uint32_t capacity;
38 //! The storage pointer for all the application systems
41};
42
43/*!
44 * @implements xrt_app_system
45 */
47{
48 struct xrt_app_system base;
49
50 //! The parent @ref xrt_app_instance
52
53 //! The @ref xrt_system this is wrapping
55};
56
57
58/*!
59 * Create a @ref b_app_instance, a fully working @ref xrt_app_instance. Objects wishing to
60 * use @ref b_app_instance as a parent class should use @ref b_app_instance_init.
61 *
62 * @public @memberof b_app_instance
63 * @ingroup base
64 * @see b_app_instance_init
65 */
66struct b_app_instance *
68
69/*!
70 * Inits a @ref b_app_instance struct when used as a parent class, only to be used externally by the derived class.
71 * Not needed to be called if created by @ref b_app_instance_create.
72 *
73 * @protected @memberof b_app_instance
74 * @ingroup base
75 */
76bool
77b_app_instance_init(struct b_app_instance *bainst, void (*destroy_fn)(struct xrt_app_instance *));
78
79/*!
80 * Finalizes a @ref b_app_instance struct when used as a parent class, only to be used
81 * by the derived class. This will not free the @ref b_app_instance pointer itself but will
82 * free any resources created by the default implementation functions. Not
83 * needed to be called if created by @ref b_app_instance_create, instead use
84 * xrt_app_instance::destroy.
85 *
86 * @protected @memberof b_app_instance
87 * @ingroup base
88 */
89void
91
92
93/*!
94 * Inits a @ref b_app_system struct when used as a parent class, only to be used
95 * by the derived class. Not needed to be called if created by @ref b_app_instance_create_app_system.
96 *
97 * @protected @memberof b_app_system
98 * @ingroup base
99 */
100bool
101b_app_system_init(struct xrt_app_instance *xainst,
102 struct b_app_system *basys,
103 struct xrt_system *xsys,
104 void (*destroy_fn)(struct xrt_app_system *));
105
106/*!
107 * Finalizes a @ref b_app_system struct when used as a parent class, only to be used
108 * by the derived class. This will not free the @ref b_app_system pointer itself but will
109 * free any resources created by the default implementation functions. Not
110 * needed to be called if created by @ref b_app_instance_create_app_system, instead use
111 * xrt_app_system::destroy.
112 *
113 * @protected @memberof b_app_system
114 * @ingroup base
115 */
116void
117b_app_system_fini(struct b_app_system *basys);
118
119
120#ifdef __cplusplus
121}
122#endif
void b_app_instance_fini(struct b_app_instance *bainst)
Finalizes a b_app_instance struct when used as a parent class, only to be used by the derived class.
Definition b_app_policy.c:199
bool b_app_instance_init(struct b_app_instance *bainst, void(*destroy_fn)(struct xrt_app_instance *))
Inits a b_app_instance struct when used as a parent class, only to be used externally by the derived ...
Definition b_app_policy.c:187
struct b_app_instance * b_app_instance_create(void)
Create a b_app_instance, a fully working xrt_app_instance.
Definition b_app_policy.c:173
Wrapper around OS threading native functions.
Definition b_app_policy.h:26
struct xrt_app_system ** storage
The storage pointer for all the application systems.
Definition b_app_policy.h:39
struct b_app_instance::@76 app_systems
Data for stored app systems.
uint32_t capacity
Capacity of the storage pointer.
Definition b_app_policy.h:37
uint32_t count
Number of application systems stored.
Definition b_app_policy.h:35
Definition b_app_policy.h:47
struct xrt_system * xsys
The xrt_system this is wrapping.
Definition b_app_policy.h:54
struct xrt_app_instance * xainst
The parent xrt_app_instance.
Definition b_app_policy.h:51
A wrapper around a native mutex.
Definition os_threading.h:69
This interface acts as a way to store per-application policy for xrt_instance.
Definition xrt_app_policy.h:34
This interface acts as a way to store per-application policy for xrt_system.
Definition xrt_app_policy.h:120
A system is a collection of devices, policies and optionally a compositor that is organised into a ch...
Definition xrt_system.h:65
Header for application policy object.