MGL(Win32)
読み取り中…
検索中…
一致する文字列を見つけられません
mgl_task_default_task_node.h
1// SPDX-License-Identifier: Zlib
2/* ------------------------------------------------------------------------- */
9/* ------------------------------------------------------------------------- */
10
11#ifndef INCGUARD_MGL_TASK_DEFAULT_H_1622707431
12#define INCGUARD_MGL_TASK_DEFAULT_H_1622707431
13
14#include <type_traits>
15
17
18namespace MGL::Task
19{
21template <typename TaskIDType = Identifier, typename EventIDType = EventIdentifier>
22class DefaultTaskNode : public Node
23{
24private:
26 enum class Stage : uint8_t
27 {
28 Update,
29 Render,
30 };
31
32public:
33 /* ------------------------------------------------------------------------- */
39 /* ------------------------------------------------------------------------- */
40 static InitializeDescriptor GetInitializeDescriptor(int32_t parallelExecuteCount = -1) noexcept
41 {
42 InitializeDescriptor descriptor;
43 descriptor.stageSettings =
44 {
45 {ExecuteStage(Stage::Update), ExecuteMode::ParallelizableUpdate},
46 {ExecuteStage(Stage::Render), ExecuteMode::RenderUpdate},
47 };
48 descriptor.parallelExecuteCount = parallelExecuteCount;
49
50 return descriptor;
51 }
52
53 /* ------------------------------------------------------------------------- */
58 /* ------------------------------------------------------------------------- */
59 constexpr DefaultTaskNode(TaskIDType identifier) noexcept
60 : MGL::Task::Node(Identifier(identifier))
61 {}
62
63 ~DefaultTaskNode() noexcept override = default;
64
65
66protected:
67 /* ------------------------------------------------------------------------- */
71 /* ------------------------------------------------------------------------- */
72 virtual void OnUpdate() noexcept {}
73
74 /* ------------------------------------------------------------------------- */
78 /* ------------------------------------------------------------------------- */
79 virtual void OnRender() noexcept {}
80
81 /* ------------------------------------------------------------------------- */
87 /* ------------------------------------------------------------------------- */
88 virtual void OnEvent(EventIDType event, void *argument) noexcept
89 {
90 (void)event;
91 (void)argument;
92 }
93
94private:
95 /* ------------------------------------------------------------------------- */
100 /* ------------------------------------------------------------------------- */
101 void OnExecute(ExecuteStage stage) noexcept final
102 {
103 switch (Stage{stage})
104 {
105 // 更新処理
106 case Stage::Update:
107 OnUpdate();
108 break;
109
110 // 描画処理
111 case Stage::Render:
112 OnRender();
113 break;
114 }
115 }
116
117 /* ------------------------------------------------------------------------- */
123 /* ------------------------------------------------------------------------- */
124 void OnReceiveTaskEvent(EventIdentifier eventID, void *argument) noexcept final
125 {
126 OnEvent(EventIDType(eventID), argument);
127 }
128};
129} // namespace MGL::Task
130#endif // INCGUARD_MGL_TASK_DEFAULT_H_1622707431
131
132// vim: et ts=4 sw=4 sts=4
デフォルトの実行ステージ設定に対応したタスク
Definition mgl_task_default_task_node.h:23
virtual void OnRender() noexcept
描画処理
Definition mgl_task_default_task_node.h:79
virtual void OnUpdate() noexcept
更新処理
Definition mgl_task_default_task_node.h:72
static InitializeDescriptor GetInitializeDescriptor(int32_t parallelExecuteCount=-1) noexcept
このタスク用の初期化記述子を取得
Definition mgl_task_default_task_node.h:40
constexpr DefaultTaskNode(TaskIDType identifier) noexcept
コンストラクタ
Definition mgl_task_default_task_node.h:59
virtual void OnEvent(EventIDType event, void *argument) noexcept
イベント受信処理
Definition mgl_task_default_task_node.h:88
タスクノード
Definition mgl_task_node.h:20
uint8_t ExecuteStage
実行ステージ
Definition mgl_task_defs.h:68
MGL タスクノード
初期化記述子
Definition mgl_task_defs.h:99