Krita Source Code Documentation
Loading...
Searching...
No Matches
KoResourceCachePrefixedStorageWrapper Class Reference

#include <KoResourceCachePrefixedStorageWrapper.h>

+ Inheritance diagram for KoResourceCachePrefixedStorageWrapper:

Public Member Functions

QVariant fetch (const QString &key) const override
 fetch a cached object from the cache using key
 
 KoResourceCachePrefixedStorageWrapper (const QString &prefix, KoResourceCacheInterfaceSP baseInterface)
 
void put (const QString &key, const QVariant &value) override
 
- Public Member Functions inherited from KoResourceCacheInterface
RelatedResourceCookie relatedResourceCookie () const
 
void setRelatedResourceCookie (RelatedResourceCookie cookie)
 
virtual ~KoResourceCacheInterface ()
 

Private Attributes

KoResourceCacheInterfaceSP m_baseInterface
 
QString m_prefix
 

Additional Inherited Members

- Public Types inherited from KoResourceCacheInterface
using RelatedResourceCookie = std::uintptr_t
 

Detailed Description

A simple wrapper class that converts all the passed cache keys into a prefixed notation: "key" -> "prefix/key".

This wrapper is usually needed when handing embedded objects using the same cache storage, e.g. masking brush preset, which is stored inside a normal preset under a prefix ("MaskingBrush/Preset/")

Definition at line 21 of file KoResourceCachePrefixedStorageWrapper.h.

Constructor & Destructor Documentation

◆ KoResourceCachePrefixedStorageWrapper()

KoResourceCachePrefixedStorageWrapper::KoResourceCachePrefixedStorageWrapper ( const QString & prefix,
KoResourceCacheInterfaceSP baseInterface )

Member Function Documentation

◆ fetch()

QVariant KoResourceCachePrefixedStorageWrapper::fetch ( const QString & key) const
overridevirtual

fetch a cached object from the cache using key

Implements KoResourceCacheInterface.

Definition at line 17 of file KoResourceCachePrefixedStorageWrapper.cpp.

18{
19 return m_baseInterface->fetch(m_prefix + key);
20}

References m_baseInterface, and m_prefix.

◆ put()

void KoResourceCachePrefixedStorageWrapper::put ( const QString & key,
const QVariant & value )
overridevirtual

store a cached object value into the cache using key WARNING: storing an object twice with the same key is considered as invalid operation and will assert! This behavior is intentional to avoid cache key aliasing.

Implements KoResourceCacheInterface.

Definition at line 22 of file KoResourceCachePrefixedStorageWrapper.cpp.

23{
24 m_baseInterface->put(m_prefix + key, value);
25}
float value(const T *src, size_t ch)

References m_baseInterface, m_prefix, and value().

Member Data Documentation

◆ m_baseInterface

KoResourceCacheInterfaceSP KoResourceCachePrefixedStorageWrapper::m_baseInterface
private

Definition at line 31 of file KoResourceCachePrefixedStorageWrapper.h.

◆ m_prefix

QString KoResourceCachePrefixedStorageWrapper::m_prefix
private

Definition at line 30 of file KoResourceCachePrefixedStorageWrapper.h.


The documentation for this class was generated from the following files: