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
44/*!
45 * @implements xrt_app_system
46 */
48{
49 struct xrt_app_system base;
50
51 //! The parent @ref xrt_app_instance
53
54 //! The @ref xrt_system this is wrapping
56
57 struct os_mutex view_config_mutex;
58 struct xrt_recommended_view_config view_configs[XRT_VIEW_TYPE_MAX];
59};
60
61
62/*!
63 * Create a @ref b_app_instance, a fully working @ref xrt_app_instance. Objects wishing to
64 * use @ref b_app_instance as a parent class should use @ref b_app_instance_init.
65 *
66 * @public @memberof b_app_instance
67 * @ingroup base
68 * @see b_app_instance_init
69 */
70struct b_app_instance *
72
73/*!
74 * Inits a @ref b_app_instance struct when used as a parent class, only to be used externally by the derived class.
75 * Not needed to be called if created by @ref b_app_instance_create.
76 *
77 * @protected @memberof b_app_instance
78 * @ingroup base
79 */
80bool
81b_app_instance_init(struct b_app_instance *bainst, void (*destroy_fn)(struct xrt_app_instance *));
82
83/*!
84 * Finalizes a @ref b_app_instance struct when used as a parent class, only to be used
85 * by the derived class. This will not free the @ref b_app_instance pointer itself but will
86 * free any resources created by the default implementation functions. Not
87 * needed to be called if created by @ref b_app_instance_create, instead use
88 * xrt_app_instance::destroy.
89 *
90 * @protected @memberof b_app_instance
91 * @ingroup base
92 */
93void
95
96
97/*!
98 * Inits a @ref b_app_system struct when used as a parent class, only to be used
99 * by the derived class. Not needed to be called if created by @ref b_app_instance_create_app_system.
100 *
101 * @protected @memberof b_app_system
102 * @ingroup base
103 */
104bool
105b_app_system_init(struct xrt_app_instance *xainst,
106 struct b_app_system *basys,
107 struct xrt_system *xsys,
108 void (*destroy_fn)(struct xrt_app_system *));
109
110/*!
111 * Finalizes a @ref b_app_system struct when used as a parent class, only to be used
112 * by the derived class. This will not free the @ref b_app_system pointer itself but will
113 * free any resources created by the default implementation functions. Not
114 * needed to be called if created by @ref b_app_instance_create_app_system, instead use
115 * xrt_app_system::destroy.
116 *
117 * @protected @memberof b_app_system
118 * @ingroup base
119 */
120void
121b_app_system_fini(struct b_app_system *basys);
122
123
124#ifdef __cplusplus
125}
126#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:236
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:224
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:210
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:48
struct xrt_system * xsys
The xrt_system this is wrapping.
Definition b_app_policy.h:55
struct xrt_app_instance * xainst
The parent xrt_app_instance.
Definition b_app_policy.h:52
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
This interface acts as a way to store per-application policy for xrt_system.
Definition xrt_app_policy.h:142
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.
Header declaring XRT graphics interfaces.