ResourceManaged

Base template class, to be used as a base from which classes which have resources that can be controlled, such as textures and music, can be derived.  Resource managed classes rely on a ResourceManager.

Children

Texture, Image

<Sample>

Summary
Base template class, to be used as a base from which classes which have resources that can be controlled, such as textures and music, can be derived.
Default constructor.
Initializing constructor, calls open with a filename/zipname.
Destructor, calls release.
Opens new resource via the associated ResourceManager.
Removes a reference to the resource, releasing if needed.
Get the name associated with the resource.
Cleans up any unused resources of the type.
Define a new named resource.
Define a new unaliased resource.

(Con/ De)structors

ResourceManaged

ResourceManaged()

Default constructor.

ResourceManaged

ResourceManaged(const std::string &name)

Initializing constructor, calls open with a filename/zipname.

Parameters

namename of resource

See Also

open

~ResourceManaged

virtual ~ResourceManaged()

Destructor, calls release.

General

open

virtual void open(const std::string &name)

Opens new resource via the associated ResourceManager.

Parameters

namename of resource

release

virtual void release()

Removes a reference to the resource, releasing if needed.  Generally called by destructor, so should rarely be called.

Accessors

getName

std::string getName() const

Get the name associated with the resource.

Returns

Name of resource, or empty string if no resource is loaded.

Resource Manager Access

cleanUp

static void cleanUp()

Cleans up any unused resources of the type.  (Ex.  Image::cleanUp() will unload all images.)

addResource

static void addResource(const std::string &name,
const typename ResMgrT::ResDescT &desc)

Define a new named resource.  (Ex.  Image::addResource(“monkey”,”images/monkey.png”) would make it so that any attempts to load “monkey” would load the image images/monkey.png)

Parameters

nameName to give to resource.
pathPath of resource data file.

addResource

static void addResource(const typename ResMgrT::ResDescT &desc)

Define a new unaliased resource.  (name == path).  (Ex.  Image::addResource(“images/monkey.png”) is essentially the same as Image::addResource(“images/monkey.png”,”images/monkey.png”)

Parameters:. path - Path of resource data file.

ResourceManaged()
Default constructor.
virtual void open(const std::string &name)
Opens new resource via the associated ResourceManager.
virtual ~ResourceManaged()
Destructor, calls release.
virtual void release()
Removes a reference to the resource, releasing if needed.
Templated base class for managing resources like textures and music.
std::string getName() const
Get the name associated with the resource.
static void cleanUp()
Cleans up any unused resources of the type.
static void addResource(const std::string &name,
const typename ResMgrT::ResDescT &desc)
Define a new named resource.
Simple OO wrapper around the concept of a texture in openGL.
Image is a class which is used to store a single image, for use in 2D games.