138 bool updateGame(
const std::string& gameId,
const Game& updatedGame);
148 std::optional<Game*>
getGame(
const std::string& gameId);
155 std::optional<const Game*>
getGame(
const std::string& gameId)
const;
223 std::vector<PlaySession>
getRecentSessions(
const std::string& gameId,
int limit = 20)
const;
245 std::vector<Game*>
searchGames(std::string_view query);
252 std::vector<const Game*>
searchGames(std::string_view query)
const;
376 std::string generateUniqueId()
const;
379 std::string getLibraryPath()
const;
382 std::string getGameFilePath(
const std::string& gameId)
const;
385 void invalidateCaches();
388 void reloadFromDatabase();
395 std::unique_ptr<GameDatabase> database_;
398 std::map<std::string, Game> games_;
401 std::vector<std::string> collections_;
404 std::string libraryPath_;
411 mutable std::vector<Game*> cachedAllGames_;
412 mutable std::vector<const Game*> cachedAllGamesConst_;
413 mutable bool allGamesCacheValid_ =
false;
414 mutable bool allGamesConstCacheValid_ =
false;
417 mutable std::vector<Game*> cachedRecentGames_;
418 mutable std::vector<const Game*> cachedRecentGamesConst_;
419 mutable bool recentGamesCacheValid_ =
false;
420 mutable bool recentGamesConstCacheValid_ =
false;
424 mutable int cachedRecentGamesCount_ = 0;
425 mutable int cachedRecentGamesConstCount_ = 0;
std::vector< Game * > getInstalledGames()
Get all installed games.
int refreshStaleImages()
Refresh images for games with stale/missing image files.
std::vector< PlaySession > getRecentSessions(const std::string &gameId, int limit=20) const
Get recent play sessions for a game from the database.
~GameLibrary()
Destructor - cleanup.
std::vector< std::string > getCollectionNames() const
Get list of all collection names.
std::vector< Game * > searchGames(std::string_view query)
Search games by name (case-insensitive substring match).
std::string addGame(const Game &game)
Add a new game to the library.
int discoverMissingImages()
Discover and update images for games missing cover art.
std::vector< Game * > getFavorites()
Get all favorite games.
std::vector< Game * > getGamesByPlatform(GamePlatform platform)
Get games filtered by platform.
std::optional< Game * > getGame(const std::string &gameId)
Get a game by ID.
int getTotalGameCount() const
Get total number of games in library.
std::vector< Game * > getGamesInCollection(const std::string &collectionName)
Get games in a specific collection.
void addGameToCollection(const std::string &gameId, const std::string &collection)
Add a game to a collection.
void loadFromDisk()
Load library from disk.
bool updateGame(const std::string &gameId, const Game &updatedGame)
Update an existing game.
int getInstalledGameCount() const
Get number of installed games.
GameLibrary()
Constructor - initializes library path.
std::vector< Game * > getAllGames()
Get all games in the library.
bool removeGame(const std::string &gameId)
Remove a game from the library.
void deleteCollection(const std::string &name)
Delete a collection.
bool discoverImagesForGame(const std::string &gameId)
Discover images for a specific game.
void removeGameFromCollection(const std::string &gameId, const std::string &collection)
Remove a game from a collection.
void saveToDisk()
Save library to disk.
void createCollection(const std::string &name)
Create a new empty collection.
std::vector< Game * > getRecentlyPlayed(int count=10)
Get recently played games.
double getTotalPlayTime() const
Get total play time across all games.
Complete representation of a game in the library.
GamePlatform
Platform/runner type for executing the game.