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#include "util/rom_hash.h"
14
15namespace yaze::editor {
16
17class SessionCoordinator;
18class ToastManager;
19class PopupManager;
20struct RomSession;
21
35 public:
41
49
51 explicit RomLifecycleManager(Dependencies deps);
53
56 void Initialize(Dependencies deps);
57
61 project_ = project;
62 }
63
64 // =========================================================================
65 // ROM Hash & Write Policy
66 // =========================================================================
67
70 void ActivateRomIdentity(const RomSession* session);
71
73 const std::string& current_rom_hash() const {
75 }
76
78 bool IsRomHashMismatch() const;
79
81 absl::Status CheckRomOpenPolicy(Rom* rom);
82
86 absl::Status CheckRomRebindPolicy(Rom* rom);
87
89 absl::Status CheckRomWritePolicy(
90 Rom* rom,
91 const std::optional<std::string>& target_filename = std::nullopt);
92
94 absl::Status CheckOracleRomSafetyPreSave(Rom* rom);
95
96 // =========================================================================
97 // ROM Write Confirmation State Machine
98 // =========================================================================
99
101 void ConfirmRomWrite();
104
105 // =========================================================================
106 // Write Conflict Management (ASM-owned address protection)
107 // =========================================================================
108
109 const std::vector<core::WriteConflict>& pending_write_conflicts() const {
111 }
115 void SetPendingWriteConflicts(std::vector<core::WriteConflict> conflicts) {
116 pending_write_conflicts_ = std::move(conflicts);
117 }
122
123 // =========================================================================
124 // Pot Item Save Confirmation
125 // =========================================================================
126
136
138 void SetPotItemConfirmPending(int unloaded_rooms, int total_rooms);
139
144 PotItemSaveDecision decision);
145
162
172
173 // =========================================================================
174 // Backup Management (delegates to RomFileManager)
175 // =========================================================================
176
177 std::vector<RomFileManager::BackupEntry> GetRomBackups(Rom* rom) const;
178 absl::Status PruneRomBackups(Rom* rom);
179
181 void ApplyDefaultBackupPolicy(bool enabled, const std::string& folder,
182 int retention_count, bool keep_daily,
183 int keep_daily_days);
184
185 private:
186 bool HasEditableSource(const std::string& source_path) const;
187
188 // Dependencies (non-owning pointers)
194
195 // Active view of the session-owned baseline; replaced on every activation.
197 std::string current_rom_path_;
199
200 // Write confirmation state machine
204
205 // Pot item save confirmation state
211
212 // Write conflict state (ASM-owned address protection)
213 std::vector<core::WriteConflict> pending_write_conflicts_;
215};
216
217} // namespace yaze::editor
218
219#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:49
Handles all ROM file I/O operations.
Manages ROM and project persistence state.
void SetProjectContext(const project::YazeProject *project)
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.
void ActivateRomIdentity(const RomSession *session)
bool HasEditableSource(const std::string &source_path) const
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.
util::RomIdentityHashes current_rom_identity_
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.
Represents a single session, containing a ROM and its associated editors.
Modern project structure with comprehensive settings consolidation.
Definition project.h:287