yaze 0.3.2
Link to the Past ROM Editor
 
Loading...
Searching...
No Matches
rom_lifecycle_manager.h
Go to the documentation of this file.
1#ifndef YAZE_APP_EDITOR_SYSTEM_ROM_LIFECYCLE_MANAGER_H_
2#define YAZE_APP_EDITOR_SYSTEM_ROM_LIFECYCLE_MANAGER_H_
3
4#include <optional>
5#include <string>
6#include <vector>
7
8#include "absl/status/status.h"
10#include "core/hack_manifest.h"
11#include "core/project.h"
12#include "rom/rom.h"
13
14namespace yaze::editor {
15
16class SessionCoordinator;
17class ToastManager;
18class PopupManager;
19
33 public:
39
47
49 explicit RomLifecycleManager(Dependencies deps);
51
54 void Initialize(Dependencies deps);
55
59 project_ = project;
60 }
61
62 // =========================================================================
63 // ROM Hash & Write Policy
64 // =========================================================================
65
67 void UpdateCurrentRomHash(Rom* rom);
68
70 const std::string& current_rom_hash() const { return current_rom_hash_; }
71
73 bool IsRomHashMismatch() const;
74
76 absl::Status CheckRomOpenPolicy(Rom* rom);
77
79 absl::Status CheckRomWritePolicy(
80 Rom* rom,
81 const std::optional<std::string>& target_filename = std::nullopt);
82
84 absl::Status CheckOracleRomSafetyPreSave(Rom* rom);
85
86 // =========================================================================
87 // ROM Write Confirmation State Machine
88 // =========================================================================
89
91 void ConfirmRomWrite();
94
95 // =========================================================================
96 // Write Conflict Management (ASM-owned address protection)
97 // =========================================================================
98
99 const std::vector<core::WriteConflict>& pending_write_conflicts() const {
101 }
105 void SetPendingWriteConflicts(std::vector<core::WriteConflict> conflicts) {
106 pending_write_conflicts_ = std::move(conflicts);
107 }
112
113 // =========================================================================
114 // Pot Item Save Confirmation
115 // =========================================================================
116
126
128 void SetPotItemConfirmPending(int unloaded_rooms, int total_rooms);
129
134 PotItemSaveDecision decision);
135
152
162
163 // =========================================================================
164 // Backup Management (delegates to RomFileManager)
165 // =========================================================================
166
167 std::vector<RomFileManager::BackupEntry> GetRomBackups(Rom* rom) const;
168 absl::Status PruneRomBackups(Rom* rom);
169
171 void ApplyDefaultBackupPolicy(bool enabled, const std::string& folder,
172 int retention_count, bool keep_daily,
173 int keep_daily_days);
174
175 private:
176 // Dependencies (non-owning pointers)
182
183 // ROM hash state
184 std::string current_rom_hash_;
185 std::string current_rom_path_;
186
187 // Write confirmation state machine
191
192 // Pot item save confirmation state
198
199 // Write conflict state (ASM-owned address protection)
200 std::vector<core::WriteConflict> pending_write_conflicts_;
202};
203
204} // namespace yaze::editor
205
206#endif // YAZE_APP_EDITOR_SYSTEM_ROM_LIFECYCLE_MANAGER_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
Handles all ROM file I/O operations.
Manages ROM and project persistence state.
void SetProjectContext(const project::YazeProject *project)
void UpdateCurrentRomHash(Rom *rom)
Recompute the hash of the current ROM.
std::vector< RomFileManager::BackupEntry > GetRomBackups(Rom *rom) const
void SetPotItemConfirmPending(int unloaded_rooms, int total_rooms)
Set pot-item confirmation pending (called by SaveRom when needed).
absl::Status CheckRomWritePolicy(Rom *rom, const std::optional< std::string > &target_filename=std::nullopt)
Enforce project write policy; may set pending_rom_write_confirm.
const project::YazeProject * project_
bool IsRomHashMismatch() const
Check whether the ROM hash mismatches the project's expected hash.
absl::Status CheckRomOpenPolicy(Rom *rom)
Validate that the loaded ROM is a safe project target to open/edit.
PotItemSaveDecision ResolvePotItemSaveConfirmation(PotItemSaveDecision decision)
const std::string & current_rom_hash() const
Get the cached ROM hash string.
std::vector< core::WriteConflict > pending_write_conflicts_
const std::vector< core::WriteConflict > & pending_write_conflicts() const
void SetPendingWriteConflicts(std::vector< core::WriteConflict > conflicts)
absl::Status CheckOracleRomSafetyPreSave(Rom *rom)
Run Oracle-specific ROM safety preflight before saving.
void ApplyDefaultBackupPolicy(bool enabled, const std::string &folder, int retention_count, bool keep_daily, int keep_daily_days)
Apply default backup policy from user settings.
High-level orchestrator for multi-session UI.
Editors are the view controllers for the application.
Modern project structure with comprehensive settings consolidation.
Definition project.h:172