XRTraits C++ OpenXR Utilities
APITraitsFwd.h
Go to the documentation of this file.
1 // Copyright 2018-2019, Collabora, Ltd.
2 // SPDX-License-Identifier: BSL-1.0
3 /*!
4  * @file
5  * @brief Header with forward declarations/default specializations of functions
6  * and traits defined/specialized by the generated file APITraitsImpl.h, which
7  * includes this one.
8  * @author Ryan Pavlik <ryan.pavlik@collabora.com>
9  */
10 
11 // IWYU pragma: private, include "xrtraits/APITraits.h"
12 // IWYU pragma: friend "APITraitsImpl\.h"
13 
14 #pragma once
15 
16 // Internal Includes
17 // - none
18 
19 // Library Includes
20 #include <openxr/openxr.h>
21 
22 // Standard Includes
23 #include <cstddef>
24 
25 namespace xrtraits {
26 namespace traits {
27 
28 #ifndef XRTRAITS_DOXYGEN
29  namespace detail {
30  /*! Declaration/default implementation of the actual trait
31  * used by is_xr_tagged_type_v - specializations are generated.
32  */
33  template <typename T>
34  constexpr bool is_xr_tagged_type_impl_v = false;
35 
36  /*! Is true for types that are XR tagged types and have a
37  * defined enum value (type tag) for their type member, false
38  * otherwise.
39  *
40  * Not all types with is_xr_tagged_type_v have their own type
41  * tag: some (that primarily serve as "abstract" types, often
42  * named `...BaseHeader`) do not but are intended primarily as
43  * ways to pass references to concrete types that do have a
44  * defined type tag.
45  */
46  template <typename T>
47  constexpr bool has_xr_type_tag_impl_v = false;
48 
49  /*! For types that are XR tagged types and have a defined enum
50  * value (type tag) for their type member, defines a
51  * XrStructureType.
52  *
53  * Default value is nullptr in order to break if it shouldn't
54  * be used with a given type.
55  */
56  template <typename T>
57  constexpr std::nullptr_t xr_type_tag_impl_v = nullptr;
58 
59  /*! A string literal with the type name for all known XR
60  * structure types.
61  */
62  template <typename T>
63  constexpr std::nullptr_t xr_type_name_impl_v = nullptr;
64 
65  /*! A string literal with the type name for all XR types with
66  * known tags.
67  */
68  template <XrStructureType Tag>
69  constexpr std::nullptr_t xr_type_name_by_tag_impl_v = nullptr;
70 
71  } // namespace detail
72 
73 #endif // !XRTRAITS_DOXYGEN
74 
75  /*! A struct template to wrap a type, to be able to pass it as
76  * an argument.
77  */
78  template <typename T> struct TypeWrapper
79  {
80  //! The type that we're wrapping.
81  using type = T;
82 
83  // Default constructor, constexpr to permit usage in constexpr
84  // functions.
85  constexpr TypeWrapper() = default;
86  };
87 
88  /*! Calls your functor with a TypeWrapper<T> argument, where T is the
89  * static type matching the enum value.
90  *
91  * If the enum value is not recognized, your functor will not be called.
92  */
93  template <typename F>
94  constexpr void typeDispatch(XrStructureType t, F&& f);
95 } // namespace traits
96 } // namespace xrtraits
T type
The type that we&#39;re wrapping.
Definition: APITraitsFwd.h:81
Main namespace for these C++ OpenXR utilities.
Definition: GetChained.h:26
Definition: APITraitsFwd.h:78
constexpr void typeDispatch(XrStructureType t, F &&f)