Ark Server API (ASA) - Wiki
Loading...
Searching...
No Matches
GenericPlatformChunkInstall.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
3
4/*=============================================================================================
5 GenericPlatformChunkInstall.h: Generic platform chunk based install classes.
6==============================================================================================*/
7
8#pragma once
9
10#include "Containers/Array.h"
11#include "Containers/ArrayView.h"
12#include "Containers/UnrealString.h"
13#include "CoreTypes.h"
14#include "Delegates/Delegate.h"
15#include "HAL/PlatformCrt.h"
16#include "Logging/LogMacros.h"
17#include "Modules/ModuleInterface.h"
18#include "UObject/NameTypes.h"
19
21
23
24namespace EChunkLocation
25{
26 enum Type
27 {
28 // note: higher quality locations should have higher enum values, we sort by these in AssetRegistry.cpp
29 DoesNotExist, // chunk does not exist
30 NotAvailable, // chunk has not been installed yet
31 LocalSlow, // chunk is on local slow media (optical)
32 LocalFast, // chunk is on local fast media (HDD)
33
35 };
36}
37
38
39namespace EChunkInstallSpeed
40{
41 enum Type
42 {
43 Paused, // chunk installation is paused
44 Slow, // installation is lower priority than Game IO
45 Fast // installation is higher priority than Game IO
46 };
47}
48
49namespace EChunkPriority
50{
51 enum Type
52 {
53 Immediate, // Chunk install is of highest priority, this can cancel lower priority installs.
54 High , // Chunk is probably required soon so grab is as soon as possible.
55 Low , // Install this chunk only when other chunks are not needed.
56 };
57}
58
60{
61 enum Type
62 {
63 ETA, // time remaining in seconds
64 PercentageComplete // percentage complete in 99.99 format
65 };
66}
67
68/**
69 * Platform Chunk Install Module Interface
70 */
72{
73public:
74
76};
77
78/** Deprecated delegate */
79DECLARE_DELEGATE_OneParam(FPlatformChunkInstallCompleteDelegate, uint32);
80
81/** Delegate called when a chunk either successfully installs or fails to install, bool is success */
82DECLARE_DELEGATE_TwoParams(FPlatformChunkInstallDelegate, uint32, bool);
83DECLARE_MULTICAST_DELEGATE_TwoParams(FPlatformChunkInstallMultiDelegate, uint32, bool);
84
85/** Delegate called when a Named Chunk either successfully installs or fails to install, bool is success */
86DECLARE_DELEGATE_TwoParams(FPlatformNamedChunkInstallDelegate, FName, bool);
87DECLARE_MULTICAST_DELEGATE_TwoParams(FPlatformNamedChunkInstallMultiDelegate, FName, bool);
88
89
91{
94};
95
97{
100 uint32 ChunkID;
102
103 FCustomChunk(FString InTag, uint32 InID, ECustomChunkType InChunkType, FString InTag2 = TEXT("")) :
104 ChunkTag(InTag), ChunkTag2(InTag2), ChunkID(InID), ChunkType(InChunkType)
105 {}
106};
107
109{
111 {
112 Main,
114 };
115
117 uint32 ChunkID;
119
120 FCustomChunkMapping(FString InPattern, uint32 InChunkID, CustomChunkMappingType InMappingType) :
121 Pattern(InPattern), ChunkID(InChunkID), MappingType(InMappingType)
122 {}
123};
124
126{
127 Invalid,
128 OnDemand,
129 Language,
130};
131
132/**
133* Interface for platform specific chunk based install
134**/
136{
137public:
138
139 /** Virtual destructor */
141
142 /**
143 * Get the current location of a chunk with pakchunk index.
144 * @param PakchunkIndex The id of the pak chunk.
145 * @return Enum specifying whether the chunk is available to use, waiting to install, or does not exist.
146 **/
147 virtual EChunkLocation::Type GetPakchunkLocation( int32 PakchunkIndex) = 0;
148
149 /**
150 * Check if a given reporting type is supported.
151 * @param ReportType Enum specifying how progress is reported.
152 * @return true if reporting type is supported on the current platform.
153 **/
155
156 /**
157 * Get the current install progress of a chunk. Let the user specify report type for platforms that support more than one.
158 * @param ChunkID The id of the chunk to check.
159 * @param ReportType The type of progress report you want.
160 * @return A value whose meaning is dependent on the ReportType param.
161 **/
162 virtual float GetChunkProgress( uint32 ChunkID, EChunkProgressReportingType::Type ReportType ) = 0;
163
164 /**
165 * Inquire about the priority of chunk installation vs. game IO.
166 * @return Paused, low or high priority.
167 **/
169 /**
170 * Specify the priority of chunk installation vs. game IO.
171 * @param InstallSpeed Pause, low or high priority.
172 * @return false if the operation is not allowed, otherwise true.
173 **/
174 virtual bool SetInstallSpeed( EChunkInstallSpeed::Type InstallSpeed ) = 0;
175
176 /**
177 * Hint to the installer that we would like to prioritize a specific chunk
178 * @param PakchunkIndex The index of the pakchunk to prioritize.
179 * @param Priority The priority for the chunk.
180 * @return false if the operation is not allowed or the chunk doesn't exist, otherwise true.
181 **/
182 virtual bool PrioritizePakchunk( int32 PakchunkIndex, EChunkPriority::Type Priority ) = 0;
183
184 /**
185 * For platforms that support emulation of the Chunk install. Starts transfer of the next chunk.
186 * Does nothing in a shipping build.
187 * @return true if the operation succeeds.
188 **/
189 virtual bool DebugStartNextChunk() = 0;
190
191 /**
192 * Allow an external system to notify that a particular chunk ID has become available
193 * Initial use-case is for dynamically encrypted pak files to signal to the outside world that
194 * it has become available.
195 *
196 * @param InChunkID - ID of the chunk that has just become available
197 */
198 virtual void ExternalNotifyChunkAvailable(uint32 InChunkID) = 0;
199
200 /**
201 * Request a delegate callback on chunk install completion or failure. Request may not be respected.
202 * @param Delegate The delegate to call when any chunk is installed or fails to install
203 * @return Handle to the bound delegate
204 */
205 virtual FDelegateHandle AddChunkInstallDelegate( FPlatformChunkInstallDelegate Delegate ) = 0;
206
207 /**
208 * Remove a delegate callback on chunk install completion.
209 * @param Delegate The delegate to remove.
210 */
211 virtual void RemoveChunkInstallDelegate( FDelegateHandle Delegate ) = 0;
212
213
214 UE_DEPRECATED(5.1, "Call SupportsNamedChunkInstall instead")
215 virtual bool SupportsIntelligentInstall() = 0;
216
217 UE_DEPRECATED(5.1, "Call IsNamedChunkInProgress instead")
218 virtual bool IsChunkInstallationPending(const TArray<FCustomChunk>& ChunkTagsID) = 0;
219
220 UE_DEPRECATED(5.1, "Call InstallNamedChunks instead")
221 virtual bool InstallChunks(const TArray<FCustomChunk>& ChunkTagsID) = 0;
222
223 UE_DEPRECATED(5.1, "Call UninstallNamedChunks instead")
224 virtual bool UninstallChunks(const TArray<FCustomChunk>& ChunkTagsID) = 0;
225
226 UE_DEPRECATED(5.2, "Call GetNamedChunksByType instead")
228
229
230 /**
231 * Check whether current platform supports chunk installation by name
232 * @return whether Intelligent Install is supported
233 */
234 virtual bool SupportsNamedChunkInstall() const = 0;
235
236 /**
237 * Check whether the give chunk is being installed
238 * @param NamedChunk The name of the chunk
239 * @return whether installation task has been kicked
240 */
241 virtual bool IsNamedChunkInProgress(const FName NamedChunk) = 0;
242
243 /**
244 * Install the given named chunk
245 * @param NamedChunk The name of the chunk
246 * @return whether installation task has been kicked
247 **/
248 virtual bool InstallNamedChunk(const FName NamedChunk) = 0;
249
250 /**
251 * Uninstall the given named chunk
252 * @param NamedChunk The name of the chunk
253 * @return whether uninstallation task has been kicked
254 **/
255 virtual bool UninstallNamedChunk(const FName NamedChunk) = 0;
256
257 /**
258 * Install the given set of named chunks
259 * @param NamedChunks The names of the chunks to install
260 * @return whether installation task has been kicked
261 **/
262 virtual bool InstallNamedChunks(const TArrayView<const FName>& NamedChunks) = 0;
263
264 /**
265 * Uninstall the given set of named chunks
266 * @param NamedChunk The names of the chunks to uninstall
267 * @return whether uninstallation task has been kicked
268 **/
269 virtual bool UninstallNamedChunks(const TArrayView<const FName>& NamedChunks) = 0;
270
271 /**
272 * Get the current location of the given named chunk
273 * @param NamedChunk The name of the chunk
274 * @return Enum specifying whether the chunk is available to use, waiting to install, or does not exist.
275 **/
276 virtual EChunkLocation::Type GetNamedChunkLocation(const FName NamedChunk) = 0;
277
278 /**
279 * Get the current install progress of the given named chunk. Let the user specify report type for platforms that support more than one.
280 * @param NamedChunk The name of the chunk
281 * @param ReportType The type of progress report you want.
282 * @return A value whose meaning is dependent on the ReportType param.
283 **/
284 virtual float GetNamedChunkProgress(const FName NamedChunk, EChunkProgressReportingType::Type ReportType) = 0;
285
286 /**
287 * Hint to the installer that we would like to prioritize a specific chunk
288 * @param NamedChunk The name of the chunk
289 * @param Priority The priority for the chunk.
290 * @return false if the operation is not allowed or the chunk doesn't exist, otherwise true.
291 **/
292 virtual bool PrioritizeNamedChunk(const FName NamedChunk, EChunkPriority::Type Priority) = 0;
293
294 /**
295 * Query the type of the given named chunk
296 * @param NamedChunk The name of the chunk
297 * @return Enum indicating the type of chunk, if any
298 */
299 virtual ENamedChunkType GetNamedChunkType(const FName NamedChunk) const = 0;
300
301 /**
302 * Get a list of all the named chunks of the given type
303 * @param Enum indicating the type of chunk
304 * @return Array containing all named chunks of the given type
305 */
307
308 /**
309 * Request a delegate callback on named chunk install completion or failure. Request may not be respected.
310 * @param Delegate The delegate to call when any named chunk is installed or fails to install
311 * @return Handle to the bound delegate
312 */
313 virtual FDelegateHandle AddNamedChunkInstallDelegate( FPlatformNamedChunkInstallDelegate Delegate ) = 0;
314
315 /**
316 * Remove a delegate callback on named chunk install completion.
317 * @param Delegate The delegate to remove.
318 */
320
321protected:
322 /**
323 * Get the current location of a chunk.
324 * Pakchunk index and platform chunk id are not always the same. Call GetPakchunkLocation instead of calling from outside.
325 * @param ChunkID The id of the chunk to check.
326 * @return Enum specifying whether the chunk is available to use, waiting to install, or does not exist.
327 **/
328 virtual EChunkLocation::Type GetChunkLocation(uint32 ChunkID) = 0;
329
330 /**
331 * Hint to the installer that we would like to prioritize a specific chunk
332 * @param ChunkID The id of the chunk to prioritize.
333 * @param Priority The priority for the chunk.
334 * @return false if the operation is not allowed or the chunk doesn't exist, otherwise true.
335 **/
336 virtual bool PrioritizeChunk(uint32 ChunkID, EChunkPriority::Type Priority) = 0;
337
338};
339
341/**
342 * Generic implementation of chunk based install
343 */
345{
346public:
347 virtual EChunkLocation::Type GetPakchunkLocation( int32 PakchunkIndex ) override
348 {
349 return GetChunkLocation(PakchunkIndex);
350 }
351
352 virtual bool PrioritizePakchunk(int32 PakchunkIndex, EChunkPriority::Type Priority)
353 {
354 return PrioritizeChunk(PakchunkIndex, Priority);
355 }
356
358 {
360 {
361 return true;
362 }
363
364 return false;
365 }
366
367 virtual float GetChunkProgress( uint32 ChunkID, EChunkProgressReportingType::Type ReportType ) override
368 {
370 {
371 return 100.0f;
372 }
373 return 0.0f;
374 }
375
377 {
379 }
380
381 virtual bool SetInstallSpeed( EChunkInstallSpeed::Type InstallSpeed ) override
382 {
383 return false;
384 }
385
386 virtual bool PrioritizeChunk( uint32 ChunkID, EChunkPriority::Type Priority ) override
387 {
388 return false;
389 }
390
391 virtual bool DebugStartNextChunk() override
392 {
393 return true;
394 }
395
396 virtual void ExternalNotifyChunkAvailable(uint32 InChunkID) override
397 {
398 InstallDelegate.Broadcast(InChunkID, true);
399 }
400
401 virtual FDelegateHandle AddChunkInstallDelegate(FPlatformChunkInstallDelegate Delegate) override
402 {
403 return InstallDelegate.Add(Delegate);
404 }
405
406 virtual void RemoveChunkInstallDelegate(FDelegateHandle Delegate) override
407 {
408 InstallDelegate.Remove(Delegate);
409 }
410
411 virtual bool SupportsIntelligentInstall() override
412 {
413 return false;
414 }
415
416 virtual bool IsChunkInstallationPending(const TArray<FCustomChunk>& ChunkTags) override
417 {
418 return false;
419 }
420
421 virtual bool InstallChunks(const TArray<FCustomChunk>& ChunkTagIDs) override
422 {
423 return false;
424 }
425
426 virtual bool UninstallChunks(const TArray<FCustomChunk>& ChunkTagsID) override
427 {
428 return false;
429 }
430
432 {
433 return TArray<FCustomChunk>();
434 }
435
436 virtual bool SupportsNamedChunkInstall() const override
437 {
438 return false;
439 }
440
441 virtual bool IsNamedChunkInProgress(const FName NamedChunk) override
442 {
443 return false;
444 }
445
446 virtual bool InstallNamedChunk(const FName NamedChunk) override
447 {
448 return InstallNamedChunks(MakeArrayView(&NamedChunk,1));
449 }
450
451 virtual bool UninstallNamedChunk(const FName NamedChunk) override
452 {
453 return UninstallNamedChunks(MakeArrayView(&NamedChunk,1));
454 }
455
456 virtual bool InstallNamedChunks(const TArrayView<const FName>& NamedChunks) override
457 {
458 return false;
459 }
460
461 virtual bool UninstallNamedChunks(const TArrayView<const FName>& NamedChunks) override
462 {
463 return false;
464 }
465
466 virtual EChunkLocation::Type GetNamedChunkLocation(const FName NamedChunk) override
467 {
469 }
470
471 virtual float GetNamedChunkProgress(const FName NamedChunk, EChunkProgressReportingType::Type ReportType) override
472 {
473 return 0.0f;
474 }
475
476 virtual bool PrioritizeNamedChunk(const FName NamedChunk, EChunkPriority::Type Priority) override
477 {
478 return false;
479 }
480
481 virtual ENamedChunkType GetNamedChunkType(const FName NamedChunk) const override
482 {
484 }
485
487 {
488 return TArray<FName>();
489 }
490
491 virtual FDelegateHandle AddNamedChunkInstallDelegate(FPlatformNamedChunkInstallDelegate Delegate) override
492 {
493 return NamedChunkInstallDelegate.Add(Delegate);
494 }
495
496 virtual void RemoveNamedChunkInstallDelegate(FDelegateHandle Delegate) override
497 {
498 NamedChunkInstallDelegate.Remove(Delegate);
499 }
500
501
502protected:
503
504 /** Delegates called when installation succeeds or fails */
505 FPlatformChunkInstallMultiDelegate InstallDelegate;
506 FPlatformNamedChunkInstallMultiDelegate NamedChunkInstallDelegate;
507
508 virtual EChunkLocation::Type GetChunkLocation(uint32 ChunkID) override
509 {
511 }
512};
513
514
515// temporary helper base class for platform chunk installers that have implemented named chunk support to provide FCustomChunk emulation
517{
518public:
519 virtual bool SupportsIntelligentInstall() override final { return true; }
520 virtual bool IsChunkInstallationPending(const TArray<FCustomChunk>& ChunkTagsID) override final;
521 virtual bool InstallChunks(const TArray<FCustomChunk>& ChunkTagsID) override final;
522 virtual bool UninstallChunks(const TArray<FCustomChunk>& ChunkTagsID) override final;
523};
524
#define UE_DEPRECATED(Version, Message)
#define DECLARE_MULTICAST_DELEGATE_TwoParams(DelegateName, Param1Type, Param2Type)
#define DECLARE_DELEGATE_TwoParams(DelegateName, Param1Type, Param2Type)
#define DECLARE_DELEGATE_OneParam(DelegateName, Param1Type)
DECLARE_LOG_CATEGORY_EXTERN(LogChunkInstaller, Log, All)
#define PRAGMA_ENABLE_DEPRECATION_WARNINGS
#define PRAGMA_DISABLE_DEPRECATION_WARNINGS
#define TEXT(x)
Definition Platform.h:1108
virtual bool IsChunkInstallationPending(const TArray< FCustomChunk > &ChunkTagsID) override final
virtual bool InstallChunks(const TArray< FCustomChunk > &ChunkTagsID) override final
virtual bool UninstallChunks(const TArray< FCustomChunk > &ChunkTagsID) override final
virtual EChunkLocation::Type GetPakchunkLocation(int32 PakchunkIndex) override
virtual void RemoveChunkInstallDelegate(FDelegateHandle Delegate) override
virtual float GetChunkProgress(uint32 ChunkID, EChunkProgressReportingType::Type ReportType) override
virtual EChunkInstallSpeed::Type GetInstallSpeed() override
virtual EChunkLocation::Type GetChunkLocation(uint32 ChunkID) override
FPlatformChunkInstallMultiDelegate InstallDelegate
virtual bool IsChunkInstallationPending(const TArray< FCustomChunk > &ChunkTags) override
virtual void RemoveNamedChunkInstallDelegate(FDelegateHandle Delegate) override
virtual bool PrioritizePakchunk(int32 PakchunkIndex, EChunkPriority::Type Priority)
virtual bool GetProgressReportingTypeSupported(EChunkProgressReportingType::Type ReportType) override
virtual bool InstallChunks(const TArray< FCustomChunk > &ChunkTagIDs) override
virtual bool PrioritizeNamedChunk(const FName NamedChunk, EChunkPriority::Type Priority) override
virtual bool SupportsIntelligentInstall() override
virtual FDelegateHandle AddChunkInstallDelegate(FPlatformChunkInstallDelegate Delegate) override
virtual EChunkLocation::Type GetNamedChunkLocation(const FName NamedChunk) override
virtual bool UninstallNamedChunks(const TArrayView< const FName > &NamedChunks) override
virtual TArray< FName > GetNamedChunksByType(ENamedChunkType NamedChunkType) const override
virtual float GetNamedChunkProgress(const FName NamedChunk, EChunkProgressReportingType::Type ReportType) override
virtual void ExternalNotifyChunkAvailable(uint32 InChunkID) override
virtual bool SetInstallSpeed(EChunkInstallSpeed::Type InstallSpeed) override
virtual bool UninstallChunks(const TArray< FCustomChunk > &ChunkTagsID) override
virtual ENamedChunkType GetNamedChunkType(const FName NamedChunk) const override
virtual bool PrioritizeChunk(uint32 ChunkID, EChunkPriority::Type Priority) override
virtual bool UninstallNamedChunk(const FName NamedChunk) override
virtual bool IsNamedChunkInProgress(const FName NamedChunk) override
virtual bool InstallNamedChunks(const TArrayView< const FName > &NamedChunks) override
virtual FDelegateHandle AddNamedChunkInstallDelegate(FPlatformNamedChunkInstallDelegate Delegate) override
virtual bool InstallNamedChunk(const FName NamedChunk) override
FPlatformNamedChunkInstallMultiDelegate NamedChunkInstallDelegate
virtual TArray< FCustomChunk > GetCustomChunksByType(ECustomChunkType DesiredChunkType) override
virtual bool SupportsNamedChunkInstall() const override
virtual bool DebugStartNextChunk()=0
virtual bool IsChunkInstallationPending(const TArray< FCustomChunk > &ChunkTagsID)=0
virtual EChunkLocation::Type GetPakchunkLocation(int32 PakchunkIndex)=0
virtual bool SupportsIntelligentInstall()=0
virtual EChunkLocation::Type GetChunkLocation(uint32 ChunkID)=0
virtual float GetNamedChunkProgress(const FName NamedChunk, EChunkProgressReportingType::Type ReportType)=0
virtual float GetChunkProgress(uint32 ChunkID, EChunkProgressReportingType::Type ReportType)=0
virtual bool PrioritizeNamedChunk(const FName NamedChunk, EChunkPriority::Type Priority)=0
virtual bool UninstallChunks(const TArray< FCustomChunk > &ChunkTagsID)=0
virtual void ExternalNotifyChunkAvailable(uint32 InChunkID)=0
virtual bool InstallChunks(const TArray< FCustomChunk > &ChunkTagsID)=0
virtual void RemoveChunkInstallDelegate(FDelegateHandle Delegate)=0
virtual TArray< FCustomChunk > GetCustomChunksByType(ECustomChunkType DesiredChunkType)=0
virtual EChunkInstallSpeed::Type GetInstallSpeed()=0
virtual bool UninstallNamedChunk(const FName NamedChunk)=0
virtual ENamedChunkType GetNamedChunkType(const FName NamedChunk) const =0
virtual void RemoveNamedChunkInstallDelegate(FDelegateHandle Delegate)=0
virtual bool PrioritizeChunk(uint32 ChunkID, EChunkPriority::Type Priority)=0
virtual bool InstallNamedChunk(const FName NamedChunk)=0
virtual FDelegateHandle AddChunkInstallDelegate(FPlatformChunkInstallDelegate Delegate)=0
virtual FDelegateHandle AddNamedChunkInstallDelegate(FPlatformNamedChunkInstallDelegate Delegate)=0
virtual bool GetProgressReportingTypeSupported(EChunkProgressReportingType::Type ReportType)=0
virtual bool SetInstallSpeed(EChunkInstallSpeed::Type InstallSpeed)=0
virtual TArray< FName > GetNamedChunksByType(ENamedChunkType NamedChunkType) const =0
virtual bool IsNamedChunkInProgress(const FName NamedChunk)=0
virtual bool SupportsNamedChunkInstall() const =0
virtual EChunkLocation::Type GetNamedChunkLocation(const FName NamedChunk)=0
virtual bool InstallNamedChunks(const TArrayView< const FName > &NamedChunks)=0
virtual bool PrioritizePakchunk(int32 PakchunkIndex, EChunkPriority::Type Priority)=0
virtual bool UninstallNamedChunks(const TArrayView< const FName > &NamedChunks)=0
virtual IPlatformChunkInstall * GetPlatformChunkInstall()=0
FCustomChunk(FString InTag, uint32 InID, ECustomChunkType InChunkType, FString InTag2=TEXT(""))
FCustomChunkMapping(FString InPattern, uint32 InChunkID, CustomChunkMappingType InMappingType)
CustomChunkMappingType MappingType