Photon Engine 2.0.0-beta
A physically based renderer.
Loading...
Searching...
No Matches
TSdlAnyInstance.h
Go to the documentation of this file.
1#pragma once
2
3#include "SDL/sdl_fwd.h"
4
5#include <variant>
6#include <type_traits>
7
8namespace ph
9{
10
18template<bool IS_CONST>
20{
21public:
23
24 TSdlAnyInstance(std::nullptr_t target);
25
29 template<typename T>
30 TSdlAnyInstance(T* target);
31
32 template<typename T>
33 auto* get() const;
34
35 const SdlClass* getClass() const;
36 const SdlStruct* getStruct() const;
37 const SdlFunction* getFunction() const;
38
39 bool isClass() const;
40 bool isStruct() const;
41 bool isFunction() const;
42
43 const ISdlInstantiable* getInstantiable() const;
44
45 operator bool () const;
46
47private:
48 using ClassInstanceType = std::conditional_t<IS_CONST, const ISdlResource, ISdlResource>;
49 using StructInstanceType = std::conditional_t<IS_CONST, const void, void>;
50
51 using InstanceType = std::variant<
52 std::monostate,
53 ClassInstanceType*,
54 StructInstanceType*>;
55
56 using MetaType = std::variant<
57 std::monostate,
58 const SdlClass*,
59 const SdlStruct*,
60 const SdlFunction*>;
61
62 InstanceType m_instance;
63 MetaType m_meta;
64};
65
66}// end namespace ph
67
Definition ISdlInstantiable.h:12
Definition SdlClass.h:25
Definition SdlFunction.h:18
Definition SdlStruct.h:25
References a SDL object. This is a lightweight utility for referencing SDL objects....
Definition TSdlAnyInstance.h:20
bool isStruct() const
Definition TSdlAnyInstance.ipp:156
const SdlClass * getClass() const
Definition TSdlAnyInstance.ipp:129
const ISdlInstantiable * getInstantiable() const
Definition TSdlAnyInstance.ipp:168
const SdlStruct * getStruct() const
Definition TSdlAnyInstance.ipp:136
bool isFunction() const
Definition TSdlAnyInstance.ipp:162
TSdlAnyInstance()
Definition TSdlAnyInstance.ipp:20
bool isClass() const
Definition TSdlAnyInstance.ipp:150
const SdlFunction * getFunction() const
Definition TSdlAnyInstance.ipp:143
auto * get() const
Definition TSdlAnyInstance.ipp:82
The root for all renderer implementations.
Definition EEngineProject.h:6