Photon Editor Library 2.0.0-beta
A physically based renderer.
Loading...
Searching...
No Matches
System.h
Go to the documentation of this file.
1#pragma once
2
3#include "Render/Scene.h"
7
8#include <Common/assertion.h>
9#include <Utility/INoCopyAndMove.h>
10#include <Utility/TUniquePtrVector.h>
11#include <Utility/Concurrent/TSPSCExecutor.h>
12#include <Utility/TSpan.h>
13
14#include <utility>
15#include <cstddef>
16#include <functional>
17#include <memory>
18#include <vector>
19
20namespace ph::editor::ghi { class GraphicsContext; }
21
22namespace ph::editor::render
23{
24
25class System final : private INoCopyAndMove
26{
27public:
28 using FileReadingWork = std::function<void(void)>;
29
31
32 explicit System(ghi::GraphicsContext& graphicsCtx);
33 ~System();
34
35 void addScene(std::unique_ptr<Scene> scene);
36 void removeScene(Scene* scene);
37 TSpan<Scene*> getScenes();
38 TSpan<Scene*> getRemovingScenes();
39 TSpan<Scene*> getRemovedScenes();
40
45
46 void addQuery(Query query);
48
49private:
50 friend class SystemController;
51
52 void waitAllFileReadingWorks();
53 void processQueries();
54 void clearRemovingScenes();
55 void clearRemovedScenes();
56
57private:
58 ghi::GraphicsContext& m_graphicsCtx;
59
60 TUniquePtrVector<Scene> m_sceneStorage;
61 std::vector<Scene*> m_scenes;
62 std::vector<Scene*> m_removingScenes;
63 std::vector<Scene*> m_removedScenes;
64
65 TSPSCExecutor<FileReadingWork> m_fileReadingThread;
67};
68
69inline TSpan<Scene*> System::getScenes()
70{
71 return m_scenes;
72}
73
74inline TSpan<Scene*> System::getRemovingScenes()
75{
76 return m_removingScenes;
77}
78
79inline TSpan<Scene*> System::getRemovedScenes()
80{
81 return m_removedScenes;
82}
83
84inline void System::addQuery(Query query)
85{
86 m_queryManager.addQuery(std::move(query));
87}
88
90{
91 return m_graphicsCtx;
92}
93
94class SystemController final : private INoCopyAndMove
95{
96public:
97 explicit SystemController(System& sys)
98 : m_sys(sys)
99 {}
100
102 {
103 m_sys.waitAllFileReadingWorks();
104 }
105
107 {
108 m_sys.processQueries();
109 }
110
112 {
113 m_sys.clearRemovingScenes();
114 }
115
117 {
118 m_sys.clearRemovedScenes();
119 }
120
122 {
123 return &m_sys;
124 }
125
126private:
127 System& m_sys;
128};
129
130}// end namespace ph::editor::render
Definition RenderThreadUpdateContext.h:11
Definition TConcurrentQueryManager.h:21
Definition TQuery.h:29
Definition GraphicsContext.h:24
A scene for the editor renderer only.
Definition Scene.h:34
void clearRemovingScenes()
Definition System.h:111
void clearRemovedScenes()
Definition System.h:116
void waitAllFileReadingWorks()
Definition System.h:101
System * operator->()
Definition System.h:121
SystemController(System &sys)
Definition System.h:97
void processQueries()
Definition System.h:106
Definition System.h:26
~System()
Definition System.cpp:63
System(ghi::GraphicsContext &graphicsCtx)
Definition System.cpp:31
TSpan< Scene * > getRemovedScenes()
Definition System.h:79
TSpan< Scene * > getScenes()
Definition System.h:69
std::function< void(void)> FileReadingWork
Definition System.h:28
void addScene(std::unique_ptr< Scene > scene)
Definition System.cpp:74
void addFileReadingWork(FileReadingWork work)
Add a file reading work, which may run on another thread. Behavior controlled by config::ENABLE_RENDE...
Definition System.cpp:97
void removeScene(Scene *scene)
Definition System.cpp:86
RenderThreadUpdateContext updateCtx
Definition System.h:30
void addQuery(Query query)
Definition System.h:84
TSpan< Scene * > getRemovingScenes()
Definition System.h:74
ghi::GraphicsContext & getGraphicsContext()
Definition System.h:89
Definition PlatformDisplay.h:13
Definition DesignerObject.h:19