LoaderManager
Handles and tracks loaded and pending data for resource
loading.
This class manages the loading process for various resources like
textures, models, and other assets. It provides progress tracking, error
handling, and URL modification capabilities for different loading
scenarios.
- Progress tracking for multiple loaders
- Error handling and reporting
- URL modification for custom loading sources
- Handler registration for different file types
Methods
LoaderManager()
Default constructor - creates a loading manager with default settings
LoaderManager(OnLoadCallback onLoad, OnProgressCallback onProgress, OnErrorCallback onError)
Constructor with callback functions
| onLoad | Function called when all loading is complete - optional | |
| onProgress | Function called when an item completes loading - optional | |
| onError | Function called when loading errors occur - optional |
void addHandler(const string& pattern, void* loader)
Registers a loader for files matching the pattern
| pattern | File extension pattern (e.g., ".png", ".obj") | |
| loader | Loader instance to handle matching files |
void* getHandler(const string& file) const
Gets the registered loader for a specific file
| file | File path to get handler for |
void removeHandler(const string& pattern)
Removes the loader for the given pattern
| pattern | File extension pattern to remove |
string resolveURL(const string& url) const
Resolves a URL using the URL modifier callback
| url | Original URL to resolve |
void setURLModifier(URLModifierCallback callback)
Sets the URL modifier callback function
| callback | Function to modify URLs before loading |
void itemStart(const string& url)
Called by loaders when starting to load an item
| url | URL of the item being loaded |
void itemEnd(const string& url)
Called by loaders when an item finishes loading
| url | URL of the completed item |
void itemError(const string& url)
Called by loaders when an item fails to load
| url | URL of the failed item |
Properties
| enabled | bool | Active/inactive |
| id | u32 | Unique identifier |
| isLoaderManager | bool | Read-only tag |
| isLoading | bool | Whether currently loading |
| itemsLoaded | u32 | Number of items loaded so far |
| itemsTotal | u32 | Total number of items to load |
| name | string | Optional display name |
| onError | OnErrorCallback | Called when loading errors occur |
| onLoad | OnLoadCallback | Called when all loading completes |
| onProgress | OnProgressCallback | Called when an item completes |
| onStart | OnStartCallback | Called when loading starts |
| urlModifier | URLModifierCallback | URL modification callback |
| uuid | string | UUID string |
| version | u32 | Bumps on change |