![]() |
Gorgon Game Engine
|
This class defines a resource loader. More...
Public Types | |
typedef std::function< Base *(std::weak_ptr< File >, std::shared_ptr< Reader >, unsigned long)> | LoaderFunction |
This is Resource loader function prototype. More... | |
Public Member Functions | |
Loader () | |
Empty constructor. More... | |
Loader (GID::Type gid, LoaderFunction handler) | |
Filling constructor. More... | |
Public Attributes | |
Resource::GID::Type | GID |
Gorgon ID of the resource that this loaded can load. More... | |
LoaderFunction | Handler |
Load handler function. More... | |
This class defines a resource loader.
The set of predefined resource loaders exists within the resource system, however, it is possible to register custom loaders for custom objects.
typedef std::function<Base* (std::weak_ptr<File>, std::shared_ptr<Reader>, unsigned long)> LoaderFunction |
This is Resource loader function prototype.
Please note that, it is possible to use your own type derived from Base for the return type. First parameter is the stream object to read data from. The stream object would be opened in binary mode. Second parameter is the size of the data chunk. After reading the object, file pointer should be moved exactly the amount of data chunk. Last parameter is the file object that manages the current load operation. This function should return nullptr in case of an error, otherwise it should return the newly loaded object. The ownership of this object will be transferred to the parent of the object and it will be deleted with its parent unless detached from the tree.
Loader | ( | GID::Type | gid, |
LoaderFunction | handler | ||
) |
Filling constructor.
Gorgon ID of the resource that this loaded can load.
LoaderFunction Handler |
Load handler function.