refs #545 CSetting<T>::setAndSave to set and save a setting in one step.

This commit is contained in:
Mathew Sutcliffe
2016-01-10 20:43:21 +00:00
parent d9167cf226
commit 956d393bb1
7 changed files with 33 additions and 6 deletions

View File

@@ -180,6 +180,10 @@ namespace BlackMisc
//! of CValueCache instances in all processes including this one. The slot will do its own round-trip detection.
void valuesChangedByLocal(const BlackMisc::CValueCachePacket &values);
//! Emitted when this cache has ratified a change which included a request to save (i.e. via CCaches::setAndSave).
//! If the derived class does not handle such requests, the signal can be ignored.
void valuesSaveRequested(const BlackMisc::CValueCachePacket &values);
private:
struct Element; // remove forward declaration when elementsStartingWith uses C++14 auto deduced return type
@@ -274,6 +278,9 @@ namespace BlackMisc
//! Write a new value. Must be called from the thread in which the owner lives.
CStatusMessage set(const T &value) { return m_page.setValue(m_element, CVariant::from(value)); }
//! Write and save in the same step. Must be called from the thread in which the owner lives.
CStatusMessage setAndSave(const T &value) { return m_page.setValue(m_element, CVariant::from(value), true); }
//! Get the key string of this value.
const QString &getKey() const { return m_page.getKey(m_element); }