Olympe Engine 2.0
2D Game Engine with ECS Architecture
Loading...
Searching...
No Matches
NodeAnnotations.h
Go to the documentation of this file.
1/**
2 * @file NodeAnnotations.h
3 * @brief Per-node annotations manager for node graphs (Phase 2.0)
4 * @author Olympe Engine
5 * @date 2026-02-19
6 *
7 * @details
8 * Provides a serializable system for per-node annotations, including:
9 * - Breakpoints (for debugging)
10 * - Text comments
11 * - Custom node colors (RGBA floats)
12 */
13
14#pragma once
15
16#include "../json_helper.h"
17#include <string>
18#include <map>
19
20namespace Olympe {
21namespace NodeGraph {
22
23// ============================================================================
24// NodeAnnotation struct
25// ============================================================================
26
27/**
28 * @struct NodeAnnotation
29 * @brief Holds annotation data for a single node
30 */
32 int nodeId = 0;
33 bool hasBreakpoint = false;
34 std::string comment;
35 float colorR = 1.0f;
36 float colorG = 1.0f;
37 float colorB = 1.0f;
38 float colorA = 1.0f;
39};
40
41// ============================================================================
42// NodeAnnotationsManager class
43// ============================================================================
44
45/**
46 * @class NodeAnnotationsManager
47 * @brief Manages per-node annotations (breakpoints, comments, colors)
48 */
50public:
53
54 /**
55 * @brief Check if a node has any annotation
56 * @param nodeId Node identifier
57 * @return true if an annotation exists for this node
58 */
59 bool HasAnnotation(int nodeId) const;
60
61 /**
62 * @brief Get annotation for a node (non-const)
63 * @param nodeId Node identifier
64 * @return Pointer to annotation, or nullptr if not found
65 */
66 NodeAnnotation* GetAnnotation(int nodeId);
67
68 /**
69 * @brief Get annotation for a node (const)
70 * @param nodeId Node identifier
71 * @return Const pointer to annotation, or nullptr if not found
72 */
73 const NodeAnnotation* GetAnnotation(int nodeId) const;
74
75 /**
76 * @brief Set breakpoint state for a node
77 * @param nodeId Node identifier
78 * @param enabled Whether breakpoint is active
79 */
80 void SetBreakpoint(int nodeId, bool enabled);
81
82 /**
83 * @brief Set comment for a node
84 * @param nodeId Node identifier
85 * @param text Comment text
86 */
87 void SetComment(int nodeId, const std::string& text);
88
89 /**
90 * @brief Set custom color for a node
91 * @param nodeId Node identifier
92 * @param r Red component [0,1]
93 * @param g Green component [0,1]
94 * @param b Blue component [0,1]
95 * @param a Alpha component [0,1]
96 */
97 void SetColor(int nodeId, float r, float g, float b, float a);
98
99 /**
100 * @brief Remove all annotation data for a node
101 * @param nodeId Node identifier
102 */
103 void ClearAnnotation(int nodeId);
104
105 /**
106 * @brief Get all annotations (for serialization / rendering)
107 * @return Const reference to internal map
108 */
109 const std::map<int, NodeAnnotation>& GetAll() const;
110
111 /**
112 * @brief Serialize all annotations to JSON
113 * @return JSON array of annotation objects
114 */
115 json ToJson() const;
116
117 /**
118 * @brief Deserialize annotations from JSON
119 * @param j JSON array of annotation objects
120 */
121 void FromJson(const json& j);
122
123private:
124 std::map<int, NodeAnnotation> m_annotations;
125
126 /**
127 * @brief Get or create annotation for a node
128 * @param nodeId Node identifier
129 * @return Reference to annotation
130 */
131 NodeAnnotation& GetOrCreate(int nodeId);
132};
133
134} // namespace NodeGraph
135} // namespace Olympe
ComponentTypeID GetComponentTypeID_Static()
Definition ECS_Entity.h:56
Manages per-node annotations (breakpoints, comments, colors)
void ClearAnnotation(int nodeId)
Remove all annotation data for a node.
json ToJson() const
Serialize all annotations to JSON.
void SetComment(int nodeId, const std::string &text)
Set comment for a node.
void SetBreakpoint(int nodeId, bool enabled)
Set breakpoint state for a node.
const std::map< int, NodeAnnotation > & GetAll() const
Get all annotations (for serialization / rendering)
std::map< int, NodeAnnotation > m_annotations
NodeAnnotation * GetAnnotation(int nodeId)
Get annotation for a node (non-const)
NodeAnnotation & GetOrCreate(int nodeId)
Get or create annotation for a node.
void FromJson(const json &j)
Deserialize annotations from JSON.
void SetColor(int nodeId, float r, float g, float b, float a)
Set custom color for a node.
bool HasAnnotation(int nodeId) const
Check if a node has any annotation.
< Provides AssetID and INVALID_ASSET_ID
nlohmann::json json
Holds annotation data for a single node.