ASAPCabinetFE
 
Loading...
Searching...
No Matches
AsapIndexManager Class Reference

Manages loading, saving, and merging of ASAP index files for ASAPCabinetFE. More...

#include <asap_index_manager.h>

+ Inheritance diagram for AsapIndexManager:
+ Collaboration diagram for AsapIndexManager:

Public Member Functions

 AsapIndexManager (const Settings &settings)
 Constructs an AsapIndexManager with the given settings.
 
bool load (const Settings &settings, std::vector< TableData > &tables, LoadingProgress *progress=nullptr) override
 Loads table data from the ASAP index file.
 
bool save (const Settings &settings, const std::vector< TableData > &tables, LoadingProgress *progress=nullptr) override
 Saves table data to the ASAP index file.
 
std::vector< TableDatamergeTables (const Settings &settings, const std::vector< TableData > &newTables, LoadingProgress *progress=nullptr) override
 Merges new table data with existing index data.
 

Detailed Description

Manages loading, saving, and merging of ASAP index files for ASAPCabinetFE.

This class provides methods to load table data from an existing ASAP index file, save table data to a new or updated index file, and merge new table data with existing index entries. It uses JSON for data serialization, supports progress tracking with LoadingProgress, and relies on Settings for configuration.

Constructor & Destructor Documentation

◆ AsapIndexManager()

AsapIndexManager::AsapIndexManager ( const Settings settings)

Constructs an AsapIndexManager with the given settings.

Parameters
settingsThe application settings containing the index file path.

Member Function Documentation

◆ load()

bool AsapIndexManager::load ( const Settings settings,
std::vector< TableData > &  tables,
LoadingProgress progress = nullptr 
)
overridevirtual

Loads table data from the ASAP index file.

Attempts to read and parse the asapcab_index.json file specified in settings.indexPath, populating the tables vector with TableData objects.

Parameters
settingsThe application settings containing the index file path.
tablesReference to the vector to store the loaded table data.
progressOptional pointer to LoadingProgress for real-time updates.
Returns
True if loading succeeds, false otherwise.

Implements ITableCallbacks.

+ Here is the caller graph for this function:

◆ mergeTables()

std::vector< TableData > AsapIndexManager::mergeTables ( const Settings settings,
const std::vector< TableData > &  newTables,
LoadingProgress progress = nullptr 
)
overridevirtual

Merges new table data with existing index data.

Compares new table data with existing index entries, updating tables with higher-quality metadata (based on jsonOwner priority), adding new tables, and removing deleted ones. Preserves user fields like playCount. Returns the merged table data.

Parameters
settingsThe application settings containing the index file path.
newTablesThe new table data to merge.
progressOptional pointer to LoadingProgress for real-time updates.
Returns
The merged vector of TableData.

Implements ITableCallbacks.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ save()

bool AsapIndexManager::save ( const Settings settings,
const std::vector< TableData > &  tables,
LoadingProgress progress = nullptr 
)
overridevirtual

Saves table data to the ASAP index file.

Serializes the provided tables vector into a JSON array and writes it to asapcab_index.json at settings.indexPath.

Parameters
settingsThe application settings containing the index file path.
tablesThe vector of TableData to save.
progressOptional pointer to LoadingProgress for real-time updates.
Returns
True if saving succeeds, false otherwise.

Implements ITableCallbacks.

+ Here is the caller graph for this function:

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