Photon Engine 2.0.0-beta
A physically based renderer.
Loading...
Searching...
No Matches
SdlDependencyResolver.h
Go to the documentation of this file.
1#pragma once
2
3#include "SDL/sdl_fwd.h"
4#include "Utility/TSpan.h"
5
6#include <string>
7#include <string_view>
8#include <unordered_map>
9#include <vector>
10#include <cstddef>
11#include <queue>
12#include <optional>
13
14namespace ph
15{
16
21{
22public:
24
30 void analyze(
32 TSpanView<std::string> resourceNames = {});
33
38 const ISdlResource* next();
39
43 std::string_view getResourceName(const ISdlResource* resource) const;
44
45private:
46 struct ResourceInfo
47 {
48 const ISdlResource* resource;
49 std::string name;
50
51 inline ResourceInfo() :
52 resource(nullptr), name()
53 {}
54 };
55
56 std::vector<ResourceInfo> m_resourceInfos;
57 std::queue<const ISdlResource*> m_queuedResources;
58 std::unordered_map<const ISdlResource*, std::size_t> m_resourceToInfoIndex;
59
60 void calcDispatchOrderFromTopologicalSort();
61 std::optional<std::size_t> getResourceInfoIdx(const ISdlResource* resource) const;
62};
63
64}// end namespace ph
Interface for all SDL resource.
Definition ISdlResource.h:22
Resolves dependency between SDL resources and provides a valid initialization order....
Definition SdlDependencyResolver.h:21
SdlDependencyResolver()
Definition SdlDependencyResolver.cpp:15
std::string_view getResourceName(const ISdlResource *resource) const
Get resource name by resource pointer. Only valid for the resources in the last analyze() call....
Definition SdlDependencyResolver.cpp:74
void analyze(TSpanView< const ISdlResource * > resources, TSpanView< std::string > resourceNames={})
Submit resources and start to resolve their dependencies. The containers for input do not need to be ...
Definition SdlDependencyResolver.cpp:21
const ISdlResource * next()
Get a resource from the analyzed scene with a valid dependency ordering.
Definition SdlDependencyResolver.cpp:62
The root for all renderer implementations.
Definition EEngineProject.h:6
std::span< const T, EXTENT > TSpanView
Same as TSpan, except that the objects are const-qualified. Note that for pointer types,...
Definition TSpan.h:19