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#include "xrt/xrt_compositor.h"
14
15#include "os/os_threading.h"
16
17
18#ifdef __cplusplus
19extern "C" {
20#endif
21
22
23/*!
24 * @implements xrt_app_instance
25 */
27{
28 struct xrt_app_instance base;
29
30 //! Data for stored app systems
31 struct
32 {
33 struct os_mutex mutex;
34
35 //! Number of application systems stored
36 uint32_t count;
37 //! Capacity of the storage pointer
38 uint32_t capacity;
39 //! The storage pointer for all the application systems
42};
43
45{
46 //! This event
48 //! The next event, or NULL if no event.
50};
51
52/*!
53 * @implements xrt_app_system
54 */
56{
57 struct xrt_app_system base;
58
59 //! The parent @ref xrt_app_instance
61
62 //! The @ref xrt_system this is wrapping
64
65 struct os_mutex mutex;
66 struct xrt_recommended_view_config view_configs[XRT_VIEW_TYPE_MAX];
67 struct b_app_system_event *events;
68};
69
70
71/*!
72 * Create a @ref b_app_instance, a fully working @ref xrt_app_instance. Objects wishing to
73 * use @ref b_app_instance as a parent class should use @ref b_app_instance_init.
74 *
75 * @public @memberof b_app_instance
76 * @ingroup base
77 * @see b_app_instance_init
78 */
79struct b_app_instance *
81
82/*!
83 * Inits a @ref b_app_instance struct when used as a parent class, only to be used externally by the derived class.
84 * Not needed to be called if created by @ref b_app_instance_create.
85 *
86 * @protected @memberof b_app_instance
87 * @ingroup base
88 */
89bool
90b_app_instance_init(struct b_app_instance *bainst, void (*destroy_fn)(struct xrt_app_instance *));
91
92/*!
93 * Finalizes a @ref b_app_instance struct when used as a parent class, only to be used
94 * by the derived class. This will not free the @ref b_app_instance pointer itself but will
95 * free any resources created by the default implementation functions. Not
96 * needed to be called if created by @ref b_app_instance_create, instead use
97 * xrt_app_instance::destroy.
98 *
99 * @protected @memberof b_app_instance
100 * @ingroup base
101 */
102void
103b_app_instance_fini(struct b_app_instance *bainst);
104
105
106/*!
107 * Inits a @ref b_app_system struct when used as a parent class, only to be used
108 * by the derived class. Not needed to be called if created by @ref b_app_instance_create_app_system.
109 *
110 * @protected @memberof b_app_system
111 * @ingroup base
112 */
113bool
114b_app_system_init(struct xrt_app_instance *xainst,
115 struct b_app_system *basys,
116 struct xrt_system *xsys,
117 void (*destroy_fn)(struct xrt_app_system *));
118
119/*!
120 * Finalizes a @ref b_app_system struct when used as a parent class, only to be used
121 * by the derived class. This will not free the @ref b_app_system pointer itself but will
122 * free any resources created by the default implementation functions. Not
123 * needed to be called if created by @ref b_app_instance_create_app_system, instead use
124 * xrt_app_system::destroy.
125 *
126 * @protected @memberof b_app_system
127 * @ingroup base
128 */
129void
130b_app_system_fini(struct b_app_system *basys);
131
132
133#ifdef __cplusplus
134}
135#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:300
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:288
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:274
Wrapper around OS threading native functions.
Definition b_app_policy.h:27
struct xrt_app_system ** storage
The storage pointer for all the application systems.
Definition b_app_policy.h:40
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:38
uint32_t count
Number of application systems stored.
Definition b_app_policy.h:36
Definition b_app_policy.h:45
struct xrt_app_system_event base
This event.
Definition b_app_policy.h:47
struct b_app_system_event * next
The next event, or NULL if no event.
Definition b_app_policy.h:49
Definition b_app_policy.h:56
struct xrt_system * xsys
The xrt_system this is wrapping.
Definition b_app_policy.h:63
struct xrt_app_instance * xainst
The parent xrt_app_instance.
Definition b_app_policy.h:60
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:36
Union of all app system events, used to return multiple events through one interface.
Definition xrt_app_policy.h:145
This interface acts as a way to store per-application policy for xrt_system.
Definition xrt_app_policy.h:194
A system is a collection of devices, policies and optionally a compositor that is organised into a ch...
Definition xrt_system.h:67
Header for application policy object.
Header declaring XRT graphics interfaces.