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
12#include "types.h"
13
14namespace display_device {
19 public:
25 explicit MacPersistentState(std::shared_ptr<SettingsPersistenceInterface> settings_persistence_api, bool throw_on_load_error = false);
26
32 [[nodiscard]] bool persistState(const std::optional<MacSingleDisplayConfigState> &state);
33
38 [[nodiscard]] const std::optional<MacSingleDisplayConfigState> &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<MacSingleDisplayConfigState> m_cached_state;
49 };
50} // namespace display_device
A wrapper around SettingsPersistenceInterface and cached macOS state.
Definition persistent_state.h:18
const std::shared_ptr< SettingsPersistenceInterface > & getSettingsPersistenceApi() const
Get the settings persistence API.
Definition persistent_state.cpp:72
const std::optional< MacSingleDisplayConfigState > & getState() const
Get cached state.
Definition persistent_state.cpp:68
MacPersistentState(std::shared_ptr< SettingsPersistenceInterface > settings_persistence_api, bool throw_on_load_error=false)
Default constructor for the class.
Definition persistent_state.cpp:28
bool persistState(const std::optional< MacSingleDisplayConfigState > &state)
Store the new state via the interface and cache it.
Definition persistent_state.cpp:56
Declarations for macOS specific display device types.
Declarations for the SettingsPersistenceInterface.