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

Manages the VPS database and its integration with table data in ASAPCabinetFE. More...

#include <vps_database_client.h>

+ Collaboration diagram for VpsDatabaseClient:

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.
 

Detailed Description

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).

Constructor & Destructor Documentation

◆ VpsDatabaseClient()

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.

Parameters
vpsDbPathThe file path to the VPS database (vpsdb.json).

Member Function Documentation

◆ fetchIfNeeded()

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.

Parameters
lastUpdatedPathThe path to the local lastUpdated.json file.
updateFrequencyThe frequency setting (e.g., "startup") to control updates.
progressOptional pointer to LoadingProgress for real-time updates.
Returns
True if the database is valid (exists or updated), false on critical failure.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ load()

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.

Parameters
progressOptional pointer to LoadingProgress for real-time updates.
Returns
True if loading succeeds, false otherwise.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ matchMetadata()

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.

Parameters
vpxTableThe JSON data from a VPX table to use for matchmaking.
tableDataReference to the TableData object to match.
progressOptional pointer to LoadingProgress for real-time updates.
Returns
True if matchmaking succeeds, false otherwise.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

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