libdisplaydevice latest
C++ library to modify display devices.
display_device::SettingsManagerInterface Class Referenceabstract

A class for applying and reverting display device settings. More...

#include <src/common/include/display_device/settings_manager_interface.h>

Inheritance diagram for display_device::SettingsManagerInterface:
[legend]

Public Types

enum class  ApplyResult {
  Ok , ApiTemporarilyUnavailable , DevicePrepFailed , PrimaryDevicePrepFailed ,
  DisplayModePrepFailed , HdrStatePrepFailed , PersistenceSaveFailed
}
 Outcome values when trying to apply settings. More...
 
enum class  RevertResult {
  Ok , ApiTemporarilyUnavailable , TopologyIsInvalid , SwitchingTopologyFailed ,
  RevertingPrimaryDeviceFailed , RevertingDisplayModesFailed , RevertingHdrStatesFailed , PersistenceSaveFailed
}
 Outcome values when trying to revert settings. More...
 

Public Member Functions

virtual ApplyResult applySettings (const SingleDisplayConfiguration &config)=0
 Apply the provided configuration to the system.
 
virtual EnumeratedDeviceList enumAvailableDevices () const =0
 Enumerate the available (active and inactive) devices.
 
virtual std::string getDisplayName (const std::string &device_id) const =0
 Get display name associated with the device.
 
virtual bool resetPersistence ()=0
 Reset the persistence in case the settings cannot be reverted.
 
virtual RevertResult revertSettings ()=0
 Revert the applied configuration and restore the previous settings.
 
virtual ~SettingsManagerInterface ()=default
 Default virtual destructor.
 

Detailed Description

A class for applying and reverting display device settings.

Member Enumeration Documentation

◆ ApplyResult

Outcome values when trying to apply settings.

Enumerator
Ok 

Settings were applied successfully.

ApiTemporarilyUnavailable 

API is temporarily unavailable.

DevicePrepFailed 

Device preparation failed.

PrimaryDevicePrepFailed 

Primary device preparation failed.

DisplayModePrepFailed 

Display mode preparation failed.

HdrStatePrepFailed 

HDR state preparation failed.

PersistenceSaveFailed 

Persistence save failed.

◆ RevertResult

Outcome values when trying to revert settings.

Enumerator
Ok 

Settings were reverted successfully.

ApiTemporarilyUnavailable 

API is temporarily unavailable.

TopologyIsInvalid 

Topology is invalid.

SwitchingTopologyFailed 

Switching topology has failed.

RevertingPrimaryDeviceFailed 

Reverting primary device failed.

RevertingDisplayModesFailed 

Reverting display modes failed.

RevertingHdrStatesFailed 

Reverting HDR states failed.

PersistenceSaveFailed 

Persistence save failed.

Member Function Documentation

◆ applySettings()

virtual ApplyResult display_device::SettingsManagerInterface::applySettings ( const SingleDisplayConfiguration & config)
nodiscardpure virtual

Apply the provided configuration to the system.

Parameters
configA desired configuration for the display device.
Returns
The apply result.

*Examples**

SettingsManagerInterface* iface = getIface(...);
const auto result = iface->applySettings(config);
A class for applying and reverting display device settings.
Definition settings_manager_interface.h:14
virtual ApplyResult applySettings(const SingleDisplayConfiguration &config)=0
Apply the provided configuration to the system.
Configuration centered around a single display.
Definition types.h:132

Implemented in display_device::SettingsManager.

◆ enumAvailableDevices()

virtual EnumeratedDeviceList display_device::SettingsManagerInterface::enumAvailableDevices ( ) const
nodiscardpure virtual

Enumerate the available (active and inactive) devices.

Returns
A list of available devices. Empty list can also be returned if an error has occurred.

*Examples**

const SettingsManagerInterface* iface = getIface(...);
const auto devices { iface->enumAvailableDevices() };
virtual EnumeratedDeviceList enumAvailableDevices() const =0
Enumerate the available (active and inactive) devices.

Implemented in display_device::SettingsManager.

◆ getDisplayName()

virtual std::string display_device::SettingsManagerInterface::getDisplayName ( const std::string & device_id) const
nodiscardpure virtual

Get display name associated with the device.

Parameters
device_idA device to get display name for.
Returns
A display name for the device, or an empty string if the device is inactive or not found. Empty string can also be returned if an error has occurred.

*Examples**

const std::string device_id { "MY_DEVICE_ID" };
const SettingsManagerInterface* iface = getIface(...);
const std::string display_name = iface->getDisplayName(device_id);
virtual std::string getDisplayName(const std::string &device_id) const =0
Get display name associated with the device.

Implemented in display_device::SettingsManager.

◆ resetPersistence()

virtual bool display_device::SettingsManagerInterface::resetPersistence ( )
nodiscardpure virtual

Reset the persistence in case the settings cannot be reverted.

Returns
True if persistence was reset, false otherwise.

In case the settings cannot be reverted, because the display is turned or some other reason, this allows to "accept" the current state and start from scratch, but only if the persistence was cleared successfully.

*Examples**

SettingsManagerInterface* iface = getIface(...);
auto result = iface->applySettings(config);
if (result == ApplyResult::Ok) {
// Wait for some time
if (iface->revertSettings() != RevertResult::Ok) {
// Wait for user input
const bool user_wants_reset { true };
if (user_wants_reset) {
iface->resetPersistence();
}
}
}
virtual bool resetPersistence()=0
Reset the persistence in case the settings cannot be reverted.
virtual RevertResult revertSettings()=0
Revert the applied configuration and restore the previous settings.
@ Ok
Settings were reverted successfully.
@ Ok
Settings were applied successfully.

Implemented in display_device::SettingsManager.

◆ revertSettings()

virtual RevertResult display_device::SettingsManagerInterface::revertSettings ( )
nodiscardpure virtual

Revert the applied configuration and restore the previous settings.

Returns
True if settings were reverted or there was nothing to revert, false otherwise.

*Examples**

SettingsManagerInterface* iface = getIface(...);
const auto result = iface->revertSettings();

Implemented in display_device::SettingsManager.


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