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);
38 static std::string GetEditorName(EditorType type);
39 static std::string GetEditorCategory(EditorType type);
40 static EditorType GetEditorTypeFromCategory(const std::string& category);
41
46 static std::vector<std::string> GetAllEditorCategories();
47
48 // Editor information
49 std::vector<EditorType> GetEditorsInCategory(
50 const std::string& category) const;
51 std::vector<std::string> GetAvailableCategories() const;
52 std::string GetEditorDisplayName(EditorType type) const;
53
54 // Editor lifecycle
55 void RegisterEditor(EditorType type, Editor* editor);
57 Editor* GetEditor(EditorType type) const;
58
59 // Factory lifecycle (Phase 3: registry-based instantiation)
60 void RegisterFactory(EditorType type, EditorFactory factory);
62 bool HasFactory(EditorType type) const;
63 std::unique_ptr<Editor> CreateEditor(EditorType type, Rom* rom) const;
64
65 // Editor state queries
66 bool IsEditorActive(EditorType type) const;
67 bool IsEditorVisible(EditorType type) const;
68 void SetEditorActive(EditorType type, bool active);
69
70 private:
71 // Editor type mappings
72 static const std::unordered_map<EditorType, std::string> kEditorCategories;
73 static const std::unordered_map<EditorType, std::string> kEditorNames;
74 static const std::unordered_map<EditorType, bool> kPanelBasedEditors;
75
76 // Registered editors
77 std::unordered_map<EditorType, Editor*> registered_editors_;
78
79 // Editor factories (for EditorSet/session creation).
80 std::unordered_map<EditorType, EditorFactory> editor_factories_;
81
82 // Helper methods
83 bool IsValidEditorType(EditorType type) const;
84 void ValidateEditorType(EditorType type) const;
85};
86
87} // namespace editor
88} // namespace yaze
89
90#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
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:240