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