Overte C++ Documentation
Resource Class Reference

Base class for resources. More...

#include <ResourceCache.h>

Inheritance diagram for Resource:

Signals

void loading ()
 Fired when the resource begins downloading.
 
void loaded (const QByteArray request)
 
void finished (bool success)
 Fired when the resource has finished loading.
 
void failed (QNetworkReply::NetworkError error)
 Fired when the resource failed to load.
 
void onRefresh ()
 Fired when the resource is refreshed.
 
void onProgress (uint64_t bytesReceived, uint64_t bytesTotal)
 Fired on progress updates.
 
void updateSize (qint64 deltaSize)
 Fired when the size changes (through setSize).
 

Public Member Functions

int getLRUKey () const
 Returns the key last used to identify this resource in the unused map.
 
void ensureLoading ()
 Makes sure that the resource has started loading.
 
virtual void setLoadPriority (const QPointer< QObject > &owner, float priority)
 Sets the load priority for one owner.
 
virtual void setLoadPriorities (const QHash< QPointer< QObject >, float > &priorities)
 Sets a set of priorities at once.
 
virtual void clearLoadPriority (const QPointer< QObject > &owner)
 Clears the load priority for one owner.
 
float getLoadPriority ()
 Returns the highest load priority across all owners.
 
virtual bool isLoaded () const
 Checks whether the resource has loaded.
 
virtual bool isFailed () const
 Checks whether the resource has failed to download.
 
qint64 getBytesReceived () const
 For loading resources, returns the number of bytes received.
 
qint64 getBytesTotal () const
 For loading resources, returns the number of total bytes (<= zero if unknown).
 
qint64 getBytes () const
 For loaded resources, returns the number of actual bytes (defaults to total bytes if not explicitly set).
 
float getProgress () const
 For loading resources, returns the load progress.
 
virtual void refresh ()
 Refreshes the resource.
 

Protected Member Functions

virtual void makeRequest ()
 
virtual bool isCacheable () const
 Checks whether the resource is cacheable.
 
virtual void downloadFinished (const QByteArray &data)
 
void setSize (const qint64 &bytes)
 Called when the download is finished and processed, sets the number of actual bytes.
 
Q_INVOKABLE void finishedLoading (bool success)
 
virtual bool handleFailedRequest (ResourceRequest::Result result)
 Return true if the resource will be retried.
 

Friends

class ResourceCache
 
class ScriptableResource
 

Detailed Description

Base class for resources.

Member Function Documentation

◆ downloadFinished()

virtual void Resource::downloadFinished ( const QByteArray &  data)
inlineprotectedvirtual

Called when the download has finished. This should be overridden by subclasses that need to process the data once it is downloaded.

Reimplemented in GeometryResource, and NetworkTexture.

◆ finishedLoading()

void Resource::finishedLoading ( bool  success)
protected

Called when the download is finished and processed. This should be called by subclasses that override downloadFinished to mark the end of processing.

◆ loaded

void Resource::loaded ( const QByteArray  request)
signal

Fired when the resource has been downloaded. This can be used instead of downloadFinished to access data before it is processed.

◆ makeRequest()

void Resource::makeRequest ( )
protectedvirtual

Called by ResourceCache to begin loading this Resource. This method can be overriden to provide custom request functionality. If this is done, downloadFinished and ResourceCache::requestCompleted must be called.

Reimplemented in NetworkTexture.


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