Photon Engine
2.0.0-beta
A physically based renderer.
Loading...
Searching...
No Matches
sdl_interface.h
Go to the documentation of this file.
1
#pragma once
2
3
#include "
SDL/ISdlResource.h
"
4
#include "
SDL/TSdl.h
"
5
#include "
SDL/Introspect/TSdlEnum.h
"
6
7
// Base types
8
#include "
SDL/Introspect/SdlClass.h
"
9
#include "
SDL/Introspect/SdlStruct.h
"
10
#include "
SDL/Introspect/SdlFunction.h
"
11
#include "
SDL/Introspect/SdlEnum.h
"
12
13
// Enum types
14
#include "
SDL/Introspect/TSdlGeneralEnum.h
"
15
16
// Owner types
17
#include "
SDL/Introspect/TSdlOwnerClass.h
"
18
#include "
SDL/Introspect/TSdlOwnerStruct.h
"
19
20
// Field types
21
#include "
SDL/Introspect/TSdlBool.h
"
22
#include "
SDL/Introspect/TSdlInteger.h
"
23
#include "
SDL/Introspect/TSdlReal.h
"
24
#include "
SDL/Introspect/TSdlString.h
"
25
#include "
SDL/Introspect/TSdlVector2.h
"
26
#include "
SDL/Introspect/TSdlVector3.h
"
27
#include "
SDL/Introspect/TSdlVector4.h
"
28
#include "
SDL/Introspect/TSdlQuaternion.h
"
29
#include "
SDL/Introspect/TSdlRealArray.h
"
30
#include "
SDL/Introspect/TSdlVector3Array.h
"
31
#include "
SDL/Introspect/TSdlReference.h
"
32
#include "
SDL/Introspect/TSdlReferenceArray.h
"
33
#include "
SDL/Introspect/TSdlEnumField.h
"
34
#include "
SDL/Introspect/TSdlPath.h
"
35
#include "
SDL/Introspect/TSdlResourceIdentifier.h
"
36
#include "
SDL/Introspect/TSdlStructArray.h
"
37
38
// Function types
39
#include "
SDL/Introspect/TSdlMethod.h
"
40
41
#include <type_traits>
42
63
#define PH_DEFINE_SDL_CLASS(...)
/* variadic args for template types that contain commas */
\
64
\
65
using ClassType = std::remove_cv_t<__VA_ARGS__>;\
66
using OwnerType = std::remove_cv_t<typename ClassType::OwnerType>;\
67
\
68
/* A marker so we know the macro has been called. */
\
69
using SdlClassDefinitionMarker = OwnerType;\
70
\
71
inline static const ClassType* getSdlClass()\
72
{\
73
static_assert(std::is_base_of_v<::ph::ISdlResource, OwnerType>,\
74
"PH_DEFINE_SDL_CLASS() can only be defined for SDL resource.");\
75
static_assert(std::is_base_of_v<::ph::SdlClass, ClassType>,\
76
"PH_DEFINE_SDL_CLASS() must return a class derived from SdlClass.");\
77
\
78
static const ClassType sdlClass = internal_sdl_class_impl();\
79
return &sdlClass;\
80
}\
81
\
82
inline const ::ph::SdlClass* getDynamicSdlClass() const override\
83
{\
84
return getSdlClass();\
85
}\
86
\
87
inline static ClassType internal_sdl_class_impl()
88
89
#define PH_DEFINE_SDL_STRUCT(...)
/* variadic args for template types that contain commas */
\
90
\
91
using StructType = std::remove_cv_t<__VA_ARGS__>;\
92
using OwnerType = std::remove_cv_t<typename StructType::OwnerType>;\
93
\
94
/* A marker so we know the macro has been called. */
\
95
using SdlStructDefinitionMarker = OwnerType;\
96
\
97
inline static const StructType* getSdlStruct()\
98
{\
99
static_assert(std::is_base_of_v<::ph::SdlStruct, StructType>,\
100
"PH_DEFINE_SDL_STRUCT() must return a struct derived from SdlStruct.");\
101
\
102
static const StructType sdlStruct = internal_sdl_struct_impl();\
103
return &sdlStruct;\
104
}\
105
\
106
inline static StructType internal_sdl_struct_impl()
107
108
#define PH_DEFINE_SDL_FUNCTION(...)
/* variadic args for template types that contain commas */
\
109
\
110
using FunctionType = std::remove_cv_t<__VA_ARGS__>;\
111
using OwnerType = std::remove_cv_t<typename FunctionType::OwnerType>;\
112
\
113
/* A marker so we know the macro has been called. */
\
114
using SdlFunctionDefinitionMarker = OwnerType;\
115
\
116
inline static const FunctionType* getSdlFunction()\
117
{\
118
static_assert(std::is_base_of_v<::ph::SdlFunction, FunctionType>,\
119
"PH_DEFINE_SDL_FUNCTION() must return a function derived from SdlFunction.");\
120
\
121
static const FunctionType sdlFunction = internal_sdl_function_impl();\
122
return &sdlFunction;\
123
}\
124
\
125
inline static FunctionType internal_sdl_function_impl()
126
142
#define PH_DEFINE_SDL_ENUM(...)
/* variadic args for template types that contain commas */
\
143
template<>\
144
class TSdlEnum<std::remove_cv_t<typename __VA_ARGS__::EnumType>> final\
145
{\
146
public:\
147
\
148
using SdlEnumType = std::remove_cv_t<__VA_ARGS__>;\
149
using EnumType = std::remove_cv_t<typename SdlEnumType::EnumType>;\
150
\
151
static_assert(std::is_enum_v<EnumType>,\
152
"EnumType must be an enum. Currently it is not.");\
153
\
154
/* A marker so we know the macro has been called. */
\
155
using SdlEnumDefinitionMarker = EnumType;\
156
\
157
public:\
158
inline EnumType operator [] (const std::string_view entryName) const\
159
{\
160
const ::ph::SdlEnum::TEntry<EnumType> entry = getSdlEnum()->getTypedEntry(entryName);\
161
return entry.value;\
162
}\
163
\
164
inline std::string_view operator [] (const EnumType entryValue) const\
165
{\
166
const ::ph::SdlEnum::TEntry<EnumType> entry = getSdlEnum()->getTypedEntry(entryValue);\
167
return entry.name;\
168
}\
169
\
170
inline static const SdlEnumType* getSdlEnum()\
171
{\
172
static_assert(std::is_base_of_v<::ph::SdlEnum, SdlEnumType>,\
173
"PH_DEFINE_SDL_ENUM() must return an enum derived from SdlEnum.");\
174
\
175
static const SdlEnumType sdlEnum = internal_sdl_enum_impl();\
176
return &sdlEnum;\
177
}\
178
\
179
private:\
180
static SdlEnumType internal_sdl_enum_impl();\
181
};\
182
\
183
/* In-header Implementations: */
\
184
\
185
inline __VA_ARGS__ TSdlEnum<std::remove_cv_t<typename __VA_ARGS__::EnumType>>::internal_sdl_enum_impl()
ISdlResource.h
SdlClass.h
SdlEnum.h
SdlFunction.h
SdlStruct.h
TSdl.h
SDL instance helpers.
TSdlBool.h
TSdlEnum.h
TSdlEnumField.h
TSdlGeneralEnum.h
TSdlInteger.h
TSdlMethod.h
TSdlOwnerClass.h
TSdlOwnerStruct.h
TSdlPath.h
TSdlQuaternion.h
TSdlReal.h
TSdlRealArray.h
TSdlReference.h
TSdlReferenceArray.h
TSdlResourceIdentifier.h
TSdlString.h
TSdlStructArray.h
TSdlVector2.h
TSdlVector3.h
TSdlVector3Array.h
TSdlVector4.h
Source
SDL
sdl_interface.h
Generated by
1.11.0