Olympe Engine 2.0
2D Game Engine with ECS Architecture
Loading...
Searching...
No Matches
BTGraphValidator.h
Go to the documentation of this file.
1/**
2 * @file BTGraphValidator.h
3 * @brief Validation system for Behavior Tree graph structure
4 * @author Olympe Engine
5 * @date 2026-02-18
6 *
7 * @details
8 * Validates BT graph structure according to business rules:
9 * - Exactly one root node
10 * - No cycles in graph
11 * - Valid child counts per node type
12 * - No orphan nodes
13 * - Type-specific constraints
14 */
15
16#pragma once
17
18#include "../../NodeGraphCore/GraphDocument.h"
19#include <string>
20#include <vector>
21#include <cstdint>
22
23namespace Olympe {
24namespace AI {
25
26/**
27 * @enum BTValidationSeverity
28 * @brief Severity level of validation message
29 */
31 Info, ///< Informational message
32 Warning, ///< Warning (non-blocking)
33 Error ///< Error (blocking compilation)
34};
35
36/**
37 * @struct BTValidationMessage
38 * @brief Validation result message
39 */
42 uint32_t nodeId = 0; ///< Node ID (0 if global error)
43 std::string message; ///< Description of the issue
44 std::string fix; ///< Suggested fix
45};
46
47/**
48 * @class BTGraphValidator
49 * @brief Static validator for BT graph documents
50 *
51 * @details
52 * Validates graph structure according to BT-specific rules. Returns list
53 * of validation messages (errors, warnings, info). Graph is valid if no
54 * error-level messages are returned.
55 */
57public:
58 /**
59 * @brief Validate a complete BT graph
60 * @param graph Graph document to validate
61 * @return Vector of validation messages (empty if valid)
62 */
63 static std::vector<BTValidationMessage> ValidateGraph(const NodeGraph::GraphDocument* graph);
64
65private:
66 /**
67 * @brief Rule 1: Check for exactly one root node
68 * @param graph Graph to validate
69 * @param messages Output messages
70 */
71 static void ValidateRootNode(const NodeGraph::GraphDocument* graph, std::vector<BTValidationMessage>& messages);
72
73 /**
74 * @brief Rule 2: Detect cycles in graph
75 * @param graph Graph to validate
76 * @param messages Output messages
77 */
78 static void ValidateCycles(const NodeGraph::GraphDocument* graph, std::vector<BTValidationMessage>& messages);
79
80 /**
81 * @brief Rule 3: Validate child counts per node type
82 * @param graph Graph to validate
83 * @param messages Output messages
84 */
85 static void ValidateChildrenCount(const NodeGraph::GraphDocument* graph, std::vector<BTValidationMessage>& messages);
86
87 /**
88 * @brief Rule 4: Check for orphan nodes (disconnected from root)
89 * @param graph Graph to validate
90 * @param messages Output messages
91 */
92 static void ValidateOrphans(const NodeGraph::GraphDocument* graph, std::vector<BTValidationMessage>& messages);
93
94 /**
95 * @brief Rule 5: Validate node types are registered
96 * @param graph Graph to validate
97 * @param messages Output messages
98 */
99 static void ValidateNodeTypes(const NodeGraph::GraphDocument* graph, std::vector<BTValidationMessage>& messages);
100};
101
102} // namespace AI
103} // namespace Olympe
ComponentTypeID GetComponentTypeID_Static()
Definition ECS_Entity.h:56
Static validator for BT graph documents.
static void ValidateNodeTypes(const NodeGraph::GraphDocument *graph, std::vector< BTValidationMessage > &messages)
Rule 5: Validate node types are registered.
static void ValidateRootNode(const NodeGraph::GraphDocument *graph, std::vector< BTValidationMessage > &messages)
Rule 1: Check for exactly one root node.
static void ValidateOrphans(const NodeGraph::GraphDocument *graph, std::vector< BTValidationMessage > &messages)
Rule 4: Check for orphan nodes (disconnected from root)
static std::vector< BTValidationMessage > ValidateGraph(const NodeGraph::GraphDocument *graph)
Validate a complete BT graph.
static void ValidateCycles(const NodeGraph::GraphDocument *graph, std::vector< BTValidationMessage > &messages)
Rule 2: Detect cycles in graph.
static void ValidateChildrenCount(const NodeGraph::GraphDocument *graph, std::vector< BTValidationMessage > &messages)
Rule 3: Validate child counts per node type.
Main document class for a node graph.
BTValidationSeverity
Severity level of validation message.
@ Warning
Warning (non-blocking)
@ Info
Informational message.
@ Error
Error (blocking compilation)
< Provides AssetID and INVALID_ASSET_ID
Validation result message.
std::string fix
Suggested fix.
uint32_t nodeId
Node ID (0 if global error)
std::string message
Description of the issue.