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

Manages ROM versioning, snapshots, and rollback capabilities. More...

#include <rom_version_manager.h>

Collaboration diagram for yaze::net::RomVersionManager:

Classes

struct  Config
 
struct  Stats
 

Public Member Functions

 RomVersionManager (Rom *rom)
 
 ~RomVersionManager ()
 
absl::Status Initialize (const Config &config)
 
absl::StatusOr< std::string > CreateSnapshot (const std::string &description, const std::string &creator, bool is_checkpoint=false)
 
absl::Status RestoreSnapshot (const std::string &snapshot_id)
 
absl::Status MarkAsSafePoint (const std::string &snapshot_id)
 
std::vector< RomSnapshotGetSnapshots (bool safe_points_only=false) const
 
absl::StatusOr< RomSnapshotGetSnapshot (const std::string &snapshot_id) const
 
absl::Status DeleteSnapshot (const std::string &snapshot_id)
 
absl::StatusOr< VersionDiffGenerateDiff (const std::string &from_id, const std::string &to_id) const
 
absl::StatusOr< bool > DetectCorruption ()
 
absl::Status AutoRecover ()
 
absl::Status ExportSnapshot (const std::string &snapshot_id, const std::string &filepath)
 
absl::Status ImportSnapshot (const std::string &filepath)
 
std::string GetCurrentHash () const
 
absl::Status CleanupOldSnapshots ()
 
Stats GetStats () const
 

Private Member Functions

std::string ComputeRomHash () const
 
std::vector< uint8_t > CompressData (const std::vector< uint8_t > &data) const
 
std::vector< uint8_t > DecompressData (const std::vector< uint8_t > &compressed) const
 
absl::Status ValidateRomIntegrity () const
 
size_t GetTotalStorageUsed () const
 
void PruneOldSnapshots ()
 

Private Attributes

Romrom_
 
Config config_
 
std::map< std::string, RomSnapshotsnapshots_
 
std::string last_known_hash_
 
int64_t last_backup_time_
 

Detailed Description

Manages ROM versioning, snapshots, and rollback capabilities.

Provides:

  • Automatic periodic snapshots
  • Manual checkpoints
  • Rollback to any previous version
  • Diff generation between versions
  • Corruption detection and recovery

Definition at line 66 of file rom_version_manager.h.

Constructor & Destructor Documentation

◆ RomVersionManager()

yaze::net::RomVersionManager::RomVersionManager ( Rom rom)
explicit

Definition at line 51 of file rom_version_manager.cc.

◆ ~RomVersionManager()

yaze::net::RomVersionManager::~RomVersionManager ( )

Definition at line 56 of file rom_version_manager.cc.

Member Function Documentation

◆ Initialize()

absl::Status yaze::net::RomVersionManager::Initialize ( const Config config)

Initialize version management

Definition at line 60 of file rom_version_manager.cc.

References config_, CreateSnapshot(), and MarkAsSafePoint().

Here is the call graph for this function:

◆ CreateSnapshot()

◆ RestoreSnapshot()

◆ MarkAsSafePoint()

absl::Status yaze::net::RomVersionManager::MarkAsSafePoint ( const std::string &  snapshot_id)

◆ GetSnapshots()

std::vector< RomSnapshot > yaze::net::RomVersionManager::GetSnapshots ( bool  safe_points_only = false) const

Get all snapshots, sorted by timestamp

Definition at line 180 of file rom_version_manager.cc.

References snapshots_.

Referenced by yaze::net::CollaborationService::ApplyRomSync(), AutoRecover(), and yaze::gui::CollaborationPanel::RenderVersionHistoryTab().

◆ GetSnapshot()

absl::StatusOr< RomSnapshot > yaze::net::RomVersionManager::GetSnapshot ( const std::string &  snapshot_id) const

Get a specific snapshot

Definition at line 198 of file rom_version_manager.cc.

References snapshots_.

◆ DeleteSnapshot()

absl::Status yaze::net::RomVersionManager::DeleteSnapshot ( const std::string &  snapshot_id)

Delete a snapshot

Definition at line 207 of file rom_version_manager.cc.

References snapshots_.

Referenced by yaze::gui::CollaborationPanel::RenderVersionSnapshot().

◆ GenerateDiff()

absl::StatusOr< VersionDiff > yaze::net::RomVersionManager::GenerateDiff ( const std::string &  from_id,
const std::string &  to_id 
) const

Generate diff between two snapshots

◆ DetectCorruption()

absl::StatusOr< bool > yaze::net::RomVersionManager::DetectCorruption ( )

◆ AutoRecover()

absl::Status yaze::net::RomVersionManager::AutoRecover ( )

Auto-recover from corruption using nearest safe point

Definition at line 252 of file rom_version_manager.cc.

References GetSnapshots(), and RestoreSnapshot().

Here is the call graph for this function:

◆ ExportSnapshot()

absl::Status yaze::net::RomVersionManager::ExportSnapshot ( const std::string &  snapshot_id,
const std::string &  filepath 
)

Export snapshot to file

◆ ImportSnapshot()

absl::Status yaze::net::RomVersionManager::ImportSnapshot ( const std::string &  filepath)

Import snapshot from file

◆ GetCurrentHash()

◆ CleanupOldSnapshots()

absl::Status yaze::net::RomVersionManager::CleanupOldSnapshots ( )

Cleanup old snapshots based on policy

Definition at line 273 of file rom_version_manager.cc.

References config_, GetTotalStorageUsed(), yaze::net::RomVersionManager::Config::max_snapshots, yaze::net::RomVersionManager::Config::max_storage_mb, and snapshots_.

Referenced by CreateSnapshot().

Here is the call graph for this function:

◆ GetStats()

◆ ComputeRomHash()

std::string yaze::net::RomVersionManager::ComputeRomHash ( ) const
private

Definition at line 328 of file rom_version_manager.cc.

References yaze::Rom::data(), yaze::Rom::is_loaded(), rom_, and yaze::Rom::size().

Here is the call graph for this function:

◆ CompressData()

std::vector< uint8_t > yaze::net::RomVersionManager::CompressData ( const std::vector< uint8_t > &  data) const
private

Definition at line 338 of file rom_version_manager.cc.

Referenced by CreateSnapshot().

◆ DecompressData()

std::vector< uint8_t > yaze::net::RomVersionManager::DecompressData ( const std::vector< uint8_t > &  compressed) const
private

Definition at line 345 of file rom_version_manager.cc.

Referenced by RestoreSnapshot().

◆ ValidateRomIntegrity()

absl::Status yaze::net::RomVersionManager::ValidateRomIntegrity ( ) const
private

Definition at line 351 of file rom_version_manager.cc.

References yaze::Rom::is_loaded(), rom_, and yaze::Rom::size().

Referenced by DetectCorruption().

Here is the call graph for this function:

◆ GetTotalStorageUsed()

size_t yaze::net::RomVersionManager::GetTotalStorageUsed ( ) const
private

Definition at line 370 of file rom_version_manager.cc.

References snapshots_.

Referenced by CleanupOldSnapshots().

◆ PruneOldSnapshots()

void yaze::net::RomVersionManager::PruneOldSnapshots ( )
private

Member Data Documentation

◆ rom_

Rom* yaze::net::RomVersionManager::rom_
private

◆ config_

Config yaze::net::RomVersionManager::config_
private

◆ snapshots_

std::map<std::string, RomSnapshot> yaze::net::RomVersionManager::snapshots_
private

◆ last_known_hash_

std::string yaze::net::RomVersionManager::last_known_hash_
private

Definition at line 175 of file rom_version_manager.h.

Referenced by CreateSnapshot(), DetectCorruption(), and RestoreSnapshot().

◆ last_backup_time_

int64_t yaze::net::RomVersionManager::last_backup_time_
private

Definition at line 176 of file rom_version_manager.h.


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