Olympe Engine 2.0
2D Game Engine with ECS Architecture
Loading...
Searching...
No Matches
NodeValidator.h
Go to the documentation of this file.
1/**
2 * @file NodeValidator.h
3 * @brief Real-time node and graph validation (Phase 9).
4 * @author Olympe Engine
5 * @date 2026-03-09
6 *
7 * @details
8 * NodeValidator provides static validation methods that inspect a
9 * TaskGraphTemplate and produce a list of ValidationMessage items.
10 *
11 * Three validation passes are available:
12 * - CheckUnconnectedNodes : nodes with no exec-output connections
13 * - CheckMissingSubGraphPaths: SubGraph nodes with an empty SubGraphPath
14 * - CheckInfiniteLoops : DFS cycle detection over ExecConnections
15 *
16 * The validator has no state and no ImGui dependency.
17 *
18 * C++14 compliant — no std::optional, structured bindings, std::filesystem.
19 */
20
21#pragma once
22
23#include <string>
24#include <vector>
25
26#include "../TaskSystem/TaskGraphTemplate.h"
27
28namespace Olympe {
29
30// ============================================================================
31// Supporting types
32// ============================================================================
33
34/**
35 * @enum NVSeverity
36 * @brief Indicates how serious a NodeValidator finding is.
37 *
38 * Named NVSeverity to avoid clashing with ValidationSeverity in
39 * GraphValidationPanel.h which is already in namespace Olympe.
40 */
41enum class NVSeverity {
42 Info, ///< Informational; no action required
43 Warning, ///< May cause unexpected behaviour
44 Error ///< Will prevent correct execution
45};
46
47/**
48 * @struct ValidationMessage
49 * @brief A single finding produced by NodeValidator.
50 */
52 int nodeId = -1; ///< Offending node ID; -1 for graph-level messages
54 std::string message;
55 std::string hint; ///< Optional suggestion to fix the issue
56};
57
58// ============================================================================
59// NodeValidator
60// ============================================================================
61
62/**
63 * @class NodeValidator
64 * @brief Static-only validator for TaskGraphTemplate instances.
65 *
66 * Typical usage:
67 * @code
68 * auto msgs = NodeValidator::ValidateGraph(&myGraph);
69 * for (const auto& m : msgs)
70 * SYSTEM_LOG << m.message << std::endl;
71 * @endcode
72 */
74public:
75
76 /**
77 * @brief Validates every node in the graph and returns all findings.
78 * @param graph Non-null pointer to the template to validate.
79 * @return List of ValidationMessage items (may be empty if graph is valid).
80 */
81 static std::vector<ValidationMessage> ValidateGraph(const TaskGraphTemplate* graph);
82
83 /**
84 * @brief Validates a single node definition.
85 * @param node Non-null pointer to the node to validate.
86 * @return List of ValidationMessage items for that node.
87 */
88 static std::vector<ValidationMessage> ValidateNode(const TaskNodeDefinition* node);
89
90private:
91
92 /**
93 * @brief Flags non-EntryPoint/ExitPoint nodes with no outgoing exec connections.
94 */
96 std::vector<ValidationMessage>& messages);
97
98 /**
99 * @brief Flags SubGraph nodes that have an empty SubGraphPath.
100 */
102 std::vector<ValidationMessage>& messages);
103
104 /**
105 * @brief Flags cycles detected via DFS over ExecPinConnections.
106 */
107 static void CheckInfiniteLoops(const TaskGraphTemplate* graph,
108 std::vector<ValidationMessage>& messages);
109
110 // Utility: add a message to the list
111 static void AddMessage(std::vector<ValidationMessage>& messages,
112 int nodeId,
113 NVSeverity severity,
114 const std::string& msg,
115 const std::string& hint = "");
116};
117
118} // namespace Olympe
ComponentTypeID GetComponentTypeID_Static()
Definition ECS_Entity.h:56
Static-only validator for TaskGraphTemplate instances.
static void AddMessage(std::vector< ValidationMessage > &messages, int nodeId, NVSeverity severity, const std::string &msg, const std::string &hint="")
static void CheckUnconnectedNodes(const TaskGraphTemplate *graph, std::vector< ValidationMessage > &messages)
Flags non-EntryPoint/ExitPoint nodes with no outgoing exec connections.
static std::vector< ValidationMessage > ValidateNode(const TaskNodeDefinition *node)
Validates a single node definition.
static void CheckInfiniteLoops(const TaskGraphTemplate *graph, std::vector< ValidationMessage > &messages)
Flags cycles detected via DFS over ExecPinConnections.
static void CheckMissingSubGraphPaths(const TaskGraphTemplate *graph, std::vector< ValidationMessage > &messages)
Flags SubGraph nodes that have an empty SubGraphPath.
static std::vector< ValidationMessage > ValidateGraph(const TaskGraphTemplate *graph)
Validates every node in the graph and returns all findings.
Immutable, shareable task graph asset.
< Provides AssetID and INVALID_ASSET_ID
NVSeverity
Indicates how serious a NodeValidator finding is.
@ Info
Informational; no action required.
Full description of a single node in the task graph.
A single finding produced by NodeValidator.
int nodeId
Offending node ID; -1 for graph-level messages.
std::string hint
Optional suggestion to fix the issue.