mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-26 02:35:38 +08:00
refs #652 Convenience to support changing only an indexed property of a cached value.
This commit is contained in:
@@ -267,7 +267,10 @@ namespace BlackMisc
|
|||||||
}
|
}
|
||||||
|
|
||||||
//! Data cache doesn't support setAndSave (because set() already causes save anyway).
|
//! Data cache doesn't support setAndSave (because set() already causes save anyway).
|
||||||
|
//! @{
|
||||||
CStatusMessage setAndSave(const typename Trait::type &value, qint64 timestamp = 0) = delete;
|
CStatusMessage setAndSave(const typename Trait::type &value, qint64 timestamp = 0) = delete;
|
||||||
|
CStatusMessage setAndSaveProperty(const CPropertyIndex &index, const CVariant &value, qint64 timestamp = 0) = delete;
|
||||||
|
//! @}
|
||||||
|
|
||||||
//! Data cache doesn't support save (because currently set value is saved already).
|
//! Data cache doesn't support save (because currently set value is saved already).
|
||||||
CStatusMessage save() = delete;
|
CStatusMessage save() = delete;
|
||||||
|
|||||||
@@ -312,6 +312,12 @@ namespace BlackMisc
|
|||||||
//! Save using the currently set value. Must be called from the thread in which the owner lives.
|
//! Save using the currently set value. Must be called from the thread in which the owner lives.
|
||||||
CStatusMessage save() { return m_page.setValue(m_element, {}, 0, true, true); }
|
CStatusMessage save() { return m_page.setValue(m_element, {}, 0, true, true); }
|
||||||
|
|
||||||
|
//! Write a property of the value. Must be called from the thread in which the owner lives.
|
||||||
|
CStatusMessage setProperty(const CPropertyIndex &index, const CVariant &value, qint64 timestamp = 0) { auto v = get(); v.setPropertyByIndex(value, index); return set(v, timestamp); }
|
||||||
|
|
||||||
|
//! Write a property and save in the same step. Must be called from the thread in which the owner lives.
|
||||||
|
CStatusMessage setAndSaveProperty(const CPropertyIndex &index, const CVariant &value, qint64 timestamp = 0) { auto v = get(); v.setPropertyByIndex(value, index); return setAndSave(v, timestamp); }
|
||||||
|
|
||||||
//! Is current thread the owner thread, so CCached::set is safe
|
//! Is current thread the owner thread, so CCached::set is safe
|
||||||
bool isOwnerThread() const { return QThread::currentThread() == m_page.thread(); }
|
bool isOwnerThread() const { return QThread::currentThread() == m_page.thread(); }
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user