mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-23 23:45:35 +08:00
refs #494 Value class CValueCachePacket is a packet of cache value changes with timestamps.
This commit is contained in:
@@ -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
|
||||
////////////////////////////////
|
||||
|
||||
Reference in New Issue
Block a user