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

#include <KoResourceCacheStorage.h>

+ Inheritance diagram for KoResourceCacheStorage:

Classes

struct  Private
 

Public Member Functions

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

Private Attributes

const QScopedPointer< Privatem_d
 

Additional Inherited Members

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

Detailed Description

A trivial implementation of KoResourceCacheInterface that just stores cached values.

Definition at line 17 of file KoResourceCacheStorage.h.

Constructor & Destructor Documentation

◆ KoResourceCacheStorage()

KoResourceCacheStorage::KoResourceCacheStorage ( )

Definition at line 20 of file KoResourceCacheStorage.cpp.

21 : m_d(new Private)
22{
23}
const QScopedPointer< Private > m_d

◆ ~KoResourceCacheStorage()

KoResourceCacheStorage::~KoResourceCacheStorage ( )

Definition at line 25 of file KoResourceCacheStorage.cpp.

26{
27}

Member Function Documentation

◆ fetch()

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

fetch a cached object from the cache using key

Implements KoResourceCacheInterface.

Definition at line 29 of file KoResourceCacheStorage.cpp.

30{
31 return m_d->map.value(key, QVariant());
32}

References m_d.

◆ put()

void KoResourceCacheStorage::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.

This assert here is intentional! It catches cache key aliasing problems. See dox in KoResourceCacheInterface

Implements KoResourceCacheInterface.

Definition at line 34 of file KoResourceCacheStorage.cpp.

35{
38 KIS_SAFE_ASSERT_RECOVER_NOOP(!m_d->map.contains(key));
39
40 m_d->map.insert(key, value);
41}
float value(const T *src, size_t ch)
#define KIS_SAFE_ASSERT_RECOVER_NOOP(cond)
Definition kis_assert.h:130

References KIS_SAFE_ASSERT_RECOVER_NOOP, m_d, and value().

Member Data Documentation

◆ m_d

const QScopedPointer<Private> KoResourceCacheStorage::m_d
private

Definition at line 28 of file KoResourceCacheStorage.h.


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