A ResourceLoader that can load resources from the files produced by a ResourceCompiler. More...
#include <CompiledResourceLoader.h>
Public Member Functions | |
CompiledResourceLoader (const string &resourceDataFile) | |
Creates a new CompiledResourceLoader. | |
virtual | ~CompiledResourceLoader () |
Deletes this CompiledResourceLoader. | |
virtual string | findResource (const string &name) |
Returns the path of the resource of the given name. | |
virtual ptr< ResourceDescriptor > | loadResource (const string &name) |
Loads the ResourceDescriptor of the given name. | |
virtual ptr< ResourceDescriptor > | reloadResource (const string &name, ptr< ResourceDescriptor > currentValue) |
Reloads the ResourceDescriptor of the given name. | |
Protected Member Functions | |
void | addPath (const string &name, const string &path) |
Adds a resource path to paths. | |
void | addResource (const string &name, ptr< ResourceDescriptor > desc) |
Adds a resource descriptor to resources. | |
Protected Attributes | |
unsigned char * | data |
The data parts of the resources that can be loaded by this loader. | |
map< string, string > | paths |
The paths that can be returned by findResource. | |
map< string, ptr < ResourceDescriptor > > | resources |
The resource descriptors that can be returned by loadResource. |
A ResourceLoader that can load resources from the files produced by a ResourceCompiler.
This class is intended to be subclassed in order to include the source code generated by a ResourceCompiler:
class MyResourceLoader : public CompiledResourceLoader { public: MyResourceLoader(const string &resourceDataFile) : CompiledResourceLoader(resourceDataFile) { #include "resourceFile" } };
This source code will construct the resource descriptors of the resources that will be loaded by this loader, during the creation of this loader.
ork::CompiledResourceLoader::CompiledResourceLoader | ( | const string & | resourceDataFile | ) |
Creates a new CompiledResourceLoader.
resourceDataFile | a file containing the data parts of the resources that must be loaded by this loader. This file must have been produced by a ResourceCompiler. |
virtual ork::CompiledResourceLoader::~CompiledResourceLoader | ( | ) | [virtual] |
Deletes this CompiledResourceLoader.
void ork::CompiledResourceLoader::addPath | ( | const string & | name, | |
const string & | path | |||
) | [protected] |
Adds a resource path to paths.
This method is called by the code generated by ResourceCompiler.
void ork::CompiledResourceLoader::addResource | ( | const string & | name, | |
ptr< ResourceDescriptor > | desc | |||
) | [protected] |
Adds a resource descriptor to resources.
This method is called by the code generated by ResourceCompiler.
virtual string ork::CompiledResourceLoader::findResource | ( | const string & | name | ) | [virtual] |
Returns the path of the resource of the given name.
This method looks for paths stored in the paths map, initialized during the construction of this loader.
name | the name of a resource. |
exception | if the resource is not found. |
Implements ork::ResourceLoader.
virtual ptr<ResourceDescriptor> ork::CompiledResourceLoader::loadResource | ( | const string & | name | ) | [virtual] |
Loads the ResourceDescriptor of the given name.
This method looks for resource descriptors stored in the resources map, initialized during the construction of this loader.
name | the name of the ResourceDescriptor to be loaded. |
Implements ork::ResourceLoader.
virtual ptr<ResourceDescriptor> ork::CompiledResourceLoader::reloadResource | ( | const string & | name, | |
ptr< ResourceDescriptor > | currentValue | |||
) | [virtual] |
Reloads the ResourceDescriptor of the given name.
This method always return NULL as the resources managed by this loader can not change.
name | the name of the ResourceDescriptor to be loaded. | |
currentValue | the current value of this ResourceDescriptor. |
Implements ork::ResourceLoader.
unsigned char* ork::CompiledResourceLoader::data [protected] |
The data parts of the resources that can be loaded by this loader.
map<string, string> ork::CompiledResourceLoader::paths [protected] |
The paths that can be returned by findResource.
map< string, ptr<ResourceDescriptor> > ork::CompiledResourceLoader::resources [protected] |
The resource descriptors that can be returned by loadResource.