Gorgon Game Engine
Loader Class Reference

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...
 

Detailed Description

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.

Member Typedef Documentation

◆ LoaderFunction

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.

Constructor & Destructor Documentation

◆ Loader() [1/2]

Loader ( GID::Type  gid,
LoaderFunction  handler 
)

Filling constructor.

◆ Loader() [2/2]

Loader ( )

Empty constructor.

Member Data Documentation

◆ GID

Gorgon ID of the resource that this loaded can load.

◆ Handler

LoaderFunction Handler

Load handler function.


The documentation for this class was generated from the following file: