Olympe Engine 2.0
2D Game Engine with ECS Architecture
Loading...
Searching...
No Matches
TaskExecutionBridge.h
Go to the documentation of this file.
1/**
2 * @file TaskExecutionBridge.h
3 * @brief Runtime bridge: routes live TaskRunner state to the Editor UI.
4 * @author Olympe Engine
5 * @date 2026-02-25
6 *
7 * @details
8 * TaskExecutionBridge is a lightweight mediator between the TaskSystem and the
9 * Editor layer. It registers a callback with TaskSystem::SetEditorPublishCallback
10 * and forwards the published runner state to Editor-side hooks (function
11 * pointers) that have been registered by the Editor at startup.
12 *
13 * Design goals
14 * ------------
15 * - TaskExecutionBridge lives in Source/TaskSystem/ and has zero compile-time
16 * dependency on any Editor or ImGui headers.
17 * - The Editor registers its static methods (e.g. InspectorPanel::SetDebugBlackboard
18 * and NodeGraphPanel::SetActiveDebugNode) as function-pointer hooks via Install().
19 * - Non-owning semantics: the LocalBlackboard pointer forwarded to the BB hook is
20 * valid only for the duration of the callback invocation.
21 * - Calls are guarded: if no hooks are installed the callback is a no-op.
22 *
23 * Usage (Editor startup)
24 * ----------------------
25 * @code
26 * // In WorldBridge or Editor initialization code:
27 * TaskExecutionBridge::Install(
28 * &NodeGraphPanel::SetActiveDebugNode, // BridgeSetNodeFn
29 * &InspectorPanel::SetDebugBlackboardRaw // BridgeSetBBFn
30 * );
31 * @endcode
32 *
33 * Usage (Editor shutdown)
34 * -----------------------
35 * @code
36 * TaskExecutionBridge::Uninstall();
37 * @endcode
38 *
39 * C++14 compliant - no C++17/20 features.
40 */
41
42#pragma once
43
44#include "LocalBlackboard.h"
45#include "../ECS_Entity.h"
46
47namespace Olympe {
48
49/// Callback type: receives the local node index being executed.
51
52/// Callback type: receives a non-owning pointer to the frame blackboard.
54
55/**
56 * @class TaskExecutionBridge
57 * @brief Mediator that publishes per-frame task-runner state to the Editor.
58 *
59 * @details
60 * All members are static; the class is not instantiable. This mirrors the
61 * pattern used by TaskSystem::SetEditorPublishCallback.
62 */
64{
65public:
66
67 // -----------------------------------------------------------------------
68 // Lifecycle
69 // -----------------------------------------------------------------------
70
71 /**
72 * @brief Install the bridge and register Editor-side hooks.
73 *
74 * Registers a static callback with TaskSystem::SetEditorPublishCallback
75 * and stores the provided hook functions. Safe to call multiple times;
76 * subsequent calls replace the previous hooks.
77 *
78 * @param nodeFn Called each frame with the active local node index.
79 * Pass nullptr to skip node-highlight updates.
80 * @param bbFn Called each frame with a pointer to the live blackboard.
81 * Pass nullptr to skip blackboard updates.
82 */
84
85 /**
86 * @brief Uninstall the bridge.
87 *
88 * Clears the hooks and passes nullptr to
89 * TaskSystem::SetEditorPublishCallback to disable publishing.
90 */
91 static void Uninstall();
92
93 /**
94 * @brief Returns true when the bridge is currently installed.
95 */
96 static bool IsInstalled();
97
98private:
99
100 /**
101 * @brief The actual callback registered with TaskSystem.
102 *
103 * Forwards @p nodeIndex to s_NodeFn and @p bb to s_BBFn when they are
104 * non-null. A frame-local copy of the blackboard is made before calling
105 * s_BBFn so the pointer remains valid for the duration of the call.
106 */
107 static void s_OnPublish(EntityID entity, int nodeIndex, const LocalBlackboard* bb);
108
109 /// Stored Editor-side node hook. nullptr = no-op.
111
112 /// Stored Editor-side blackboard hook. nullptr = no-op.
114
115 /// Whether the bridge is currently registered with TaskSystem.
116 static bool s_Installed;
117};
118
119} // namespace Olympe
ComponentTypeID GetComponentTypeID_Static()
Definition ECS_Entity.h:56
std::uint64_t EntityID
Definition ECS_Entity.h:21
Runtime key-value store for task graph variables.
Simple map-based blackboard for task graph runtime state.
Mediator that publishes per-frame task-runner state to the Editor.
static void s_OnPublish(EntityID entity, int nodeIndex, const LocalBlackboard *bb)
The actual callback registered with TaskSystem.
static void Uninstall()
Uninstall the bridge.
static BridgeSetNodeFn s_NodeFn
Stored Editor-side node hook. nullptr = no-op.
static bool IsInstalled()
Returns true when the bridge is currently installed.
static void Install(BridgeSetNodeFn nodeFn, BridgeSetBBFn bbFn)
Install the bridge and register Editor-side hooks.
static bool s_Installed
Whether the bridge is currently registered with TaskSystem.
static BridgeSetBBFn s_BBFn
Stored Editor-side blackboard hook. nullptr = no-op.
< Provides AssetID and INVALID_ASSET_ID
void(*)(int nodeIndex) BridgeSetNodeFn
Callback type: receives the local node index being executed.
void(*)(const LocalBlackboard *bb) BridgeSetBBFn
Callback type: receives a non-owning pointer to the frame blackboard.