Monado OpenXR Runtime
xrt::util::DeviceBase< T, functions > Class Template Reference

Helper wrapper for xrt_device, Monado has C style inheritance where the first field is the base class. More...

#include <glue/g_device.hpp>

Public Member Functions

 DeviceBase () noexcept
 Fully resets and sets function pointers on xrt_device. More...
 
 ~DeviceBase () noexcept=default
 Destructor. More...
 
const T & derived () const noexcept
 
T & derived () noexcept
 
const xrt_devicegetXDev () const noexcept
 Gets the underlying xrt_device pointer. More...
 
xrt_devicegetXDev () noexcept
 Gets the underlying xrt_device pointer. More...
 

Static Public Member Functions

static const T * fromXDev (const xrt_device *xdev) noexcept
 Gets the pointer to the derived class from a xrt_device. More...
 
static T * fromXDev (xrt_device *xdev) noexcept
 Gets the pointer to the derived class from a xrt_device. More...
 

Detailed Description

template<class T, DeviceFunctions functions>
class xrt::util::DeviceBase< T, functions >

Helper wrapper for xrt_device, Monado has C style inheritance where the first field is the base class.

In order to safely cast the from the parent to the child class it needs to have a standard layout, it is very easy to not have that. So this class, which has standard layout, goes via itself to then using a static_cast to go to the derived class.

https://en.cppreference.com/w/cpp/types/is_standard_layout

Constructor & Destructor Documentation

◆ DeviceBase()

template<class T , DeviceFunctions functions>
xrt::util::DeviceBase< T, functions >::DeviceBase ( )
inlinenoexcept

Fully resets and sets function pointers on xrt_device.

References xrt::util::DeviceBase< T, functions >::getXDev(), and u_device_populate_function_pointers().

◆ ~DeviceBase()

template<class T , DeviceFunctions functions>
xrt::util::DeviceBase< T, functions >::~DeviceBase ( )
defaultnoexcept

Destructor.

Member Function Documentation

◆ fromXDev() [1/2]

template<class T , DeviceFunctions functions>
static const T * xrt::util::DeviceBase< T, functions >::fromXDev ( const xrt_device xdev)
inlinestaticnoexcept

Gets the pointer to the derived class from a xrt_device.

◆ fromXDev() [2/2]

template<class T , DeviceFunctions functions>
static T * xrt::util::DeviceBase< T, functions >::fromXDev ( xrt_device xdev)
inlinestaticnoexcept

Gets the pointer to the derived class from a xrt_device.

◆ getXDev() [1/2]

template<class T , DeviceFunctions functions>
const xrt_device * xrt::util::DeviceBase< T, functions >::getXDev ( ) const
inlinenoexcept

Gets the underlying xrt_device pointer.

Referenced by xrt::util::DeviceBase< T, functions >::DeviceBase().

◆ getXDev() [2/2]

template<class T , DeviceFunctions functions>
xrt_device * xrt::util::DeviceBase< T, functions >::getXDev ( )
inlinenoexcept

Gets the underlying xrt_device pointer.


The documentation for this class was generated from the following file: