A read-only archive that provides access to a File on disk, similar to FArchiveFileReaderGeneric provided by FFileManagerGeneric, but with support for asynchronous preloading and priming. 更多...
#include <PreloadableFile.h>
类 FPreloadableFile 继承关系图:Public 成员函数 | |
| bool | AllocateCache () |
| When in PreloadBytes mode, allocate if necessary the memory for the preloaded bytes. 更多... | |
| virtual bool | Close () final |
| Attempts to close and finalize any handles used for backing data storage, returns true if it succeeded. | |
| FArchive * | DetachLowerLevel () |
| Return the LowerLevel FArchive if it has been allocated. 更多... | |
| void | InitializeAsync (uint32 InFlags=Flags::None, int64 PrimeSize=DefaultPrimeSize) |
| Initialize the FPreloadableFile asynchronously, performing FileOpen operations on another thread. 更多... | |
| bool | IsCacheAllocated () const |
| Return whether the cache is currently allocated. | |
| bool | IsInitialized () const |
| Return whether InitializeAsync has completed. 更多... | |
| bool | IsPreloading () const |
| Return whether preloading is in progress. 更多... | |
| void | ReleaseCache () |
| Free all memory used by the cache or for preloading (calling StopPreload if necessary). | |
| virtual void | Seek (int64 InPos) final |
| Attempts to set the current offset into backing data storage, this will do nothing if there is no storage. | |
| void | SetPageSize (int64 PageSize) |
| Set the PageSize used read requests made to the LowerLevel Archive in PreloadBytes mode when reading bytes into the In-Memory cache. 更多... | |
| bool | StartPreload () |
| When in PreloadBytes mode, if not already preloading, allocate if necessary the memory for the preloaded bytes and start the chain of asynchronous ReadRequests for the bytes. 更多... | |
| void | StopPreload () |
| Cancel any current asynchronous ReadRequests and wait for the asynchronous work to exit. | |
| virtual int64 | TotalSize () final |
| Return the size of the file, or -1 if the file does not exist. 更多... | |
| void | WaitForInitialization () const |
| Wait for InitializeAsync to complete if it is running, otherwise return immediately. | |
Public 成员函数 继承自 FArchive | |
| virtual void | AttachBulkData (UObject *Owner, FUntypedBulkData *BulkData) |
| Attaches/ associates the passed in bulk data object with the linker. 更多... | |
| virtual bool | AttachExternalReadDependency (FExternalReadCallback &ReadCallback) |
| Adds external read dependency 更多... | |
| FORCEINLINE FArchive & | ByteOrderSerialize (void *V, int32 Length) |
| Serialize data of Length bytes, taking into account byte swapping if needed. | |
| void | ByteSwap (void *V, int32 Length) |
| Used to do byte swapping on small items. 更多... | |
| virtual bool | Close () |
| Attempts to close and finalize any handles used for backing data storage, returns true if it succeeded. | |
| virtual void | DetachBulkData (FUntypedBulkData *BulkData, bool bEnsureBulkDataIsLoaded) |
| Detaches the passed in bulk data object from the linker. 更多... | |
| virtual void | Flush () |
| Attempts to finish writing any buffered data to disk/permanent storage. | |
| virtual void | FlushCache () |
| Flushes cache and frees internal data. | |
| virtual void | ForceBlueprintFinalization () |
| Inform the archive that a blueprint would like to force finalization, normally this is triggered by CDO load, but if there's no CDO we force finalization. | |
| FArchiveState & | GetArchiveState () |
| Returns the low level archive state for this archive. | |
| virtual FArchive * | GetCacheableArchive () |
| Returns a pointer to an archive that represents the same data that the current archive covers, but that can be cached and reused later In the case of standard archives, this function will just return a pointer to itself. 更多... | |
| virtual bool | IsProxyOf (FArchive *InOther) const |
| Determine if the given archive is a valid "child" of this archive. 更多... | |
| virtual void | MarkScriptSerializationEnd (const UObject *Obj) |
| Called when an object stops serializing property data using script serialization. | |
| virtual void | MarkScriptSerializationStart (const UObject *Obj) |
| Called when an object begins serializing property data using script serialization. | |
| virtual void | MarkSearchableName (const UObject *TypeObject, const FName &ValueName) const |
| Called to register a reference to a specific name value, of type TypeObject (UEnum or UStruct normally). 更多... | |
| virtual FArchive & | operator<< (FField *&Value) |
| Serializes a Field value from or into this archive. 更多... | |
| virtual FArchive & | operator<< (FName &Value) |
| Serializes an FName value from or into this archive. 更多... | |
| virtual FArchive & | operator<< (FText &Value) |
| Serializes an FText value from or into an archive. 更多... | |
| virtual FArchive & | operator<< (struct FLazyObjectPtr &Value) |
| Serializes a lazy object pointer value from or into this archive. 更多... | |
| virtual FArchive & | operator<< (struct FSoftObjectPath &Value) |
| Serializes soft object paths from or into this archive. 更多... | |
| virtual FArchive & | operator<< (struct FSoftObjectPtr &Value) |
| Serializes asset pointer from or into this archive. 更多... | |
| virtual FArchive & | operator<< (struct FWeakObjectPtr &Value) |
| Serializes FWeakObjectPtr value from or into this archive. 更多... | |
| template<class T > | |
| FORCEINLINE FArchive & | operator<< (TCheckedObjPtr< T > &Value) |
| Serializes a UObject wrapped in a TCheckedObjPtr container, using the above operator, and verifies the serialized object is derived from the correct base class, to prevent illegal casting. 更多... | |
| virtual FArchive & | operator<< (UObject *&Value) |
| Serializes an UObject value from or into this archive. 更多... | |
| virtual void | PopSerializedProperty (class FProperty *InProperty, const bool bIsEditorOnlyProperty) |
| Pop a property that was previously being serialized off the property stack 更多... | |
| virtual bool | Precache (int64 PrecacheOffset, int64 PrecacheSize) |
| Hint the archive that the region starting at passed in offset and spanning the passed in size is going to be read soon and should be precached. 更多... | |
| virtual void | Preload (UObject *Object) |
| Tells the archive to attempt to preload the specified object so data can be loaded out of it. | |
| virtual void | PushFileRegionType (EFileRegionType Type) |
| Called whilst cooking to provide file region hints to the cooker. | |
| virtual void | PushSerializedProperty (class FProperty *InProperty, const bool bIsEditorOnlyProperty) |
| Push a property that is currently being serialized onto the property stack 更多... | |
| virtual void | Seek (int64 InPos) |
| Attempts to set the current offset into backing data storage, this will do nothing if there is no storage. | |
| void | SerializeCompressed (void *V, int64 Length, FName CompressionFormat, ECompressionFlags Flags=COMPRESS_NoFlags, bool bTreatBufferAsFileReader=false) |
| Serializes and compresses/ uncompresses data. 更多... | |
| virtual void | SerializeIntPacked (uint32 &Value) |
| Packs int value into bytes of 7 bits with 8th bit for 'more' | |
| virtual bool | SetCompressionMap (TArray< struct FCompressedChunk > *CompressedChunks, ECompressionFlags CompressionFlags) |
| Sets mapping from offsets/ sizes that are going to be used for seeking and serialization to what is actually stored on disk. 更多... | |
| void | StartSerializingDefaults () |
| Sets a flag indicating that this archive is currently serializing class/struct defaults. | |
| void | StopSerializingDefaults () |
| Indicate that this archive is no longer serializing class/struct defaults. | |
| virtual void | UsingCustomVersion (const struct FGuid &Guid) |
| Registers the custom version to the archive. 更多... | |
静态 Public 成员函数 | |
| static bool | TryRegister (const TSharedPtr< FPreloadableFile > &PreloadableFile) |
| Try to register the given FPreloadableFile instance to handle the next call to TryTakeArchive for its FileName. 更多... | |
| static FArchive * | TryTakeArchive (const TCHAR *FileName) |
| Look up an FPreloadableFile instance registered for the given FileName, and return an FArchive from it. 更多... | |
| static bool | UnRegister (const TSharedPtr< FPreloadableFile > &PreloadableFile) |
| Remove the FPreloadableFile instance if it is registered for its FileName. 更多... | |
A read-only archive that provides access to a File on disk, similar to FArchiveFileReaderGeneric provided by FFileManagerGeneric, but with support for asynchronous preloading and priming.
This class supports two mutually-exclusive modes: PreloadBytes: A lower-level asynchronous archive is opened during initialization and size is read. After initialization, when StartPreload is called, an array of bytes equal in size to the file's size is allocated, and an asynchronous ReadRequest is sent to the IAsyncReadFileHandle to read the first <PageSize> bytes of the file. Upon completion of each in-flight ReadRequest, another asynchronous ReadRequest is issued, until the entire file has been read. If serialize functions are called beyond the bytes of the file that have been cached so far, they requests are satisfied by synchronous reads.
Activate this mode by passing Flags::PreloadBytes to InitializeAsync. PreloadHandle: A lower-level FArchive is opened for the file using IFileManager::Get().CreateFileReader; this call is made asynchronously on a TaskGraph thread. Optionally, a precache request is sent to the lower-level FArchive for the first <PrimeSize> bytes; this call is also made asynchronously. The created and primed lower-level FArchive can then be detached from this class and handed off to a new owner.
Activate this mode by passing Flags::OpenHandle and (optionally, for the precache request) Flags::Prime to InitializeAsync.
This class also supports registration of the members of this class by filename, which other systems in the engine can use to request an FArchive for the preload file, if it exists, replacing a call they would otherwise make to IFileManager::Get().CreateFileReader.
This class is not threadsafe. The public interface can be used at the same time as internal asynchronous tasks are executing, but the public interface can not be used from multiple threads at once.
| bool FPreloadableFile::AllocateCache | ( | ) |
When in PreloadBytes mode, allocate if necessary the memory for the preloaded bytes.
Return whether the memory is now allocated.
| FArchive * FPreloadableFile::DetachLowerLevel | ( | ) |
Return the LowerLevel FArchive if it has been allocated.
May return null, even if the FPreloadableFile is currently active. If return value is non-null, caller is responsible for deleting it.
| void FPreloadableFile::InitializeAsync | ( | uint32 | InFlags = Flags::None, |
| int64 | PrimeSize = DefaultPrimeSize |
||
| ) |
Initialize the FPreloadableFile asynchronously, performing FileOpen operations on another thread.
Use IsInitialized or WaitForInitialization to check progress.
| bool FPreloadableFile::IsInitialized | ( | ) | const |
Return whether InitializeAsync has completed.
If Close is called, state returns to false until the next call to InitializeAsync.
| bool FPreloadableFile::IsPreloading | ( | ) | const |
Return whether preloading is in progress.
Value may not be up to date since asynchronous work might complete in a race condition.
| void FPreloadableFile::SetPageSize | ( | int64 | PageSize | ) |
Set the PageSize used read requests made to the LowerLevel Archive in PreloadBytes mode when reading bytes into the In-Memory cache.
Invalid to set after Initialization; PageSize must be constant during use.
| bool FPreloadableFile::StartPreload | ( | ) |
When in PreloadBytes mode, if not already preloading, allocate if necessary the memory for the preloaded bytes and start the chain of asynchronous ReadRequests for the bytes.
Returns whether preloading is now active.
|
finalvirtual |
Return the size of the file, or -1 if the file does not exist.
This is also the amount of memory that will be allocated by AllocateCache.
|
static |
Try to register the given FPreloadableFile instance to handle the next call to TryTakeArchive for its FileName.
Will fail if the instance has not been initialized or if another instance has already registered for the Filename. Return whether the instance is currently registered. Returns true if the instance was already registered. Registered files are referenced-counted, and the reference will not be dropped until (1) (TryTakeArchive or UnRegister is called) and (2) (PreloadBytes mode only) the archive returned from TryTakeArchive is deleted.
|
static |
Look up an FPreloadableFile instance registered for the given FileName, and return an FArchive from it.
If found, removes the registration so no future call to TryTakeArchive can sue the same FArchive. If the instance is in PreloadHandle mode, the Lower-Level FArchive will be detached from the FPreloadableFile and returned using DetachLowerLevel. If the instance is in PreloadBytes mode, a ProxyArchive will be returned that forwards call to the FPreloadableFile instance.
|
static |
Remove the FPreloadableFile instance if it is registered for its FileName.
Returns whether the instance was registered.