Olympe Engine 2.0
2D Game Engine with ECS Architecture
Loading...
Searching...
No Matches
AtomicTaskUIRegistry.h
Go to the documentation of this file.
1/**
2 * @file AtomicTaskUIRegistry.h
3 * @brief UI-side registry of available atomic tasks with display metadata.
4 * @author Olympe Engine
5 * @date 2026-03-14
6 *
7 * @details
8 * AtomicTaskUIRegistry provides editor-facing information for atomic tasks
9 * (display name, category, description) used to populate dropdown menus
10 * in the properties panel.
11 *
12 * Built-in tasks are pre-registered via InitializeBuiltInTasks().
13 * The runtime AtomicTaskRegistry is the authoritative source for which
14 * tasks are actually executable; this registry adds UI metadata on top.
15 *
16 * C++14 compliant — no std::optional, structured bindings, std::filesystem.
17 */
18
19#pragma once
20
21#include <string>
22#include <vector>
23#include <unordered_map>
24
25namespace Olympe {
26
27/**
28 * @struct TaskParameter
29 * @brief Metadata for a parameter of an atomic task.
30 */
32 std::string name; ///< Parameter name (e.g., "message", "speed")
33 std::string type; ///< Parameter type (String, Float, Int, Bool, etc.)
34 std::string defaultValue; ///< Default value
35 std::string description; ///< Tooltip/description for the parameter
36};
37
38/**
39 * @struct TaskSpec
40 * @brief Display metadata for a single atomic task type.
41 */
42struct TaskSpec {
43 std::string id; ///< Task ID (matches AtomicTaskRegistry key)
44 std::string displayName; ///< Human-readable name (e.g. "Move To Goal")
45 std::string category; ///< Category for grouping (e.g. "Movement")
46 std::string description; ///< Short description for tooltip
47 std::vector<TaskParameter> parameters; ///< Parameters this task accepts
48};
49
50/**
51 * @class AtomicTaskUIRegistry
52 * @brief Singleton registry mapping task IDs to TaskSpec metadata.
53 */
55public:
56
57 /**
58 * @brief Returns the singleton instance.
59 * Calls InitializeBuiltInTasks() on first access.
60 */
61 static AtomicTaskUIRegistry& Get();
62
63 /**
64 * @brief Registers a TaskSpec for the given task ID.
65 * @param spec Spec to register (id must be non-empty).
66 */
67 void Register(const TaskSpec& spec);
68
69 /**
70 * @brief Returns the TaskSpec for the given id, or nullptr if not found.
71 * @param id Task ID string.
72 */
73 const TaskSpec* GetTaskSpec(const std::string& id) const;
74
75 /**
76 * @brief Returns all registered task IDs (unordered).
77 */
78 std::vector<std::string> GetAllTaskIds() const;
79
80 /**
81 * @brief Returns all tasks belonging to the given category.
82 * @param category Category string (e.g. "Movement").
83 */
84 std::vector<TaskSpec> GetTasksByCategory(const std::string& category) const;
85
86 /**
87 * @brief Returns all unique category names.
88 */
89 std::vector<std::string> GetAllCategories() const;
90
91 /**
92 * @brief Returns all tasks sorted by category then displayName,
93 * suitable for building a dropdown or combo box.
94 */
95 std::vector<TaskSpec> GetSortedForUI() const;
96
97private:
98
100
102
103 std::unordered_map<std::string, TaskSpec> m_specs;
104};
105
106} // namespace Olympe
ComponentTypeID GetComponentTypeID_Static()
Definition ECS_Entity.h:56
Singleton registry mapping task IDs to TaskSpec metadata.
std::vector< TaskSpec > GetTasksByCategory(const std::string &category) const
Returns all tasks belonging to the given category.
static AtomicTaskUIRegistry & Get()
Returns the singleton instance.
std::vector< std::string > GetAllTaskIds() const
Returns all registered task IDs (unordered).
std::vector< TaskSpec > GetSortedForUI() const
Returns all tasks sorted by category then displayName, suitable for building a dropdown or combo box.
std::unordered_map< std::string, TaskSpec > m_specs
const TaskSpec * GetTaskSpec(const std::string &id) const
Returns the TaskSpec for the given id, or nullptr if not found.
void Register(const TaskSpec &spec)
Registers a TaskSpec for the given task ID.
std::vector< std::string > GetAllCategories() const
Returns all unique category names.
< Provides AssetID and INVALID_ASSET_ID
Metadata for a parameter of an atomic task.
std::string name
Parameter name (e.g., "message", "speed")
std::string description
Tooltip/description for the parameter.
std::string type
Parameter type (String, Float, Int, Bool, etc.)
std::string defaultValue
Default value.
Display metadata for a single atomic task type.
std::vector< TaskParameter > parameters
Parameters this task accepts.
std::string id
Task ID (matches AtomicTaskRegistry key)
std::string displayName
Human-readable name (e.g. "Move To Goal")
std::string category
Category for grouping (e.g. "Movement")
std::string description
Short description for tooltip.