#include <imageurlcache.h>
Cache class to allow delayed load of images with notification when it's ready to display. Multiple requests are combined (the first request loads the image and notifies all others)
Public Types | |
using | UpdateCacheDelegate = Delegate< Result< void >(const Url &url, const ImageBaseRef &loaded)> |
Public Member Functions | |
MAXON_OBSERVABLE (void, ObservableFreeCache,(const Url &url), ObservableCombinerRunAllComponent) | |
MAXON_METHOD Result< Opt< ImageBaseRef > > | GetImage (UpdateCacheDelegate &&updateDelegate) const |
MAXON_METHOD Result< Opt< ImageBaseRef > > | GetImage (UpdateCacheDelegate &&updateDelegate, Bool async) const |
Static Public Member Functions | |
static MAXON_METHOD Result< void > | InvalidateCache (const Url &url) |
static MAXON_METHOD Result< ImageUrlCacheRef > | FindOrCreate (const Url &url) |
Private Member Functions | |
MAXON_INTERFACE (ImageUrlCacheInterface, MAXON_REFERENCE_NORMAL, "net.maxon.image.interface.imageurlcache") | |
using UpdateCacheDelegate = Delegate<Result<void>(const Url& url, const ImageBaseRef& loaded)> |
Delegate which is called if the cache was updated.
[in] | url | url of the image |
[in] | loaded | ImageBaseRef with the loaded image. |
|
private |
|
static |
InvalidateCache invalidates and removed the image from the cache. The next request will reload the image.
[in] | url | Image to discard from the cache. |
|
static |
FindOrCreate returns the cache for the requested image resource.
[in] | url | Url of the image to load. |
MAXON_OBSERVABLE | ( | void | , |
ObservableFreeCache | , | ||
(const Url &url) | , | ||
ObservableCombinerRunAllComponent | |||
) |
MAXON_METHOD Result<Opt<ImageBaseRef> > GetImage | ( | UpdateCacheDelegate && | updateDelegate | ) | const |
GetImage returns the image from the cache, if there is one. If nullptr then the image is still loading. In that case the delegate is triggered once the image is loaded.
[in] | updateDelegate | Delegate which is called once the image is loaded. |
MAXON_METHOD Result<Opt<ImageBaseRef> > GetImage | ( | UpdateCacheDelegate && | updateDelegate, |
Bool | async | ||
) | const |
GetImage returns the image from the cache, if there is one. If nullptr then the image is still loading. In that case the delegate is triggered once the image is loaded.
[in] | updateDelegate | Delegate which is called once the image is loaded. |
[in] | async | Use false to force synchronous loading, by default loading is asynchronous. |