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

The framework's store: a map held in memory, on its own strand. More...

#include <preferences.hpp>

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

Public Member Functions

 MemoryPreferencesStore (exec::IExecutor &base)
 A store whose strand runs on base.
async::Completion< std::optional< std::string > > get (PrefKey const &key) override
 Reads a choice.
async::Completion< bool > set (PrefKey const &key, std::string json) override
 Writes a choice.
async::Completion< bool > remove (PrefKey const &key) override
 Forgets a choice.
Public Member Functions inherited from morph::ui::IPreferencesStore
 IPreferencesStore (IPreferencesStore const &)=delete
IPreferencesStore & operator= (IPreferencesStore const &)=delete
 IPreferencesStore (IPreferencesStore &&)=delete
IPreferencesStore & operator= (IPreferencesStore &&)=delete

Detailed Description

The framework's store: a map held in memory, on its own strand.

Its entries last as long as it does. Each call is a task on the strand, and its completion is delivered there.

Definition at line 79 of file preferences.hpp.

Constructor & Destructor Documentation

◆ MemoryPreferencesStore()

morph::ui::MemoryPreferencesStore::MemoryPreferencesStore ( exec::IExecutor & base)
inlineexplicit

A store whose strand runs on base.

Parameters
baseWhere the strand's tasks run. Borrowed: it must outlive the store.

Definition at line 83 of file preferences.hpp.

Member Function Documentation

◆ get()

async::Completion< std::optional< std::string > > morph::ui::MemoryPreferencesStore::get ( PrefKey const & key)
inlinenodiscardoverridevirtual

Reads a choice.

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

Implements morph::ui::IPreferencesStore.

Definition at line 88 of file preferences.hpp.

◆ set()

async::Completion< bool > morph::ui::MemoryPreferencesStore::set ( PrefKey const & key,
std::string json )
inlinenodiscardoverridevirtual

Writes a choice.

Parameters
keyThe entry.
jsonIts JSON text.
Returns
true: the memory store refuses nothing.

Implements morph::ui::IPreferencesStore.

Definition at line 101 of file preferences.hpp.

◆ remove()

async::Completion< bool > morph::ui::MemoryPreferencesStore::remove ( PrefKey const & key)
inlinenodiscardoverridevirtual

Forgets a choice.

Parameters
keyThe entry.
Returns
Whether an entry was there.

Implements morph::ui::IPreferencesStore.

Definition at line 113 of file preferences.hpp.


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