Kale
Loading...
Searching...
No Matches
src
Kale
Vulkan
ChildResource
ChildResource.hpp
Go to the documentation of this file.
1
/*
2
Copyright 2022 Rishi Challa
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
#pragma once
18
19
#ifdef KALE_VULKAN
20
21
#include <algorithm>
22
23
namespace
Kale::Vulkan
{
24
28
template
<
typename
Parent>
class
ParentResource;
29
33
template
<
typename
Parent>
class
ChildResource
{
34
protected
:
35
40
ChildResource
() {
41
// Empty Body
42
}
43
48
ChildResource
(Parent& parent) :
parentPtr
(&parent) {
49
parent.resources.push_back(
this
);
50
}
51
56
virtual
void
init
(Parent& parent) {
57
parentPtr
= &parent;
58
if
(std::find(parent.resources.begin(), parent.resources.end(),
this
) == parent.resources.end())
59
parent.resources.push_back(
this
);
60
}
61
65
~ChildResource
() {
66
freeResources
();
67
}
68
72
Parent*
parentPtr
=
nullptr
;
73
74
friend
class
ParentResource
<Parent>;
75
76
public
:
77
82
virtual
void
freeResources
(
bool
remove =
true
) {
83
if
(!remove ||
parentPtr
==
nullptr
)
return
;
84
parentPtr
->resources.remove(
this
);
85
}
86
};
87
}
88
89
#endif
Kale::Vulkan::ChildResource
Definition
ChildResource.hpp:33
Kale::Vulkan::ChildResource::freeResources
virtual void freeResources(bool remove=true)
Definition
ChildResource.hpp:82
Kale::Vulkan::ChildResource::parentPtr
Parent * parentPtr
Definition
ChildResource.hpp:72
Kale::Vulkan::ChildResource::ChildResource
ChildResource(Parent &parent)
Definition
ChildResource.hpp:48
Kale::Vulkan::ChildResource::ChildResource
ChildResource()
Definition
ChildResource.hpp:40
Kale::Vulkan::ChildResource::~ChildResource
~ChildResource()
Definition
ChildResource.hpp:65
Kale::Vulkan::ChildResource::init
virtual void init(Parent &parent)
Definition
ChildResource.hpp:56
Kale::Vulkan::ParentResource
Definition
ParentResource.hpp:35
Kale::Vulkan
Definition
Window.hpp:42
Generated on Tue Mar 12 2024 00:05:56 for Kale by
1.10.0