SimpleDataStore

Base class for JSON-based persistent data storage.

Declared in src/libs/libstore/store/SimpleDataStore.hpp.

Detailed description

SimpleDataStore wraps AsyncStore with JSON backend for simple persistent storage. Subclasses implement toMap() and fromMap() to serialize their data. Supports async operations with callbacks.

See also AsyncStore, JsonAsyncBackend.

Member function documentation

closeOnDestruction

[protected] bool SimpleDataStore::closeOnDestruction(ConfigureHelper &ownHelper)

Stop the worker, save the last changes and switch the store off.

It calls toMap() directly, on the calling thread, after the worker has ended. In a subclass destructor the frontend cannot reach the store any more: the last strong reference is gone, so its weak lock fails. So the events still queued that need the frontend fail, and this save writes the data they were for.

A deactivation that still waits for the event loop does nothing after this, see activate(). ownHelper is the subclass's own configure helper, which this deactivates too.

Returns false when the final save failed, and true otherwise, also when the store was not active.

In this section