Krita Source Code Documentation
Loading...
Searching...
No Matches
KisResourcesInterface::TypedResourceSourceAdapter< T > Class Template Reference

#include <KisResourcesInterface.h>

Public Member Functions

QSharedPointer< T > bestMatch (const QString md5, const QString filename, const QString name)
 bestMatch retrieves a resource, preferably by md5, but with filename and name as fallback for older files that do not store the md5sum. If the resource is not found by md5 and the md5 isn't empty, then it will try to fallback to searching by filename, but will show a warning in case sanity checks are enabled.
 
KoResourceLoadResult bestMatchLoadResult (const QString md5, const QString filename, const QString name)
 
QSharedPointer< T > exactMatch (const QString md5, const QString filename, const QString name)
 exactMatch retrieves a resource, preferably by md5, but with filename and name as fallback for older files that do not store the md5sum. If the resource is not found by md5 and the md5 isn't empty, then nullptr is returned (that is the difference to bestMatch).
 
QSharedPointer< T > fallbackResource () const
 
 TypedResourceSourceAdapter (ResourceSourceAdapter *adapter)
 

Protected Attributes

ResourceSourceAdapterm_source
 

Private Member Functions

QVector< QSharedPointer< T > > resourcesForFilename (const QString &filename) const
 
QVector< QSharedPointer< T > > resourcesForMD5 (const QString &md5) const
 
QVector< QSharedPointer< T > > resourcesForName (const QString &name) const
 

Detailed Description

template<typename T>
class KisResourcesInterface::TypedResourceSourceAdapter< T >

Definition at line 99 of file KisResourcesInterface.h.

Constructor & Destructor Documentation

◆ TypedResourceSourceAdapter()

template<typename T >
KisResourcesInterface::TypedResourceSourceAdapter< T >::TypedResourceSourceAdapter ( ResourceSourceAdapter * adapter)
inline

Definition at line 102 of file KisResourcesInterface.h.

103 : m_source(adapter)
104 {
105 }

Member Function Documentation

◆ bestMatch()

template<typename T >
QSharedPointer< T > KisResourcesInterface::TypedResourceSourceAdapter< T >::bestMatch ( const QString md5,
const QString filename,
const QString name )
inline

bestMatch retrieves a resource, preferably by md5, but with filename and name as fallback for older files that do not store the md5sum. If the resource is not found by md5 and the md5 isn't empty, then it will try to fallback to searching by filename, but will show a warning in case sanity checks are enabled.

If multiple resources with the same md5 exist, then it prefers the one with the same filename and name.

Returns
a resource, or 0 of the resource doesn't exist.

Definition at line 146 of file KisResourcesInterface.h.

146 {
147 return m_source->bestMatch(md5, filename, name).dynamicCast<T>();
148 }
KoResourceSP bestMatch(const QString md5, const QString filename, const QString name)
bestMatch retrieves a resource, preferably by md5, but with filename and name as fallback for older f...

◆ bestMatchLoadResult()

template<typename T >
KoResourceLoadResult KisResourcesInterface::TypedResourceSourceAdapter< T >::bestMatchLoadResult ( const QString md5,
const QString filename,
const QString name )
inline

Same as bestMatch(), but returns KoResourceLoadResult. In case the resource is not found in the backend storage, the load-result will be set in FailedLink state

Definition at line 171 of file KisResourcesInterface.h.

171 {
172 return m_source->bestMatchLoadResult(md5, filename, name);
173 }
KoResourceLoadResult bestMatchLoadResult(const QString md5, const QString filename, const QString name)

◆ exactMatch()

template<typename T >
QSharedPointer< T > KisResourcesInterface::TypedResourceSourceAdapter< T >::exactMatch ( const QString md5,
const QString filename,
const QString name )
inline

exactMatch retrieves a resource, preferably by md5, but with filename and name as fallback for older files that do not store the md5sum. If the resource is not found by md5 and the md5 isn't empty, then nullptr is returned (that is the difference to bestMatch).

If multiple resources with the same md5 exist, then it prefers the one with the same filename and name.

Returns
a resource, or 0 of the resource doesn't exist.

Definition at line 161 of file KisResourcesInterface.h.

161 {
162 return m_source->exactMatch(md5, filename, name).dynamicCast<T>();
163 }
KoResourceSP exactMatch(const QString md5, const QString filename, const QString name)
exactMatch retrieves a resource, preferably by md5, but with filename and name as fallback for older ...

◆ fallbackResource()

template<typename T >
QSharedPointer< T > KisResourcesInterface::TypedResourceSourceAdapter< T >::fallbackResource ( ) const
inline

Definition at line 175 of file KisResourcesInterface.h.

176 {
177 return m_source->fallbackResource().dynamicCast<T>();
178 }
virtual KoResourceSP fallbackResource() const =0

◆ resourcesForFilename()

template<typename T >
QVector< QSharedPointer< T > > KisResourcesInterface::TypedResourceSourceAdapter< T >::resourcesForFilename ( const QString & filename) const
inlineprivate

Definition at line 107 of file KisResourcesInterface.h.

108 {
110 Q_FOREACH(KoResourceSP resource, m_source->resourcesForFilename(filename)) {
111 r << resource.dynamicCast<T>();
112 }
113 return r;
114 }
virtual QVector< KoResourceSP > resourcesForFilename(const QString &filename) const =0

◆ resourcesForMD5()

template<typename T >
QVector< QSharedPointer< T > > KisResourcesInterface::TypedResourceSourceAdapter< T >::resourcesForMD5 ( const QString & md5) const
inlineprivate

Definition at line 125 of file KisResourcesInterface.h.

126 {
128 Q_FOREACH(KoResourceSP resource, m_source->resourcesForMD5(md5)) {
129 r << resource.dynamicCast<T>();
130 }
131 return r;
132 }
virtual QVector< KoResourceSP > resourcesForMD5(const QString &md5) const =0

◆ resourcesForName()

template<typename T >
QVector< QSharedPointer< T > > KisResourcesInterface::TypedResourceSourceAdapter< T >::resourcesForName ( const QString & name) const
inlineprivate

Definition at line 116 of file KisResourcesInterface.h.

117 {
119 Q_FOREACH(KoResourceSP resource, m_source->resourcesForName(name)) {
120 r << resource.dynamicCast<T>();
121 }
122 return r;
123 }
virtual QVector< KoResourceSP > resourcesForName(const QString &name) const =0

Member Data Documentation

◆ m_source

template<typename T >
ResourceSourceAdapter* KisResourcesInterface::TypedResourceSourceAdapter< T >::m_source
protected

Definition at line 181 of file KisResourcesInterface.h.


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