morph 0.1.0
Asynchronous bridge between GUI thread and business models
Loading...
Searching...
No Matches
morph::ui::IPreferencesStore Class Referenceabstract

Stores customization choices as JSON text, by PrefKey. More...

#include <preferences.hpp>

Inheritance diagram for morph::ui::IPreferencesStore:
morph::ui::MemoryPreferencesStore

Public Member Functions

 IPreferencesStore (IPreferencesStore const &)=delete
IPreferencesStore & operator= (IPreferencesStore const &)=delete
 IPreferencesStore (IPreferencesStore &&)=delete
IPreferencesStore & operator= (IPreferencesStore &&)=delete
virtual async::Completion< std::optional< std::string > > get (PrefKey const &key)=0
 Reads a choice.
virtual async::Completion< bool > set (PrefKey const &key, std::string json)=0
 Writes a choice, replacing what was stored.
virtual async::Completion< bool > remove (PrefKey const &key)=0
 Forgets a choice, so the point is at the document's default again.

Detailed Description

Stores customization choices as JSON text, by PrefKey.

Every call is asynchronous, so a store may sit on a database or a remote service. A store owns the executor its completions are delivered on. The preferences model calls it only with keys whose person the server derived and with values it has already bounded and parsed, so a store applies no bound of its own.

Definition at line 50 of file preferences.hpp.

Member Function Documentation

◆ get()

virtual async::Completion< std::optional< std::string > > morph::ui::IPreferencesStore::get ( PrefKey const & key)
nodiscardpure virtual

Reads a choice.

Parameters
keyThe entry.
Returns
Its JSON text, or std::nullopt when nothing is stored.

Implemented in morph::ui::MemoryPreferencesStore.

◆ set()

virtual async::Completion< bool > morph::ui::IPreferencesStore::set ( PrefKey const & key,
std::string json )
nodiscardpure virtual

Writes a choice, replacing what was stored.

Parameters
keyThe entry.
jsonIts JSON text.
Returns
Whether it was stored; false is a refusal the caller reports.

Implemented in morph::ui::MemoryPreferencesStore.

◆ remove()

virtual async::Completion< bool > morph::ui::IPreferencesStore::remove ( PrefKey const & key)
nodiscardpure virtual

Forgets a choice, so the point is at the document's default again.

Parameters
keyThe entry.
Returns
Whether an entry was there.

Implemented in morph::ui::MemoryPreferencesStore.


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