Olympe Engine 2.0
2D Game Engine with ECS Architecture
Loading...
Searching...
No Matches
GraphValidationPanel.h
Go to the documentation of this file.
1/**
2 * @file GraphValidationPanel.h
3 * @brief VS graph validation with clickable error list (Phase 7).
4 * @author Olympe Engine
5 * @date 2026-03-10
6 *
7 * @details
8 * GraphValidationPanel inspects a TaskGraphTemplate and produces a list of
9 * GraphValidationError items covering:
10 * - Dead-end nodes (exec-output pins with no outgoing connection)
11 * - SubGraph nodes with an empty SubGraphPath
12 * - Cycles detected via DFS over ExecConnections
13 *
14 * UI code calls Validate(), iterates GetErrors(), and calls OnErrorClick()
15 * when the user clicks an entry so the canvas can pan to the offending node.
16 *
17 * C++14 compliant — no std::optional, structured bindings, std::filesystem.
18 */
19
20#pragma once
21
22#include <string>
23#include <vector>
24
25#include "../TaskSystem/TaskGraphTemplate.h"
26
27namespace Olympe {
28
29// ============================================================================
30// Supporting types
31// ============================================================================
32
33/**
34 * @enum ValidationSeverity
35 * @brief Indicates how serious a validation finding is.
36 */
38 Warning, ///< Informational; graph may still execute
39 Error, ///< Likely to cause incorrect behaviour
40 Critical ///< Graph cannot be executed
41};
42
43/**
44 * @struct GraphValidationError
45 * @brief A single validation finding.
46 */
48 int nodeId; ///< Offending node ID; -1 for graph-level errors
49 std::string message;
51};
52
53// ============================================================================
54// GraphValidationPanel
55// ============================================================================
56
57/**
58 * @class GraphValidationPanel
59 * @brief Singleton that validates a TaskGraphTemplate and tracks selected node.
60 *
61 * Typical usage:
62 * @code
63 * auto& panel = GraphValidationPanel::Get();
64 * panel.Validate(myGraph);
65 * if (panel.HasErrors())
66 * {
67 * for (const auto& err : panel.GetErrors())
68 * SYSTEM_LOG << err.message << std::endl;
69 * }
70 * @endcode
71 */
73public:
74
75 // -----------------------------------------------------------------------
76 // Singleton access
77 // -----------------------------------------------------------------------
78
79 /**
80 * @brief Returns the single shared instance.
81 */
82 static GraphValidationPanel& Get();
83
84 // -----------------------------------------------------------------------
85 // Validation
86 // -----------------------------------------------------------------------
87
88 /**
89 * @brief Clears previous results and validates @p graph.
90 */
91 void Validate(const TaskGraphTemplate& graph);
92
93 /**
94 * @brief Returns the current list of validation findings.
95 */
96 const std::vector<GraphValidationError>& GetErrors() const;
97
98 /**
99 * @brief Returns true if there are any findings of any severity.
100 */
101 bool HasErrors() const;
102
103 /**
104 * @brief Returns true if any finding has severity Critical.
105 */
106 bool HasCriticalErrors() const;
107
108 /**
109 * @brief Clears all findings and resets the selected node.
110 */
111 void Clear();
112
113 // -----------------------------------------------------------------------
114 // Navigation
115 // -----------------------------------------------------------------------
116
117 /**
118 * @brief Records @p nodeId as the currently selected node.
119 * UI can read this to pan the canvas to the offending node.
120 */
121 void OnErrorClick(int nodeId);
122
123 /**
124 * @brief Returns the node ID set by the most recent OnErrorClick() call
125 * (-1 if none).
126 */
127 int GetSelectedNodeId() const;
128
129private:
130
132
133 // ---- Individual validation passes ----
134
135 /**
136 * @brief Flags nodes whose exec-output pins have no outgoing connection.
137 */
139
140 /**
141 * @brief Flags SubGraph nodes that have no SubGraphPath set.
142 */
144
145 /**
146 * @brief Flags cycles detected by DFS over ExecConnections.
147 */
149
150 // ---- Helpers ----
151
152 void AddError(int nodeId, const std::string& message, ValidationSeverity severity);
153
154 std::vector<GraphValidationError> m_Errors;
156};
157
158} // namespace Olympe
ComponentTypeID GetComponentTypeID_Static()
Definition ECS_Entity.h:56
Singleton that validates a TaskGraphTemplate and tracks selected node.
void CheckCycles(const TaskGraphTemplate &graph)
Flags cycles detected by DFS over ExecConnections.
const std::vector< GraphValidationError > & GetErrors() const
Returns the current list of validation findings.
int GetSelectedNodeId() const
Returns the node ID set by the most recent OnErrorClick() call (-1 if none).
void Validate(const TaskGraphTemplate &graph)
Clears previous results and validates graph.
bool HasErrors() const
Returns true if there are any findings of any severity.
void CheckMissingConnections(const TaskGraphTemplate &graph)
Flags SubGraph nodes that have no SubGraphPath set.
void AddError(int nodeId, const std::string &message, ValidationSeverity severity)
void CheckDeadEnds(const TaskGraphTemplate &graph)
Flags nodes whose exec-output pins have no outgoing connection.
bool HasCriticalErrors() const
Returns true if any finding has severity Critical.
std::vector< GraphValidationError > m_Errors
static GraphValidationPanel & Get()
Returns the single shared instance.
void Clear()
Clears all findings and resets the selected node.
void OnErrorClick(int nodeId)
Records nodeId as the currently selected node.
Immutable, shareable task graph asset.
< Provides AssetID and INVALID_ASSET_ID
ValidationSeverity
Indicates how serious a validation finding is.
A single validation finding.
int nodeId
Offending node ID; -1 for graph-level errors.