FastEngine
0.9.3
A multiplayer oriented 2D engine made with Vulkan.
Loading...
Searching...
No Matches
includes
FastEngine
vulkan
C_contextAware.hpp
1
/*
2
* Copyright 2024 Guillaume Guillet
3
*
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
* you may not use this file except in compliance with the License.
6
* You may obtain a copy of the License at
7
*
8
* http://www.apache.org/licenses/LICENSE-2.0
9
*
10
* Unless required by applicable law or agreed to in writing, software
11
* distributed under the License is distributed on an "AS IS" BASIS,
12
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
* See the License for the specific language governing permissions and
14
* limitations under the License.
15
*/
16
17
#ifndef _FGE_VULKAN_C_CONTEXTAWARE_HPP_INCLUDED
18
#define _FGE_VULKAN_C_CONTEXTAWARE_HPP_INCLUDED
19
20
#include "FastEngine/fge_except.hpp"
21
22
namespace
fge::vulkan
23
{
24
25
class
Context;
26
27
class
ContextAware
28
{
29
public
:
30
explicit
constexpr
ContextAware
(
Context
const
& context) :
31
g_context{&context}
32
{}
33
constexpr
ContextAware
(
ContextAware
const
& r) =
default
;
34
constexpr
ContextAware
(
ContextAware
&& r)
noexcept
=
default
;
35
virtual
~ContextAware
() =
default
;
36
37
ContextAware
& operator=(
ContextAware
const
& r) =
delete
;
38
ContextAware
& operator=(
ContextAware
&& r)
noexcept
=
delete
;
39
40
[[nodiscard]]
constexpr
Context
const
& getContext()
const
{
return
*this->g_context; }
41
inline
void
swapContext(
Context
const
& context)
42
{
43
this->destroy();
44
this->g_context = &context;
45
}
46
47
virtual
void
destroy() = 0;
48
49
protected
:
50
inline
void
verifyContext(
ContextAware
const
& r)
const
51
{
52
if
(this->g_context != r.g_context)
53
{
54
throw
fge::Exception
(
"ContextAware objects assignment with different Context !"
);
55
}
56
}
57
58
private
:
59
Context
const
* g_context{
nullptr
};
60
};
61
62
}
// namespace fge::vulkan
63
64
#endif
//_FGE_VULKAN_C_CONTEXTAWARE_HPP_INCLUDED
fge::Exception
Definition
fge_except.hpp:28
fge::vulkan::ContextAware
Definition
C_contextAware.hpp:28
fge::vulkan::Context
Vulkan context.
Definition
C_context.hpp:70
Generated by
1.12.0