File indexing completed on 2024-05-12 15:59:55
0001 /* 0002 * SPDX-FileCopyrightText: 2021 Dmitry Kazakov <dimula73@gmail.com> 0003 * 0004 * SPDX-License-Identifier: GPL-2.0-or-later 0005 */ 0006 #include "KoResourceCacheStorage.h" 0007 0008 #include <QHash> 0009 #include <QString> 0010 #include <QVariant> 0011 0012 #include "kis_assert.h" 0013 #include "kis_debug.h" 0014 0015 struct KoResourceCacheStorage::Private 0016 { 0017 QHash<QString, QVariant> map; 0018 }; 0019 0020 KoResourceCacheStorage::KoResourceCacheStorage() 0021 : m_d(new Private) 0022 { 0023 } 0024 0025 KoResourceCacheStorage::~KoResourceCacheStorage() 0026 { 0027 } 0028 0029 QVariant KoResourceCacheStorage::fetch(const QString &key) const 0030 { 0031 return m_d->map.value(key, QVariant()); 0032 } 0033 0034 void KoResourceCacheStorage::put(const QString &key, const QVariant &value) 0035 { 0036 /// This assert here is intentional! It catches cache key 0037 /// aliasing problems. See dox in KoResourceCacheInterface 0038 KIS_SAFE_ASSERT_RECOVER_NOOP(!m_d->map.contains(key)); 0039 0040 m_d->map.insert(key, value); 0041 }