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
25 public:
26 using EditorFactory = std::function<std::unique_ptr<Editor>(Rom*)>;
27
28 EditorRegistry() = default;
29 ~EditorRegistry() = default;
30
31 // Editor type management (static methods for global access)
32 static bool IsPanelBasedEditor(EditorType type);
42 static bool IsExperimentalEditor(EditorType type);
43 static std::string GetEditorName(EditorType type);
44 static std::string GetEditorCategory(EditorType type);
45 static EditorType GetEditorTypeFromCategory(const std::string& category);
46
51 static std::vector<std::string> GetAllEditorCategories();
52
53 // Editor information
54 std::vector<EditorType> GetEditorsInCategory(
55 const std::string& category) const;
56 std::vector<std::string> GetAvailableCategories() const;
57 std::string GetEditorDisplayName(EditorType type) const;
58
59 // Editor lifecycle
60 void RegisterEditor(EditorType type, Editor* editor);
62 Editor* GetEditor(EditorType type) const;
63
64 // Factory lifecycle (Phase 3: registry-based instantiation)
65 void RegisterFactory(EditorType type, EditorFactory factory);
67 bool HasFactory(EditorType type) const;
68 std::unique_ptr<Editor> CreateEditor(EditorType type, Rom* rom) const;
69
70 // Editor state queries
71 bool IsEditorActive(EditorType type) const;
72 bool IsEditorVisible(EditorType type) const;
73 void SetEditorActive(EditorType type, bool active);
74
75 private:
76 // Editor type mappings
77 static const std::unordered_map<EditorType, std::string> kEditorCategories;
78 static const std::unordered_map<EditorType, std::string> kEditorNames;
79 static const std::unordered_map<EditorType, bool> kPanelBasedEditors;
80
81 // Registered editors
82 std::unordered_map<EditorType, Editor*> registered_editors_;
83
84 // Editor factories (for EditorSet/session creation).
85 std::unordered_map<EditorType, EditorFactory> editor_factories_;
86
87 // Helper methods
88 bool IsValidEditorType(EditorType type) const;
89 void ValidateEditorType(EditorType type) const;
90};
91
92} // namespace editor
93} // namespace yaze
94
95#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:28
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)
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)
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:245