yaze 0.3.2
Link to the Past ROM Editor
 
Loading...
Searching...
No Matches
editor_registry.h
Go to the documentation of this file.
1#ifndef YAZE_APP_EDITOR_SYSTEM_EDITOR_REGISTRY_H_
2#define YAZE_APP_EDITOR_SYSTEM_EDITOR_REGISTRY_H_
3
4#include <functional>
5#include <memory>
6#include <string>
7#include <unordered_map>
8#include <vector>
9
10#include "app/editor/editor.h"
11
12namespace yaze {
13namespace editor {
14
20
26
37 public:
38 using EditorFactory = std::function<std::unique_ptr<Editor>(Rom*)>;
39
40 EditorRegistry() = default;
41 ~EditorRegistry() = default;
42
43 // Editor type management (static methods for global access)
44 static bool IsPanelBasedEditor(EditorType type);
51 static bool IsExperimentalEditor(EditorType type);
54 bool experiments_enabled);
55 static std::string GetEditorName(EditorType type);
56 static std::string GetEditorCategory(EditorType type);
57 static EditorType GetEditorTypeFromCategory(const std::string& category);
58
63 static std::vector<std::string> GetAllEditorCategories();
64
65 // Editor information
66 std::vector<EditorType> GetEditorsInCategory(
67 const std::string& category) const;
68 std::vector<std::string> GetAvailableCategories() const;
69 std::string GetEditorDisplayName(EditorType type) const;
70
71 // Editor lifecycle
72 void RegisterEditor(EditorType type, Editor* editor);
74 Editor* GetEditor(EditorType type) const;
75
76 // Factory lifecycle (Phase 3: registry-based instantiation)
77 void RegisterFactory(EditorType type, EditorFactory factory);
79 bool HasFactory(EditorType type) const;
80 std::unique_ptr<Editor> CreateEditor(EditorType type, Rom* rom) const;
81
82 // Editor state queries
83 bool IsEditorActive(EditorType type) const;
84 bool IsEditorVisible(EditorType type) const;
85 void SetEditorActive(EditorType type, bool active);
86
87 private:
88 // Editor type mappings
89 static const std::unordered_map<EditorType, std::string> kEditorCategories;
90 static const std::unordered_map<EditorType, std::string> kEditorNames;
91 static const std::unordered_map<EditorType, bool> kPanelBasedEditors;
92
93 // Registered editors
94 std::unordered_map<EditorType, Editor*> registered_editors_;
95
96 // Editor factories (for EditorSet/session creation).
97 std::unordered_map<EditorType, EditorFactory> editor_factories_;
98
99 // Helper methods
100 bool IsValidEditorType(EditorType type) const;
101 void ValidateEditorType(EditorType type) const;
102};
103
104} // namespace editor
105} // namespace yaze
106
107#endif // YAZE_APP_EDITOR_SYSTEM_EDITOR_REGISTRY_H_
The Rom class is used to load, save, and modify Rom data. This is a generic SNES ROM container and do...
Definition rom.h:49
Manages editor types, categories, and lifecycle.
void RegisterEditor(EditorType type, Editor *editor)
static const std::unordered_map< EditorType, std::string > kEditorNames
static bool UpdateAllowedWithoutLoadedRom(EditorType type)
static EditorType GetEditorTypeFromCategory(const std::string &category)
static const std::unordered_map< EditorType, std::string > kEditorCategories
void ValidateEditorType(EditorType type) const
static std::vector< std::string > GetAllEditorCategories()
Get all editor categories in display order for sidebar.
std::vector< EditorType > GetEditorsInCategory(const std::string &category) const
static bool IsPanelBasedEditor(EditorType type)
static bool ShouldWarnAboutExperimentalEditor(EditorType type, bool experiments_enabled)
std::unique_ptr< Editor > CreateEditor(EditorType type, Rom *rom) const
static bool IsExperimentalEditor(EditorType type)
std::function< std::unique_ptr< Editor >(Rom *)> EditorFactory
void SetEditorActive(EditorType type, bool active)
std::string GetEditorDisplayName(EditorType type) const
bool HasFactory(EditorType type) const
void UnregisterEditor(EditorType type)
bool IsEditorActive(EditorType type) const
std::unordered_map< EditorType, EditorFactory > editor_factories_
bool IsValidEditorType(EditorType type) const
void RegisterFactory(EditorType type, EditorFactory factory)
bool IsEditorVisible(EditorType type) const
void UnregisterFactory(EditorType type)
static EditorExperimentPolicy GetExperimentPolicy(EditorType type)
std::vector< std::string > GetAvailableCategories() const
static std::string GetEditorName(EditorType type)
static const std::unordered_map< EditorType, bool > kPanelBasedEditors
Editor * GetEditor(EditorType type) const
static std::string GetEditorCategory(EditorType type)
std::unordered_map< EditorType, Editor * > registered_editors_
Interface for editor classes.
Definition editor.h:249
ExperimentalSavePosture disabled_save_posture