libdisplaydevice master
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
44 [[nodiscard]] const std::shared_ptr<SettingsPersistenceInterface> &getSettingsPersistenceApi() const;
45
46 private:
47 std::shared_ptr<SettingsPersistenceInterface> m_settings_persistence_api;
48 std::optional<SingleDisplayConfigState> m_cached_state;
49 };
50} // 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:53
PersistentState(std::shared_ptr< SettingsPersistenceInterface > settings_persistence_api, bool throw_on_load_error=false)
Definition persistent_state.cpp:25
const std::optional< SingleDisplayConfigState > & getState() const
Get cached state.
Definition persistent_state.cpp:65
const std::shared_ptr< SettingsPersistenceInterface > & getSettingsPersistenceApi() const
Get the settings persistence API.
Definition persistent_state.cpp:69
Declarations for the SettingsPersistenceInterface.
Declarations for the WinDisplayDeviceInterface.