Kale
Loading...
Searching...
No Matches
ParentResource.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
22
23#include <list>
24
25namespace Kale::Vulkan {
26
30 template <typename Parent> class ChildResource;
31
35 template <typename Parent> class ParentResource {
36 protected:
37
41 std::list<ChildResource<Parent>*> resources;
42
43 friend class ChildResource<Parent>;
44 public:
45
49 virtual ~ParentResource() {
51 }
52
56 void freeChildren() {
57 for (ChildResource<Parent>* resource : resources) {
58 try {
59 resource->freeResources(false);
60 }
61 catch (const std::exception& e) {
62 console.error(e.what());
63 }
64 }
65 resources.clear();
66 }
67 };
68}
69
70#endif
void error(T msg)
Definition Logger.hpp:198
std::list< ChildResource< Parent > * > resources
Logger console
Definition Logger.hpp:317