Manages the VPS database and its integration with table data in ASAPCabinetFE. More...
#include <vps_database_client.h>
Public Member Functions | |
VpsDatabaseClient (const std::string &vpsDbPath) | |
Constructs a VpsDatabaseClient instance. | |
bool | load (LoadingProgress *progress=nullptr) |
Loads the VPS database from the specified file path. | |
bool | matchMetadata (const nlohmann::json &vpxTable, TableData &tableData, LoadingProgress *progress=nullptr) const |
Enriches a TableData object with VPS database data. | |
bool | fetchIfNeeded (const std::string &lastUpdatedPath, const std::string &updateFrequency, LoadingProgress *progress=nullptr) |
Fetches the VPS database if an update is needed. | |
Manages the VPS database and its integration with table data in ASAPCabinetFE.
This class provides a high-level interface to load, update, and match TableData objects using the VPS database (vpsdb.json). It delegates loading to VpsDatabaseLoader, matchmaking to VpsDataScanner, and updates to VpsDatabaseUpdater, all configured with a single vpsDbPath. Progress is tracked via LoadingProgress, and the client can be extended with configUI for custom settings (e.g., update frequency or matchmaking rules).
VpsDatabaseClient::VpsDatabaseClient | ( | const std::string & | vpsDbPath | ) |
Constructs a VpsDatabaseClient instance.
Initializes the client with the path to the VPS database file, which is used by the loader, matchmaker, and updater components. The matchmaker is initialized with the loaded database data.
vpsDbPath | The file path to the VPS database (vpsdb.json). |
bool VpsDatabaseClient::fetchIfNeeded | ( | const std::string & | lastUpdatedPath, |
const std::string & | updateFrequency, | ||
LoadingProgress * | progress = nullptr |
||
) |
Fetches the VPS database if an update is needed.
Delegates the update process to the internal VpsDatabaseUpdater, checking the last updated timestamp and downloading vpsdb.json if necessary. Progress is tracked via LoadingProgress if provided.
lastUpdatedPath | The path to the local lastUpdated.json file. |
updateFrequency | The frequency setting (e.g., "startup") to control updates. |
progress | Optional pointer to LoadingProgress for real-time updates. |
bool VpsDatabaseClient::load | ( | LoadingProgress * | progress = nullptr | ) |
Loads the VPS database from the specified file path.
Delegates the loading process to the internal VpsDatabaseLoader, parsing vpsdb.json into a JSON object. Progress is tracked via LoadingProgress if provided.
progress | Optional pointer to LoadingProgress for real-time updates. |
bool VpsDatabaseClient::matchMetadata | ( | const nlohmann::json & | vpxTable, |
TableData & | tableData, | ||
LoadingProgress * | progress = nullptr |
||
) | const |
Enriches a TableData object with VPS database data.
Delegates the matchmaking process to the internal VpsDataScanner, matching the vpxTable JSON with the tableData object. Progress is tracked via LoadingProgress if provided.
vpxTable | The JSON data from a VPX table to use for matchmaking. |
tableData | Reference to the TableData object to match. |
progress | Optional pointer to LoadingProgress for real-time updates. |