Olympe Engine 2.0
2D Game Engine with ECS Architecture
Loading...
Searching...
No Matches
NodeSearchPalette.h
Go to the documentation of this file.
1/**
2 * @file NodeSearchPalette.h
3 * @brief Fuzzy-search palette for VS node types (Phase 7).
4 * @author Olympe Engine
5 * @date 2026-03-10
6 *
7 * @details
8 * NodeSearchPalette maintains a catalog of all available node types and
9 * provides fuzzy-search over them. Results are sorted by descending match
10 * score. The implementation has no ImGui dependency — UI code calls
11 * FuzzySearch() and renders the returned vector however it likes.
12 *
13 * C++14 compliant — no std::optional, structured bindings, std::filesystem.
14 */
15
16#pragma once
17
18#include <string>
19#include <vector>
20
21namespace Olympe {
22
23// ============================================================================
24// Supporting types
25// ============================================================================
26
27/**
28 * @enum NodeSearchCategory
29 * @brief Broad category for filtering node search results.
30 */
32 All,
34 Actions,
35 Data
36};
37
38/**
39 * @struct NodeSearchResult
40 * @brief A single match returned by NodeSearchPalette::FuzzySearch().
41 */
43 std::string typeName; ///< Internal type identifier (e.g. "Sequence")
44 std::string displayName; ///< Human-readable label shown in the palette
46 int score; ///< Fuzzy match score; higher = better
47};
48
49// ============================================================================
50// NodeSearchPalette
51// ============================================================================
52
53/**
54 * @class NodeSearchPalette
55 * @brief Singleton fuzzy-search palette for VS node types.
56 *
57 * Typical usage:
58 * @code
59 * auto& palette = NodeSearchPalette::Get();
60 * palette.Open();
61 * auto results = palette.FuzzySearch("mov");
62 * // render results...
63 * @endcode
64 */
66public:
67
68 // -----------------------------------------------------------------------
69 // Singleton access
70 // -----------------------------------------------------------------------
71
72 /**
73 * @brief Returns the single shared instance.
74 */
75 static NodeSearchPalette& Get();
76
77 // -----------------------------------------------------------------------
78 // Open / close
79 // -----------------------------------------------------------------------
80
81 void Open();
82 void Close();
83 bool IsOpen() const;
84
85 // -----------------------------------------------------------------------
86 // Search
87 // -----------------------------------------------------------------------
88
89 /**
90 * @brief Fuzzy-searches the node catalog.
91 *
92 * @param query The string typed by the user (may be empty).
93 * @param filter Category to restrict results to; defaults to All.
94 * @return Results sorted by score descending.
95 */
96 std::vector<NodeSearchResult> FuzzySearch(
97 const std::string& query,
99
100 /**
101 * @brief Computes a fuzzy match score between @p query and @p candidate.
102 *
103 * @details
104 * Returns 0 when there is no match. Positive scores reflect quality:
105 * exact match > substring match > scattered character match.
106 */
107 static int ComputeFuzzyScore(const std::string& query,
108 const std::string& candidate);
109
110 /**
111 * @brief Returns all node types in the catalog (unfiltered).
112 */
113 const std::vector<NodeSearchResult>& GetAllNodes() const;
114
115private:
116
118
119 void InitNodeCatalog();
120
122 std::vector<NodeSearchResult> m_NodeCatalog;
123};
124
125} // namespace Olympe
ComponentTypeID GetComponentTypeID_Static()
Definition ECS_Entity.h:56
Singleton fuzzy-search palette for VS node types.
std::vector< NodeSearchResult > m_NodeCatalog
static int ComputeFuzzyScore(const std::string &query, const std::string &candidate)
Computes a fuzzy match score between query and candidate.
std::vector< NodeSearchResult > FuzzySearch(const std::string &query, NodeSearchCategory filter=NodeSearchCategory::All)
Fuzzy-searches the node catalog.
static NodeSearchPalette & Get()
Returns the single shared instance.
const std::vector< NodeSearchResult > & GetAllNodes() const
Returns all node types in the catalog (unfiltered).
< Provides AssetID and INVALID_ASSET_ID
NodeSearchCategory
Broad category for filtering node search results.
A single match returned by NodeSearchPalette::FuzzySearch().
NodeSearchCategory category
std::string typeName
Internal type identifier (e.g. "Sequence")
std::string displayName
Human-readable label shown in the palette.
int score
Fuzzy match score; higher = better.