AsyncResourceCacheEntryInterface Class Reference

#include <asyncresourcecache.h>

Inheritance diagram for AsyncResourceCacheEntryInterface:

Detailed Description

Cache class to allow delayed load of data with notification when it's ready to display. Multiple requests are combined (the first request loads the data and notifies all others)

Public Types

using UpdateCacheDelegate = Delegate< Result< void >(const Generic &key, const Generic &loaded)>
 

Public Member Functions

template<typename KEYTYPE , typename TYPE >
MAXON_FUNCTION Result< Opt< TYPE > > GetData (Delegate< Result< void >(const KEYTYPE &key, const TYPE &loaded)> &&updateDelegate, Bool async=true) const
 
MAXON_METHOD Result< Opt< DataRef > > GetDataImpl (UpdateCacheDelegate &&updateDelegate, Bool async=true) const
 
MAXON_METHOD Opt< UniversalDateTimeGetCacheCreationTime () const
 
 MAXON_OBSERVABLE (void, ObservableFreeCache,(const KeyData &key), ObservableCombinerRunAllComponent)
 

Private Member Functions

 MAXON_INTERFACE (AsyncResourceCacheEntryInterface, MAXON_REFERENCE_NORMAL, "net.maxon.interface.asyncresourcecacheentry")
 
 MAXON_GENERIC (typename KEYTYPE=KeyData)
 
 MAXON_GENERIC ((Out) typename TYPE=DataRef)
 

Member Typedef Documentation

◆ UpdateCacheDelegate

using UpdateCacheDelegate = Delegate<Result<void>(const Generic& key, const Generic& loaded)>

Delegate which is called if the cache was updated.

Parameters
[in]keyKey of the data.
[in]loadedData with the loaded data.

Member Function Documentation

◆ MAXON_INTERFACE()

MAXON_INTERFACE ( AsyncResourceCacheEntryInterface  ,
MAXON_REFERENCE_NORMAL  ,
"net.maxon.interface.asyncresourcecacheentry"   
)
private

◆ MAXON_GENERIC() [1/2]

MAXON_GENERIC ( typename KEYTYPE  = KeyData)
private

◆ MAXON_GENERIC() [2/2]

MAXON_GENERIC ( (Out) typename  TYPE = DataRef)
private

◆ GetData()

MAXON_FUNCTION Result<Opt<TYPE> > GetData ( Delegate< Result< void >(const KEYTYPE &key, const TYPE &loaded)> &&  updateDelegate,
Bool  async = true 
) const

GetData returns the data from the cache, if there is one. If nullptr then the data is still loading. In that case the delegate is triggered once the data is loaded.

Parameters
[in]updateDelegateDelegate which is called once the data is loaded.
[in]asyncUse false to force synchronous loading, by default loading is asynchronous.
Returns
Data or nullptr on success.

◆ GetDataImpl()

MAXON_METHOD Result<Opt<DataRef> > GetDataImpl ( UpdateCacheDelegate &&  updateDelegate,
Bool  async = true 
) const

◆ GetCacheCreationTime()

MAXON_METHOD Opt<UniversalDateTime> GetCacheCreationTime ( ) const

◆ MAXON_OBSERVABLE()

MAXON_OBSERVABLE ( void  ,
ObservableFreeCache  ,
(const KeyData &key)  ,
ObservableCombinerRunAllComponent   
)