![]() |
XII Release 0.1.0
|
#include <CollectionResource.h>
Public Member Functions | |
| void | RegisterNames () |
| void | UnregisterNames () |
| bool | PreloadResources (xiiUInt32 uiNumResourcesToPreload=xiiMath::MaxValue< xiiUInt32 >()) |
| bool | IsLoadingFinished (float *out_pProgress=nullptr) const |
| const xiiCollectionResourceDescriptor & | GetDescriptor () const |
| Returns the resource descriptor for this resource. | |
| xiiArrayPtr< const xiiTypelessResourceHandle > | GetPreloadedResources () const |
| Returns the current list of resources that have already been added to the preload list. See PreloadResources(). | |
| Public Member Functions inherited from xiiResource | |
| XII_ALWAYS_INLINE xiiStringView | GetResourceID () const |
| XII_ALWAYS_INLINE xiiUInt64 | GetResourceIDHash () const |
| Returns the hash of the unique ID. | |
| void | SetResourceDescription (xiiStringView sDescription) |
| const xiiString & | GetResourceDescription () const |
| const xiiString & | GetResourceIdOrDescription () const |
| XII_ALWAYS_INLINE xiiResourceState | GetLoadingState () const |
| Returns the current state in which this resource is in. | |
| XII_ALWAYS_INLINE xiiUInt8 | GetNumQualityLevelsDiscardable () const |
| XII_ALWAYS_INLINE xiiUInt8 | GetNumQualityLevelsLoadable () const |
| Returns how many quality levels the resource may additionally load. | |
| float | GetLoadingPriority (xiiTime now) const |
| Returns the priority that is used by the resource manager to determine which resource to load next. | |
| xiiResourcePriority | GetPriority () const |
| Returns the current resource priority. | |
| void | SetPriority (xiiResourcePriority priority) |
| Changes the current resource priority. | |
| XII_ALWAYS_INLINE const xiiBitflags< xiiResourceFlags > & | GetBaseResourceFlags () const |
| Returns the basic flags for the resource type. Mostly used the resource manager. | |
| XII_ALWAYS_INLINE const MemoryUsage & | GetMemoryUsage () const |
| Returns the information about the current memory usage of the resource. | |
| XII_ALWAYS_INLINE xiiTime | GetLastAcquireTime () const |
| XII_ALWAYS_INLINE xiiInt32 | GetReferenceCount () const |
| Returns the reference count of this resource. | |
| XII_ALWAYS_INLINE const xiiTimestamp & | GetLoadedFileModificationTime () const |
| XII_ALWAYS_INLINE xiiUInt32 | GetCurrentResourceChangeCounter () const |
| XII_ALWAYS_INLINE void | IncResourceChangeCounter () |
| Allows to manually increase the resource change counter to signal that dependent code might need to update. | |
| virtual void | ResetResource () |
| void | PrintHandleStackTraces () |
| Public Member Functions inherited from xiiReflectedClass | |
| virtual const xiiRTTI * | GetDynamicRTTI () const |
| bool | IsInstanceOf (const xiiRTTI *pType) const |
| Returns whether the type of this instance is of the given type or derived from it. | |
| template<typename T> | |
| XII_ALWAYS_INLINE bool | IsInstanceOf () const |
| Returns whether the type of this instance is of the given type or derived from it. | |
Private Member Functions | |
| virtual xiiResourceLoadDescription | UnloadData (Unload WhatToUnload) override |
| virtual xiiResourceLoadDescription | UpdateContent (xiiStreamReader *Stream) override |
| virtual void | UpdateMemoryUsage (MemoryUsage &out_NewMemoryUsage) override |
Additional Inherited Members | |
| Public Types inherited from xiiResource | |
| enum class | DoUpdate : xiiUInt8 { OnMainThread = 0U , OnAnyThread } |
| Specifies the thread type on which update operations should be performed. More... | |
| Static Public Member Functions inherited from xiiNoBase | |
| static const xiiRTTI * | GetStaticRTTI () |
| Public Attributes inherited from xiiResource | |
| xiiEvent< const xiiResourceEvent &, xiiMutex > | m_ResourceEvents |
| Protected Types inherited from xiiResource | |
| enum class | Unload : xiiUInt8 { AllQualityLevels = 0U , OneQualityLevel } |
| Protected Member Functions inherited from xiiResource | |
| xiiResource (DoUpdate resourceUpdateThread, xiiUInt8 uiQualityLevelsLoadable) | |
| Default constructor. | |
| virtual | ~xiiResource () |
| virtual destructor. | |
| MemoryUsage & | ModifyMemoryUsage () |
| Non-const version for resources that want to write this variable directly. | |
| void | SetIsReloadable (bool bIsReloadable) |
| void | SetHasLoadingFallback (bool bHasLoadingFallback) |
| Used internally by the code injection macros. | |
A xiiCollectionResource is used to tell the engine about resources that it should preload in the background
Collection resources can be used to improve the user experience by ensuring data is already (more likely) available when it is needed. For instance when a player walks into a longer corridor, a collection resource can be triggered to preload the data that will be needed when he reaches the door at the end of the corridor. In scenes this can be achieved using a xiiCollectionComponent.
Collection resources can also be used to query how much percent of the references resources are already loaded, which enables building progress bars or allowing functionality only after all necessary data is available.
Finally, collections can also be used to register resources with a nice name, such that it can be referenced in code by that name. This is useful if you want to reference some asset in code with a readable resource ID, and may want to change which resource is referenced at a later time. For example the nice name "Avatar" could point to some dummy mesh at the beginning of the project, and be updated to point to something else later, without the need to change the code.
| bool xiiCollectionResource::IsLoadingFinished | ( | float * | out_pProgress = nullptr | ) | const |
Returns true if all resources added for preloading via PreloadResources have finished loading. if out_progress is defined:
| bool xiiCollectionResource::PreloadResources | ( | xiiUInt32 | uiNumResourcesToPreload = xiiMath::MaxValue<xiiUInt32>() | ) |
Puts up to the given number of resources for which a resource type could be found into the preload queue of the xiiResourceManager.
This has to be called manually. It will return false if no more resources can be queued for preloading. This can be used as a workflow where PreloadResources and IsLoadingFinished are called repeadedly in tandem, so only a smaller fraction of resources gets queued and waited for, to allow simple resource load-balancing.
| void xiiCollectionResource::RegisterNames | ( | ) |
Registers the named resources in the collection with the xiiResourceManager, such that they can be loaded by those names.
Calling this twice has no effect.
|
overrideprivatevirtual |
Requests the resource to unload another quality level. If bFullUnload is true, the resource should unload all data, because it is going to be deleted afterwards.
Implements xiiResource.
| void xiiCollectionResource::UnregisterNames | ( | ) |
Removes the registered names from the xiiResourceManager.
Calling this twice has no effect.
|
overrideprivatevirtual |
Called whenever more data for the resource is available. The resource must read the stream to update it's data.
pStream may be nullptr in case the resource data could not be found.
Implements xiiResource.
|
overrideprivatevirtual |
This function must be overridden by all resource types.
It has to compute the memory used by this resource. It is called by the resource manager whenever the resource's data has been loaded or unloaded.
Implements xiiResource.