|
libultraship
Reimplementations of libultra (N64 SDK) functions for modern hardware
|
Abstract factory interface for deserializing a specific resource type and format. More...
#include <ResourceFactory.h>
Public Member Functions | |
| virtual std::shared_ptr< IResource > | ReadResource (std::shared_ptr< File > file, std::shared_ptr< ResourceInitData > initData)=0 |
| Deserializes a File into an IResource. | |
Protected Member Functions | |
| virtual bool | FileHasValidFormatAndReader (std::shared_ptr< File > file, std::shared_ptr< Ship::ResourceInitData > initData)=0 |
| Validates that the file's format tag and reader type are compatible with this factory. | |
Abstract factory interface for deserializing a specific resource type and format.
Implement this class to add support for a new resource type. Register the implementation with ResourceLoader::RegisterResourceFactory() so that it is invoked automatically when a matching file is encountered.
Example skeleton:
|
protectedpure virtual |
Validates that the file's format tag and reader type are compatible with this factory.
ResourceLoader calls this before invoking ReadResource(). Return false to signal that the file is malformed or in an unexpected format, which will abort loading.
| file | Raw file data to inspect. |
| initData | Metadata from the file header. |
Implemented in Ship::ResourceFactoryBinary, and Ship::ResourceFactoryXML.
|
pure virtual |
Deserializes a File into an IResource.
Called by ResourceLoader after it has selected this factory as the best match for the file's (format, type, version) triple.
| file | Raw file data with a populated Reader (BinaryReader or XMLDocument). |
| initData | Metadata parsed from the file header. |
Implemented in Fast::ResourceFactoryBinaryDisplayListV0, Fast::ResourceFactoryXMLDisplayListV0, Fast::ResourceFactoryBinaryLightV0, Fast::ResourceFactoryBinaryMatrixV0, Fast::ResourceFactoryBinaryTextureV0, Fast::ResourceFactoryBinaryTextureV1, Fast::ResourceFactoryBinaryVertexV0, and Fast::ResourceFactoryXMLVertexV0.