Monado OpenXR Runtime
oxr_handle_base Struct Reference

Used to hold diverse child handles and ensure orderly destruction. More...

#include <oxr/oxr_objects.h>

Inheritance diagram for oxr_handle_base:
Collaboration diagram for oxr_handle_base:

Public Member Functions

XrResult oxr_handle_destroy (struct oxr_logger *log, struct oxr_handle_base *hb)
 Destroy the handle's object, as well as all child handles recursively. More...
 

Data Fields

uint64_t debug
 Magic (per-handle-type) value for debugging. More...
 
struct oxr_handle_baseparent
 Pointer to this object's parent handle holder, if any. More...
 
struct oxr_handle_basechildren [256]
 Array of children, if any. More...
 
enum oxr_handle_state state
 Current handle state. More...
 
oxr_handle_destroyer destroy
 Destroy the object this handle refers to. More...
 

Protected Member Functions

XrResult oxr_handle_init (struct oxr_logger *log, struct oxr_handle_base *hb, uint64_t debug, oxr_handle_destroyer destroy, struct oxr_handle_base *parent)
 Initialize a handle holder, and if a parent is specified, update its child list to include this handle. More...
 

Related Functions

(Note that these are not member functions.)

typedef XrResult(* oxr_handle_destroyer) (struct oxr_logger *log, struct oxr_handle_base *hb)
 Function pointer type for a handle destruction function. More...
 
XrResult oxr_handle_allocate_and_init (struct oxr_logger *log, size_t size, uint64_t debug, oxr_handle_destroyer destroy, struct oxr_handle_base *parent, void **out)
 Allocate some memory for use as a handle, and initialize it as a handle. More...
 
#define OXR_ALLOCATE_HANDLE(LOG, OUT, DEBUG, DESTROY, PARENT)    oxr_handle_allocate_and_init(LOG, sizeof(*OUT), DEBUG, DESTROY, PARENT, (void **)&OUT)
 Allocates memory for a handle and evaluates to an XrResult. More...
 
#define OXR_ALLOCATE_HANDLE_OR_RETURN(LOG, OUT, DEBUG, DESTROY, PARENT)
 Allocate memory for a handle, returning in case of failure. More...
 
const char * oxr_handle_state_to_string (enum oxr_handle_state state)
 Returns a human-readable label for a handle state. More...
 

Detailed Description

Used to hold diverse child handles and ensure orderly destruction.

Each object referenced by an OpenXR handle should have one of these as its first element, thus "extending" this class.

Member Function Documentation

◆ oxr_handle_init()

XrResult oxr_handle_init ( struct oxr_logger log,
struct oxr_handle_base hb,
uint64_t  debug,
oxr_handle_destroyer  destroy,
struct oxr_handle_base parent 
)
protected

Initialize a handle holder, and if a parent is specified, update its child list to include this handle.

Friends And Related Function Documentation

◆ OXR_ALLOCATE_HANDLE

#define OXR_ALLOCATE_HANDLE (   LOG,
  OUT,
  DEBUG,
  DESTROY,
  PARENT 
)     oxr_handle_allocate_and_init(LOG, sizeof(*OUT), DEBUG, DESTROY, PARENT, (void **)&OUT)
related

Allocates memory for a handle and evaluates to an XrResult.

Parameters
LOGpointer to struct oxr_logger
OUTthe pointer to handle struct type you already created.
DEBUGMagic per-type debugging constant
DESTROYHandle destructor function
PARENTa parent handle, if any

Use when you want to do something other than immediately returning in case of failure. If returning immediately is OK, see OXR_ALLOCATE_HANDLE_OR_RETURN().

◆ OXR_ALLOCATE_HANDLE_OR_RETURN

#define OXR_ALLOCATE_HANDLE_OR_RETURN (   LOG,
  OUT,
  DEBUG,
  DESTROY,
  PARENT 
)
related
Value:
do { \
XrResult allocResult = OXR_ALLOCATE_HANDLE(LOG, OUT, DEBUG, DESTROY, PARENT); \
if (allocResult != XR_SUCCESS) { \
return allocResult; \
} \
} while (0)
#define OXR_ALLOCATE_HANDLE(LOG, OUT, DEBUG, DESTROY, PARENT)
Allocates memory for a handle and evaluates to an XrResult.
Definition: oxr_handle.h:68

Allocate memory for a handle, returning in case of failure.

Parameters
LOGpointer to struct oxr_logger
OUTthe pointer to handle struct type you already created.
DEBUGMagic per-type debugging constant
DESTROYHandle destructor function
PARENTa parent handle, if any

Will return an XrResult from the current function if something fails. If that's not OK, see OXR_ALLOCATE_HANDLE().

Referenced by oxr_instance::oxr_instance_create(), and oxr_space_xdev_pose_create().

◆ oxr_handle_allocate_and_init()

XrResult oxr_handle_allocate_and_init ( struct oxr_logger log,
size_t  size,
uint64_t  debug,
oxr_handle_destroyer  destroy,
struct oxr_handle_base parent,
void **  out 
)
related

Allocate some memory for use as a handle, and initialize it as a handle.

Mainly for internal use - use OXR_ALLOCATE_HANDLE instead which wraps this.

Field Documentation

◆ children

struct oxr_handle_base* oxr_handle_base::children[256]

Array of children, if any.

◆ debug

uint64_t oxr_handle_base::debug

Magic (per-handle-type) value for debugging.

◆ destroy

oxr_handle_destroyer oxr_handle_base::destroy

Destroy the object this handle refers to.

◆ parent

struct oxr_handle_base* oxr_handle_base::parent

Pointer to this object's parent handle holder, if any.

◆ state

enum oxr_handle_state oxr_handle_base::state

Current handle state.


The documentation for this struct was generated from the following files: