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

Concrete implementation of IConfigService for managing configuration. More...

#include <config_service.h>

+ Inheritance diagram for ConfigService:
+ Collaboration diagram for ConfigService:

Public Member Functions

 ConfigService (const std::string &configPath, IKeybindProvider *keybindProvider)
 Constructs a ConfigService instance.
 
 ~ConfigService () override=default
 Virtual destructor for proper cleanup.
 
const SettingsgetSettings () const override
 Gets the current application settings (read-only).
 
SettingsgetMutableSettings () override
 Gets the current application settings (mutable).
 
IKeybindProvidergetKeybindProvider () override
 Gets the keybinding provider.
 
bool isConfigValid () const override
 Checks if the configuration is valid.
 
void loadConfig () override
 Loads configuration data from the JSON file.
 
void saveConfig () override
 Saves the current configuration data to the JSON file.
 
void updateWindowSetup (int &playfieldX, int &playfieldY, int &playfieldWidth, int &playfieldHeight, int &backglassX, int &backglassY, int &backglassWidth, int &backglassHeight, int &dmdX, int &dmdY, int &dmdWidth, int &dmdHeight, int &topperX, int &topperY, int &topperWidth, int &topperHeight) override
 Updates window setup coordinates and dimensions.
 
- Public Member Functions inherited from IConfigService
virtual ~IConfigService ()=default
 Virtual destructor for proper cleanup of derived classes.
 

Detailed Description

Concrete implementation of IConfigService for managing configuration.

This class implements the IConfigService interface to load, save, and validate JSON configuration data, manage keybindings, and apply VPinballX.ini settings when enabled. It handles file operations, post-processing of settings, and updates to window positions, providing a complete configuration solution for ASAPCabinetFE.

Constructor & Destructor Documentation

◆ ConfigService()

ConfigService::ConfigService ( const std::string &  configPath,
IKeybindProvider keybindProvider 
)

Constructs a ConfigService instance.

Initializes the configuration service with the specified configuration file path and keybind provider.

Parameters
configPathThe file path to the configuration file.
keybindProviderUnique pointer to the IKeybindProvider implementation.
+ Here is the call graph for this function:

Member Function Documentation

◆ getKeybindProvider()

IKeybindProvider & ConfigService::getKeybindProvider ( )
overridevirtual

Gets the keybinding provider.

Returns
A reference to the IKeybindProvider object.

Implements IConfigService.

◆ getMutableSettings()

Settings & ConfigService::getMutableSettings ( )
overridevirtual

Gets the current application settings (mutable).

Returns
A reference to the Settings object.

Implements IConfigService.

◆ getSettings()

const Settings & ConfigService::getSettings ( ) const
overridevirtual

Gets the current application settings (read-only).

Returns
A const reference to the Settings object containing current configuration.

Implements IConfigService.

◆ isConfigValid()

bool ConfigService::isConfigValid ( ) const
overridevirtual

Checks if the configuration is valid.

Validates essential parameters such as VPinballXPath and VPXTablesPath.

Returns
True if the configuration is valid, false otherwise.

Implements IConfigService.

◆ loadConfig()

void ConfigService::loadConfig ( )
overridevirtual

Loads configuration data from the JSON file.

Reads and parses the configuration file, applying defaults and VPinballX.ini settings if enabled.

Implements IConfigService.

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

◆ saveConfig()

void ConfigService::saveConfig ( )
overridevirtual

Saves the current configuration data to the JSON file.

Writes the current settings and keybindings to the configuration file.

Implements IConfigService.

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

◆ updateWindowSetup()

void ConfigService::updateWindowSetup ( int &  playfieldX,
int &  playfieldY,
int &  playfieldWidth,
int &  playfieldHeight,
int &  backglassX,
int &  backglassY,
int &  backglassWidth,
int &  backglassHeight,
int &  dmdX,
int &  dmdY,
int &  dmdWidth,
int &  dmdHeight,
int &  topperX,
int &  topperY,
int &  topperWidth,
int &  topperHeight 
)
overridevirtual

Updates window setup coordinates and dimensions.

Updates the configuration with the current window positions and sizes, then saves the changes to the JSON file.

Parameters
playfieldXReference to the playfield window X coordinate.
playfieldYReference to the playfield window Y coordinate.
playfieldWidthReference to the playfield window width.
playfieldHeightReference to the playfield window height.
backglassXReference to the backglass window X coordinate.
backglassYReference to the backglass window Y coordinate.
backglassWidthReference to the backglass window width.
backglassHeightReference to the backglass window height.
dmdXReference to the DMD window X coordinate.
dmdYReference to the DMD window Y coordinate.
dmdWidthReference to the DMD window width.
dmdHeightReference to the DMD window height.
topperXReference to the topper window X coordinate.
topperYReference to the topper window Y coordinate.
topperWidthReference to the topper window width.
topperHeightReference to the topper window height.

Implements IConfigService.

+ Here is the call graph for this function:

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