game_launcher 1.1.0
Modern Linux game launcher with Steam / Proton / Wine integration
Loading...
Searching...
No Matches
PerformanceProfileService Class Reference

Service for managing per-game performance profiles. More...

#include <performance_profile_service.h>

Classes

class  Impl

Public Types

using OnProfileChanged

Public Member Functions

 PerformanceProfileService ()
 PerformanceProfileService (const PerformanceProfileService &)=delete
 ~PerformanceProfileService ()
PerformanceProfile createFromPreset (PerformancePreset preset, const std::string &name="") const
 Create a profile from a preset.
bool createGlobalProfile (const PerformanceProfile &profile)
 Create a global profile.
bool createProfile (const std::string &gameId, const PerformanceProfile &profile)
 Create a new performance profile for a game.
PerformanceProfile createSmartDefault (const std::string &gameId, const std::string &protondbTier="") const
 Create game-specific default profile based on system info.
bool deleteProfile (const std::string &gameId, const std::string &profileId)
 Delete a profile.
std::string duplicateProfile (const std::string &gameId, const std::string &sourceProfileId, const std::string &newName)
 Duplicate an existing profile.
bool exportGameProfiles (const std::string &gameId, const std::string &filePath) const
 Export all profiles for a game.
std::string exportProfileToJson (const PerformanceProfile &profile) const
 Export a profile to JSON.
std::optional< PerformanceProfile > getActiveProfile (const std::string &gameId) const
 Get the active profile for a game.
PerformanceProfile getDefaultProfile () const
 Get the default profile template.
int getGamesWithProfilesCount () const
 Get number of games with custom profiles.
std::vector< PerformanceProfile > getGlobalProfiles () const
 Get global profiles (shared across games).
std::optional< PerformanceProfile > getMostUsedProfile (const std::string &gameId) const
 Get most used profile for a game.
std::optional< PerformanceProfile > getProfile (const std::string &gameId, const std::string &profileId) const
 Get a specific profile.
std::vector< PerformanceProfile > getProfiles (const std::string &gameId) const
 Get all profiles for a game.
int getTotalProfileCount () const
 Get total number of profiles.
int importGameProfiles (const std::string &gameId, const std::string &filePath)
 Import profiles for a game.
std::optional< PerformanceProfile > importProfileFromJson (const std::string &json) const
 Import a profile from JSON.
bool initialize (const std::string &dataDir)
 Initialize the service with a data directory.
bool isInitialized () const
 Check if service is initialized.
bool linkToGlobalProfile (const std::string &gameId, const std::string &globalProfileId)
 Link a game to use a global profile.
PerformanceProfileService & operator= (const PerformanceProfileService &)=delete
std::map< std::string, std::string > profileToEnvVars (const PerformanceProfile &profile) const
 Convert a profile to environment variables.
std::vector< std::string > profileToGamescopeArgs (const PerformanceProfile &profile) const
 Convert a profile to Gamescope arguments.
void recordMetrics (const std::string &gameId, const std::string &profileId, double avgFps, double avgFrametime)
 Record performance metrics for a profile.
bool setActiveProfile (const std::string &gameId, const std::string &profileId)
 Set the active profile for a game.
void setOnProfileChanged (OnProfileChanged callback)
bool updateProfile (const std::string &gameId, const PerformanceProfile &profile)
 Update an existing profile.

Detailed Description

Service for managing per-game performance profiles.

Provides Steam Deck-style performance profile management, allowing users to save and switch between different performance configurations per game.

Definition at line 220 of file performance_profile_service.h.

Member Typedef Documentation

◆ OnProfileChanged

Initial value:
std::function<void(const std::string& gameId, const std::string& profileId)>

Definition at line 223 of file performance_profile_service.h.

Constructor & Destructor Documentation

◆ PerformanceProfileService() [1/2]

PerformanceProfileService::PerformanceProfileService ( )

Definition at line 543 of file performance_profile_service.cpp.

Referenced by PerformanceProfileService(), and operator=().

◆ ~PerformanceProfileService()

PerformanceProfileService::~PerformanceProfileService ( )
default

◆ PerformanceProfileService() [2/2]

PerformanceProfileService::PerformanceProfileService ( const PerformanceProfileService & )
delete

Member Function Documentation

◆ createFromPreset()

◆ createGlobalProfile()

bool PerformanceProfileService::createGlobalProfile ( const PerformanceProfile & profile)

Create a global profile.

Parameters
profileProfile to create globally
Returns
True if created successfully

Definition at line 1044 of file performance_profile_service.cpp.

References PerformanceProfile::createdAt, exportProfileToJson(), generateUUID(), and PerformanceProfile::id.

◆ createProfile()

bool PerformanceProfileService::createProfile ( const std::string & gameId,
const PerformanceProfile & profile )

Create a new performance profile for a game.

Parameters
gameIdGame ID
profileProfile to create
Returns
True if created successfully

Definition at line 557 of file performance_profile_service.cpp.

References PerformanceProfile::createdAt, generateUUID(), PerformanceProfile::id, PerformanceProfile::name, and Logger::warn().

Referenced by duplicateProfile().

◆ createSmartDefault()

PerformanceProfile PerformanceProfileService::createSmartDefault ( const std::string & gameId,
const std::string & protondbTier = "" ) const

◆ deleteProfile()

bool PerformanceProfileService::deleteProfile ( const std::string & gameId,
const std::string & profileId )

Delete a profile.

Parameters
gameIdGame ID
profileIdProfile ID to delete
Returns
True if deleted successfully

Definition at line 627 of file performance_profile_service.cpp.

References PerformanceProfile::id, and Logger::warn().

◆ duplicateProfile()

std::string PerformanceProfileService::duplicateProfile ( const std::string & gameId,
const std::string & sourceProfileId,
const std::string & newName )

Duplicate an existing profile.

Parameters
gameIdGame ID
sourceProfileIdProfile to duplicate
newNameName for the duplicate
Returns
New profile ID, or empty if failed

Definition at line 669 of file performance_profile_service.cpp.

References PerformanceProfile::createdAt, createProfile(), generateUUID(), getProfile(), PerformanceProfile::id, PerformanceProfile::lastUsedAt, PerformanceProfile::name, and PerformanceProfile::useCount.

◆ exportGameProfiles()

bool PerformanceProfileService::exportGameProfiles ( const std::string & gameId,
const std::string & filePath ) const

Export all profiles for a game.

Parameters
gameIdGame ID
filePathOutput file path
Returns
True if export succeeded

Definition at line 1140 of file performance_profile_service.cpp.

References exportProfileToJson().

◆ exportProfileToJson()

◆ getActiveProfile()

std::optional< PerformanceProfile > PerformanceProfileService::getActiveProfile ( const std::string & gameId) const

Get the active profile for a game.

Parameters
gameIdGame ID
Returns
Active profile if one is set

Definition at line 722 of file performance_profile_service.cpp.

References getProfile().

◆ getDefaultProfile()

PerformanceProfile PerformanceProfileService::getDefaultProfile ( ) const

Get the default profile template.

Returns
Default profile with balanced settings

Definition at line 837 of file performance_profile_service.cpp.

References Balanced, and createFromPreset().

Referenced by createSmartDefault().

◆ getGamesWithProfilesCount()

int PerformanceProfileService::getGamesWithProfilesCount ( ) const

Get number of games with custom profiles.

Definition at line 1246 of file performance_profile_service.cpp.

◆ getGlobalProfiles()

std::vector< PerformanceProfile > PerformanceProfileService::getGlobalProfiles ( ) const

Get global profiles (shared across games).

Returns
Vector of global profiles

Definition at line 1039 of file performance_profile_service.cpp.

◆ getMostUsedProfile()

std::optional< PerformanceProfile > PerformanceProfileService::getMostUsedProfile ( const std::string & gameId) const

Get most used profile for a game.

Parameters
gameIdGame ID
Returns
Most used profile if data available

Definition at line 1252 of file performance_profile_service.cpp.

◆ getProfile()

std::optional< PerformanceProfile > PerformanceProfileService::getProfile ( const std::string & gameId,
const std::string & profileId ) const

Get a specific profile.

Parameters
gameIdGame ID
profileIdProfile ID
Returns
Profile if found

Definition at line 704 of file performance_profile_service.cpp.

Referenced by duplicateProfile(), and getActiveProfile().

◆ getProfiles()

std::vector< PerformanceProfile > PerformanceProfileService::getProfiles ( const std::string & gameId) const

Get all profiles for a game.

Parameters
gameIdGame ID
Returns
Vector of profiles

Definition at line 693 of file performance_profile_service.cpp.

◆ getTotalProfileCount()

int PerformanceProfileService::getTotalProfileCount ( ) const

Get total number of profiles.

Definition at line 1235 of file performance_profile_service.cpp.

◆ importGameProfiles()

int PerformanceProfileService::importGameProfiles ( const std::string & gameId,
const std::string & filePath )

Import profiles for a game.

Parameters
gameIdGame ID
filePathInput file path
Returns
Number of profiles imported

Definition at line 1166 of file performance_profile_service.cpp.

References generateUUID(), PerformanceProfile::id, and jsonParseProfile().

◆ importProfileFromJson()

std::optional< PerformanceProfile > PerformanceProfileService::importProfileFromJson ( const std::string & json) const

Import a profile from JSON.

Parameters
jsonJSON string
Returns
Parsed profile if valid

Definition at line 1132 of file performance_profile_service.cpp.

References PerformanceProfile::id, and jsonParseProfile().

◆ initialize()

bool PerformanceProfileService::initialize ( const std::string & dataDir)

Initialize the service with a data directory.

Parameters
dataDirDirectory to store profile data
Returns
True if initialization succeeded

Definition at line 547 of file performance_profile_service.cpp.

◆ isInitialized()

bool PerformanceProfileService::isInitialized ( ) const

Check if service is initialized.

Definition at line 552 of file performance_profile_service.cpp.

◆ linkToGlobalProfile()

bool PerformanceProfileService::linkToGlobalProfile ( const std::string & gameId,
const std::string & globalProfileId )

Link a game to use a global profile.

Parameters
gameIdGame ID
globalProfileIdGlobal profile ID
Returns
True if linked successfully

Definition at line 1067 of file performance_profile_service.cpp.

◆ operator=()

PerformanceProfileService & PerformanceProfileService::operator= ( const PerformanceProfileService & )
delete

◆ profileToEnvVars()

◆ profileToGamescopeArgs()

std::vector< std::string > PerformanceProfileService::profileToGamescopeArgs ( const PerformanceProfile & profile) const

◆ recordMetrics()

void PerformanceProfileService::recordMetrics ( const std::string & gameId,
const std::string & profileId,
double avgFps,
double avgFrametime )

Record performance metrics for a profile.

Parameters
gameIdGame ID
profileIdProfile that was active
avgFpsAverage FPS achieved
avgFrametimeAverage frametime achieved

Definition at line 1020 of file performance_profile_service.cpp.

◆ setActiveProfile()

bool PerformanceProfileService::setActiveProfile ( const std::string & gameId,
const std::string & profileId )

Set the active profile for a game.

Parameters
gameIdGame ID
profileIdProfile ID to activate
Returns
True if activated successfully

Definition at line 731 of file performance_profile_service.cpp.

◆ setOnProfileChanged()

void PerformanceProfileService::setOnProfileChanged ( OnProfileChanged callback)

Definition at line 1230 of file performance_profile_service.cpp.

◆ updateProfile()

bool PerformanceProfileService::updateProfile ( const std::string & gameId,
const PerformanceProfile & profile )

Update an existing profile.

Parameters
gameIdGame ID
profileUpdated profile (matched by profile.id)
Returns
True if updated successfully

Definition at line 604 of file performance_profile_service.cpp.

References PerformanceProfile::id.


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