ork::CompiledResourceLoader Class Reference
[resource]

A ResourceLoader that can load resources from the files produced by a ResourceCompiler. More...

#include <CompiledResourceLoader.h>

Inheritance diagram for ork::CompiledResourceLoader:
ork::ResourceLoader ork::Object

List of all members.

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< ResourceDescriptorloadResource (const string &name)
 Loads the ResourceDescriptor of the given name.
virtual ptr< ResourceDescriptorreloadResource (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.

Detailed Description

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.


Constructor & Destructor Documentation

ork::CompiledResourceLoader::CompiledResourceLoader ( const string &  resourceDataFile  ) 

Creates a new CompiledResourceLoader.

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


Member Function Documentation

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.

Parameters:
name the name of a resource.
Returns:
the path of this resource.
Exceptions:
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.

Parameters:
name the name of the ResourceDescriptor to be loaded.
Returns:
the ResourceDescriptor of the given name, or NULL if the resource is not found.

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.

Parameters:
name the name of the ResourceDescriptor to be loaded.
currentValue the current value of this ResourceDescriptor.
Returns:
the new value of this ResourceDescriptor, or NULL if this value has not changed.

Implements ork::ResourceLoader.


Member Data Documentation

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.

The resource descriptors that can be returned by loadResource.


Generated on Mon Oct 18 09:36:11 2010 for ork by  doxygen 1.6.1