refs #494 Value class CValueCachePacket is a packet of cache value changes with timestamps.

This commit is contained in:
Mathew Sutcliffe
2015-10-22 22:25:34 +01:00
parent a284de3acb
commit eb11b69c6d
6 changed files with 142 additions and 0 deletions

View File

@@ -25,6 +25,42 @@ namespace BlackMisc
bool isSafeToIncrement(const T &value) { return value < std::numeric_limits<T>::max(); }
////////////////////////////////
// CValueCachePacket
////////////////////////////////
CValueCachePacket::CValueCachePacket(const CVariantMap &values, qint64 timestamp)
{
for (auto it = values.cbegin(); it != values.cend(); ++it)
{
implementationOf(*this).insert(CDictionary::cend(), it.key(), std::make_pair(it.value(), timestamp));
}
}
void CValueCachePacket::insert(const QString &key, const CVariant &value, qint64 timestamp)
{
CDictionary::insert(key, std::make_pair(value, timestamp));
}
void CValueCachePacket::insert(const CVariantMap &values, qint64 timestamp)
{
for (auto it = values.cbegin(); it != values.cend(); ++it)
{
CDictionary::insert(it.key(), std::make_pair(it.value(), timestamp));
}
}
CVariantMap CValueCachePacket::toVariantMap() const
{
CVariantMap result;
for (auto it = cbegin(); it != cend(); ++it)
{
implementationOf(result).insert(result.cend(), it.key(), it.value());
}
return result;
}
////////////////////////////////
// CValueCache
////////////////////////////////