A Resource factory, creates resources from ResourceDescriptor. More...
#include <ResourceFactory.h>
Classes | |
class | Type |
A utility template to automate the registration of new resource types. More... | |
Public Types | |
typedef ptr< Object >(* | createFunc )(ptr< ResourceManager > manager, const string &name, ptr< ResourceDescriptor > desc, const TiXmlElement *e) |
A function that creates a Resource from a ResourceDescriptor. | |
Public Member Functions | |
void | addType (const string &type, createFunc f) |
Registers a new resource type with this factory. | |
ptr< Object > | create (ptr< ResourceManager > manager, const string &name, ptr< ResourceDescriptor > desc, const TiXmlElement *e=NULL) |
Creates a Resource from the given ResourceDescriptor. | |
Static Public Member Functions | |
static ResourceFactory * | getInstance () |
Returns the unique instance of this class. |
A Resource factory, creates resources from ResourceDescriptor.
There is only one instance of this class, which registers a creation function for each resource type name.
typedef ptr<Object>(* ork::ResourceFactory::createFunc)(ptr< ResourceManager > manager, const string &name, ptr< ResourceDescriptor > desc, const TiXmlElement *e) |
A function that creates a Resource from a ResourceDescriptor.
manager | the manager that will manage the created resource. | |
name | the resource name. | |
desc | the resource descriptor. | |
e | an optional XML element providing contextual information (such as the XML element in which the resource descriptor was found). |
void ork::ResourceFactory::addType | ( | const string & | type, | |
createFunc | f | |||
) |
Registers a new resource type with this factory.
type | a resource type, as it appears in the tag of a ResourceDescriptor (e.g. texture1D, texture2D, shader, program, etc). | |
f | a function that can create resources of this type. |
ptr<Object> ork::ResourceFactory::create | ( | ptr< ResourceManager > | manager, | |
const string & | name, | |||
ptr< ResourceDescriptor > | desc, | |||
const TiXmlElement * | e = NULL | |||
) |
Creates a Resource from the given ResourceDescriptor.
manager | the manager that will manage the created resource. | |
name | the resoure name. | |
desc | the resource descriptor. | |
e | an optional XML element providing contextual information (such as the XML element in which the resource descriptor was found). |
static ResourceFactory* ork::ResourceFactory::getInstance | ( | ) | [static] |
Returns the unique instance of this class.