libdisplaydevice v2026.322.2407
C++ library to modify display devices.
persistent_state.h
Go to the documentation of this file.
1
5#pragma once
6
7// system includes
8#include <memory>
9
10// local includes
13
14namespace display_device {
19 public:
25 explicit PersistentState(std::shared_ptr<SettingsPersistenceInterface> settings_persistence_api, bool throw_on_load_error = false);
26
32 [[nodiscard]] bool persistState(const std::optional<SingleDisplayConfigState> &state);
33
38 [[nodiscard]] const std::optional<SingleDisplayConfigState> &getState() const;
39
40 protected:
41 std::shared_ptr<SettingsPersistenceInterface> m_settings_persistence_api;
42
43 private:
44 std::optional<SingleDisplayConfigState> m_cached_state;
45 };
46} // namespace display_device
A simple wrapper around the SettingsPersistenceInterface and cached local state to keep them in sync.
Definition persistent_state.h:18
bool persistState(const std::optional< SingleDisplayConfigState > &state)
Store the new state via the interface and cache it.
Definition persistent_state.cpp:42
PersistentState(std::shared_ptr< SettingsPersistenceInterface > settings_persistence_api, bool throw_on_load_error=false)
Definition persistent_state.cpp:14
const std::optional< SingleDisplayConfigState > & getState() const
Get cached state.
Definition persistent_state.cpp:72
Declarations for the SettingsPersistenceInterface.
Declarations for the WinDisplayDeviceInterface.