Olympe Engine 2.0
2D Game Engine with ECS Architecture
Loading...
Searching...
No Matches
ConditionRegistry.h
Go to the documentation of this file.
1/**
2 * @file ConditionRegistry.h
3 * @brief Registry of available condition types for Branch/While node dropdowns.
4 * @author Olympe Engine
5 * @date 2026-03-14
6 *
7 * @details
8 * ConditionRegistry stores metadata (id, displayName, description, parameters)
9 * for each supported condition type. Used by the properties panel to populate
10 * the ConditionID dropdown on Branch and While nodes.
11 *
12 * C++14 compliant — no std::optional, structured bindings, std::filesystem.
13 */
14
15#pragma once
16
17#include <string>
18#include <vector>
19#include <unordered_map>
20
21#include "../TaskSystem/TaskGraphTypes.h"
22
23namespace Olympe {
24
25/**
26 * @struct ConditionParamSpec
27 * @brief Describes one parameter of a condition (e.g. the Key or Operator).
28 */
30 std::string name; ///< Parameter name (e.g. "Key", "Operator")
31 ParameterBindingType bindingType; ///< Expected binding type
32 std::string description; ///< Short description
33 bool required; ///< Whether the parameter is mandatory
34};
35
36/**
37 * @struct ConditionSpec
38 * @brief Full metadata for a single condition type.
39 */
41 std::string id; ///< Condition type ID (e.g. "CompareValue")
42 std::string displayName; ///< Human-readable name
43 std::string description; ///< Short description
44 std::vector<ConditionParamSpec> parameters; ///< Expected parameters in order
45};
46
47/**
48 * @class ConditionRegistry
49 * @brief Singleton registry of available condition types.
50 */
52public:
53
54 /**
55 * @brief Returns the singleton instance.
56 * Calls InitializeBuiltInConditions() on first access.
57 */
58 static ConditionRegistry& Get();
59
60 /**
61 * @brief Registers a ConditionSpec.
62 * @param spec Spec to register (id must be non-empty).
63 */
64 void Register(const ConditionSpec& spec);
65
66 /**
67 * @brief Returns the ConditionSpec for the given id, or nullptr if not found.
68 * @param id Condition type ID.
69 */
70 const ConditionSpec* GetConditionSpec(const std::string& id) const;
71
72 /**
73 * @brief Returns all registered condition IDs.
74 */
75 std::vector<std::string> GetAllConditionIds() const;
76
77 /**
78 * @brief Returns all registered condition specs, sorted by id.
79 */
80 std::vector<ConditionSpec> GetAllConditions() const;
81
82private:
83
85
87
88 std::unordered_map<std::string, ConditionSpec> m_specs;
89};
90
91} // namespace Olympe
ComponentTypeID GetComponentTypeID_Static()
Definition ECS_Entity.h:56
Singleton registry of available condition types.
void Register(const ConditionSpec &spec)
Registers a ConditionSpec.
static ConditionRegistry & Get()
Returns the singleton instance.
std::vector< ConditionSpec > GetAllConditions() const
Returns all registered condition specs, sorted by id.
std::vector< std::string > GetAllConditionIds() const
Returns all registered condition IDs.
const ConditionSpec * GetConditionSpec(const std::string &id) const
Returns the ConditionSpec for the given id, or nullptr if not found.
std::unordered_map< std::string, ConditionSpec > m_specs
< Provides AssetID and INVALID_ASSET_ID
ParameterBindingType
Describes how a parameter value is provided to a task node.
Describes one parameter of a condition (e.g.
std::string name
Parameter name (e.g. "Key", "Operator")
ParameterBindingType bindingType
Expected binding type.
std::string description
Short description.
bool required
Whether the parameter is mandatory.
Full metadata for a single condition type.
std::string description
Short description.
std::vector< ConditionParamSpec > parameters
Expected parameters in order.
std::string id
Condition type ID (e.g. "CompareValue")
std::string displayName
Human-readable name.