yaze 0.3.2
Link to the Past ROM Editor
 
Loading...
Searching...
No Matches
yaze::editor::RomLifecycleManager Class Reference

Manages ROM and project persistence state. More...

#include <rom_lifecycle_manager.h>

Classes

struct  Dependencies
 

Public Types

enum class  PotItemSaveDecision { kSaveWithPotItems , kSaveWithoutPotItems , kCancel }
 

Public Member Functions

 RomLifecycleManager ()=default
 
 RomLifecycleManager (Dependencies deps)
 
 ~RomLifecycleManager ()=default
 
void Initialize (Dependencies deps)
 
void UpdateCurrentRomHash (Rom *rom)
 Recompute the hash of the current ROM.
 
const std::string & current_rom_hash () const
 Get the cached ROM hash string.
 
bool IsRomHashMismatch () const
 Check whether the ROM hash mismatches the project's expected hash.
 
absl::Status CheckRomWritePolicy (Rom *rom)
 Enforce project write policy; may set pending_rom_write_confirm.
 
absl::Status CheckOracleRomSafetyPreSave (Rom *rom)
 Run Oracle-specific ROM safety preflight before saving.
 
bool IsRomWriteConfirmPending () const
 
void ConfirmRomWrite ()
 
void CancelRomWriteConfirm ()
 
const std::vector< core::WriteConflict > & pending_write_conflicts () const
 
bool ShouldBypassWriteConflict () const
 
void BypassWriteConflictOnce ()
 
void ClearPendingWriteConflicts ()
 
void SetPendingWriteConflicts (std::vector< core::WriteConflict > conflicts)
 
void ConsumeWriteConflictBypass ()
 
bool HasPendingPotItemSaveConfirmation () const
 
int pending_pot_item_unloaded_rooms () const
 
int pending_pot_item_total_rooms () const
 
void SetPotItemConfirmPending (int unloaded_rooms, int total_rooms)
 Set pot-item confirmation pending (called by SaveRom when needed).
 
PotItemSaveDecision ResolvePotItemSaveConfirmation (PotItemSaveDecision decision)
 
bool ShouldBypassPotItemConfirm () const
 
bool ShouldSuppressPotItemSave () const
 
void ClearPotItemBypass ()
 
std::vector< RomFileManager::BackupEntryGetRomBackups (Rom *rom) const
 
absl::Status PruneRomBackups (Rom *rom)
 
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.
 

Private Attributes

RomFileManagerrom_file_manager_ = nullptr
 
SessionCoordinatorsession_coordinator_ = nullptr
 
ToastManagertoast_manager_ = nullptr
 
PopupManagerpopup_manager_ = nullptr
 
project::YazeProjectproject_ = nullptr
 
std::string current_rom_hash_
 
bool pending_rom_write_confirm_ = false
 
bool bypass_rom_write_confirm_once_ = false
 
bool pending_pot_item_save_confirm_ = false
 
int pending_pot_item_unloaded_rooms_ = 0
 
int pending_pot_item_total_rooms_ = 0
 
bool bypass_pot_item_confirm_once_ = false
 
bool suppress_pot_item_save_once_ = false
 
std::vector< core::WriteConflictpending_write_conflicts_
 
bool bypass_write_conflict_once_ = false
 

Detailed Description

Manages ROM and project persistence state.

Extracted from EditorManager to consolidate all ROM/project save/load state management, write-policy enforcement, backup management, and confirmation dialogs into a single component.

EditorManager delegates ROM operations to this class and receives results/errors back. The manager does NOT own the ROM or project objects - those live in the session hierarchy.

Definition at line 31 of file rom_lifecycle_manager.h.

Member Enumeration Documentation

◆ PotItemSaveDecision

Enumerator
kSaveWithPotItems 
kSaveWithoutPotItems 
kCancel 

Definition at line 33 of file rom_lifecycle_manager.h.

Constructor & Destructor Documentation

◆ RomLifecycleManager() [1/2]

yaze::editor::RomLifecycleManager::RomLifecycleManager ( )
default

◆ RomLifecycleManager() [2/2]

yaze::editor::RomLifecycleManager::RomLifecycleManager ( Dependencies deps)
explicit

Definition at line 38 of file rom_lifecycle_manager.cc.

◆ ~RomLifecycleManager()

yaze::editor::RomLifecycleManager::~RomLifecycleManager ( )
default

Member Function Documentation

◆ Initialize()

◆ UpdateCurrentRomHash()

void yaze::editor::RomLifecycleManager::UpdateCurrentRomHash ( Rom * rom)

Recompute the hash of the current ROM.

Definition at line 57 of file rom_lifecycle_manager.cc.

References yaze::util::ComputeRomHash(), current_rom_hash_, yaze::Rom::data(), yaze::Rom::is_loaded(), and yaze::Rom::size().

Referenced by yaze::editor::EditorManager::UpdateCurrentRomHash().

Here is the call graph for this function:

◆ current_rom_hash()

const std::string & yaze::editor::RomLifecycleManager::current_rom_hash ( ) const
inline

Get the cached ROM hash string.

Definition at line 63 of file rom_lifecycle_manager.h.

References current_rom_hash_.

Referenced by yaze::editor::EditorManager::GetCurrentRomHash().

◆ IsRomHashMismatch()

bool yaze::editor::RomLifecycleManager::IsRomHashMismatch ( ) const

Check whether the ROM hash mismatches the project's expected hash.

Definition at line 65 of file rom_lifecycle_manager.cc.

References current_rom_hash_, yaze::project::RomMetadata::expected_hash, project_, yaze::project::YazeProject::project_opened(), and yaze::project::YazeProject::rom_metadata.

Referenced by yaze::editor::EditorManager::IsRomHashMismatch().

Here is the call graph for this function:

◆ CheckRomWritePolicy()

◆ CheckOracleRomSafetyPreSave()

◆ IsRomWriteConfirmPending()

bool yaze::editor::RomLifecycleManager::IsRomWriteConfirmPending ( ) const
inline

◆ ConfirmRomWrite()

void yaze::editor::RomLifecycleManager::ConfirmRomWrite ( )

◆ CancelRomWriteConfirm()

void yaze::editor::RomLifecycleManager::CancelRomWriteConfirm ( )

◆ pending_write_conflicts()

const std::vector< core::WriteConflict > & yaze::editor::RomLifecycleManager::pending_write_conflicts ( ) const
inline

◆ ShouldBypassWriteConflict()

bool yaze::editor::RomLifecycleManager::ShouldBypassWriteConflict ( ) const
inline

Definition at line 89 of file rom_lifecycle_manager.h.

References bypass_write_conflict_once_.

Referenced by yaze::editor::EditorManager::SaveRom().

◆ BypassWriteConflictOnce()

void yaze::editor::RomLifecycleManager::BypassWriteConflictOnce ( )
inline

◆ ClearPendingWriteConflicts()

void yaze::editor::RomLifecycleManager::ClearPendingWriteConflicts ( )
inline

◆ SetPendingWriteConflicts()

void yaze::editor::RomLifecycleManager::SetPendingWriteConflicts ( std::vector< core::WriteConflict > conflicts)
inline

Definition at line 92 of file rom_lifecycle_manager.h.

References pending_write_conflicts_.

Referenced by yaze::editor::EditorManager::SaveRom().

◆ ConsumeWriteConflictBypass()

void yaze::editor::RomLifecycleManager::ConsumeWriteConflictBypass ( )
inline

◆ HasPendingPotItemSaveConfirmation()

bool yaze::editor::RomLifecycleManager::HasPendingPotItemSaveConfirmation ( ) const
inline

◆ pending_pot_item_unloaded_rooms()

int yaze::editor::RomLifecycleManager::pending_pot_item_unloaded_rooms ( ) const
inline

◆ pending_pot_item_total_rooms()

int yaze::editor::RomLifecycleManager::pending_pot_item_total_rooms ( ) const
inline

◆ SetPotItemConfirmPending()

void yaze::editor::RomLifecycleManager::SetPotItemConfirmPending ( int unloaded_rooms,
int total_rooms )

Set pot-item confirmation pending (called by SaveRom when needed).

Definition at line 169 of file rom_lifecycle_manager.cc.

References pending_pot_item_save_confirm_, pending_pot_item_total_rooms_, and pending_pot_item_unloaded_rooms_.

Referenced by yaze::editor::EditorManager::SaveRom().

◆ ResolvePotItemSaveConfirmation()

RomLifecycleManager::PotItemSaveDecision yaze::editor::RomLifecycleManager::ResolvePotItemSaveConfirmation ( PotItemSaveDecision decision)

Resolve the pot item confirmation dialog. If decision is kSaveWithPotItems or kSaveWithoutPotItems, the caller should invoke SaveRom() again (with the appropriate bypass).

Definition at line 177 of file rom_lifecycle_manager.cc.

References bypass_pot_item_confirm_once_, kCancel, kSaveWithoutPotItems, pending_pot_item_save_confirm_, pending_pot_item_total_rooms_, pending_pot_item_unloaded_rooms_, and suppress_pot_item_save_once_.

Referenced by yaze::editor::EditorManager::ResolvePotItemSaveConfirmation().

◆ ShouldBypassPotItemConfirm()

bool yaze::editor::RomLifecycleManager::ShouldBypassPotItemConfirm ( ) const
inline

◆ ShouldSuppressPotItemSave()

bool yaze::editor::RomLifecycleManager::ShouldSuppressPotItemSave ( ) const
inline

◆ ClearPotItemBypass()

void yaze::editor::RomLifecycleManager::ClearPotItemBypass ( )
inline

◆ GetRomBackups()

std::vector< RomFileManager::BackupEntry > yaze::editor::RomLifecycleManager::GetRomBackups ( Rom * rom) const

Definition at line 198 of file rom_lifecycle_manager.cc.

References yaze::Rom::filename(), yaze::editor::RomFileManager::ListBackups(), and rom_file_manager_.

Referenced by yaze::editor::EditorManager::GetRomBackups().

Here is the call graph for this function:

◆ PruneRomBackups()

absl::Status yaze::editor::RomLifecycleManager::PruneRomBackups ( Rom * rom)

Definition at line 206 of file rom_lifecycle_manager.cc.

References yaze::Rom::filename(), yaze::editor::RomFileManager::PruneBackups(), and rom_file_manager_.

Referenced by yaze::editor::EditorManager::PruneRomBackups().

Here is the call graph for this function:

◆ ApplyDefaultBackupPolicy()

void yaze::editor::RomLifecycleManager::ApplyDefaultBackupPolicy ( bool enabled,
const std::string & folder,
int retention_count,
bool keep_daily,
int keep_daily_days )

Member Data Documentation

◆ rom_file_manager_

RomFileManager* yaze::editor::RomLifecycleManager::rom_file_manager_ = nullptr
private

◆ session_coordinator_

SessionCoordinator* yaze::editor::RomLifecycleManager::session_coordinator_ = nullptr
private

Definition at line 149 of file rom_lifecycle_manager.h.

Referenced by Initialize().

◆ toast_manager_

ToastManager* yaze::editor::RomLifecycleManager::toast_manager_ = nullptr
private

◆ popup_manager_

PopupManager* yaze::editor::RomLifecycleManager::popup_manager_ = nullptr
private

Definition at line 151 of file rom_lifecycle_manager.h.

Referenced by CheckRomWritePolicy(), and Initialize().

◆ project_

project::YazeProject* yaze::editor::RomLifecycleManager::project_ = nullptr
private

◆ current_rom_hash_

std::string yaze::editor::RomLifecycleManager::current_rom_hash_
private

◆ pending_rom_write_confirm_

bool yaze::editor::RomLifecycleManager::pending_rom_write_confirm_ = false
private

◆ bypass_rom_write_confirm_once_

bool yaze::editor::RomLifecycleManager::bypass_rom_write_confirm_once_ = false
private

◆ pending_pot_item_save_confirm_

bool yaze::editor::RomLifecycleManager::pending_pot_item_save_confirm_ = false
private

◆ pending_pot_item_unloaded_rooms_

int yaze::editor::RomLifecycleManager::pending_pot_item_unloaded_rooms_ = 0
private

◆ pending_pot_item_total_rooms_

int yaze::editor::RomLifecycleManager::pending_pot_item_total_rooms_ = 0
private

◆ bypass_pot_item_confirm_once_

bool yaze::editor::RomLifecycleManager::bypass_pot_item_confirm_once_ = false
private

◆ suppress_pot_item_save_once_

bool yaze::editor::RomLifecycleManager::suppress_pot_item_save_once_ = false
private

◆ pending_write_conflicts_

std::vector<core::WriteConflict> yaze::editor::RomLifecycleManager::pending_write_conflicts_
private

◆ bypass_write_conflict_once_

bool yaze::editor::RomLifecycleManager::bypass_write_conflict_once_ = false
private

The documentation for this class was generated from the following files: