Caches: method to query keys of all unsaved values.

This commit is contained in:
Mathew Sutcliffe
2016-06-08 21:39:12 +01:00
parent 183c4d9528
commit 000e22246f
2 changed files with 15 additions and 0 deletions

View File

@@ -201,6 +201,17 @@ namespace BlackMisc
return map;
}
QStringList CValueCache::getAllUnsavedKeys(const QString &keyPrefix) const
{
QMutexLocker lock(&m_mutex);
QStringList keys;
for (const auto &element : elementsStartingWith(keyPrefix))
{
if (element->m_value.isValid() && ! element->m_saved) { keys.push_back(element->m_key); }
}
return keys;
}
void CValueCache::insertValues(const CValueCachePacket &values)
{
QMutexLocker lock(&m_mutex);

View File

@@ -171,6 +171,10 @@ namespace BlackMisc
//! \threadsafe
BlackMisc::CValueCachePacket getAllValuesWithTimestamps(const QString &keyPrefix = {}) const;
//! Return keys of all values which have been changed but not saved.
//! \threadsafe
QStringList getAllUnsavedKeys(const QString &keyPrefix = {}) const;
//! Add some values to the cache.
//! Values already in the cache will remain in the cache unless they are overwritten.
//! \threadsafe