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 #ifndef KORESOURCECACHEPREFIXEDSTORAGEWRAPPER_H
0007 #define KORESOURCECACHEPREFIXEDSTORAGEWRAPPER_H
0008 
0009 #include <KoResourceCacheInterface.h>
0010 #include <QString>
0011 
0012 /**
0013  * A simple wrapper class that converts all the passed cache keys
0014  * into a prefixed notation: "key" -> "prefix/key".
0015  *
0016  * This wrapper is usually needed when handing embedded objects
0017  * using the same cache storage, e.g. masking brush preset, which
0018  * is stored inside a normal preset under a prefix
0019  * ("MaskingBrush/Preset/")
0020  */
0021 class KRITARESOURCES_EXPORT KoResourceCachePrefixedStorageWrapper : public KoResourceCacheInterface
0022 {
0023 public:
0024     KoResourceCachePrefixedStorageWrapper(const QString &prefix, KoResourceCacheInterfaceSP baseInterface);
0025 
0026     QVariant fetch(const QString &key) const override;
0027     void put(const QString &key, const QVariant &value) override;
0028 
0029 private:
0030     QString m_prefix;
0031     KoResourceCacheInterfaceSP m_baseInterface;
0032 
0033 };
0034 
0035 #endif // KORESOURCECACHEPREFIXEDSTORAGEWRAPPER_H