Dauphine  0.1
A platforming/stealth game in a medieval fantasy setting, developed with SDL2.
Public Member Functions | Private Member Functions | Private Attributes | List of all members
ResourceManager Class Reference

General resource management class. More...

#include <ResourceManager.h>

Public Member Functions

 ResourceManager ()
 The constructor. More...
 
 ~ResourceManager ()
 The destructor. More...
 
Spriteget (const std::string &path_)
 Retrieves the sprite from the resources. More...
 

Private Member Functions

Sprite::SpritePtr load (const std::string &path_)
 Constructs the desired sprite. More...
 
void registerResource (const std::string &path_, Sprite::SpritePtr resource_)
 Registers the resource on the resources map. More...
 
void unregisterResource (const std::string &path_)
 Unregisters the resource on the resources map. More...
 

Private Attributes

std::map< std::string,
Sprite::SpritePtr
resources
 
                 The map that contains all the

Sprite resources. More...

 

Detailed Description

General resource management class.

Todo:
Generalize the resource manager for audio, not just sprites.

Constructor & Destructor Documentation

ResourceManager::ResourceManager ( )

The constructor.

Initializes attributes.

ResourceManager::~ResourceManager ( )

The destructor.

Note
Warns about resources being deleted with references still pointing to them.

Member Function Documentation

Sprite * ResourceManager::get ( const std::string &  path_)

Retrieves the sprite from the resources.

Returns
The pointer to the wanted sprite. Creates it, if not already in resources.
Parameters
path_: Path to the desired sprite.
Sprite::SpritePtr ResourceManager::load ( const std::string &  path_)
private

Constructs the desired sprite.

Parameters
path_: Path to the desired sprite.
void ResourceManager::registerResource ( const std::string &  path_,
Sprite::SpritePtr  resource_ 
)
private

Registers the resource on the resources map.

Parameters
path_: Path to the sprite. Will be the key value.
resource_: The shared pointer for the resource.
void ResourceManager::unregisterResource ( const std::string &  path_)
private

Unregisters the resource on the resources map.

Parameters
path_: The key (path to sprite) on the map.

Member Data Documentation

std::map<std::string, Sprite::SpritePtr> ResourceManager::resources
private

                 The map that contains all the

Sprite resources.


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