FYP  1.0.0
Final Year Project -- Alexander Meuer
ResourceManager< T > Class Template Reference

Simple SFML resource manager. More...

#include <ResourceManager.hpp>

Collaboration diagram for ResourceManager< T >:
Collaboration graph

Public Member Functions

T & get (std::string const &path)
 Gets a resource by its path in the file system. If the resource specified by path has not already been loaded: Loads the resource, puts the resource into the map (with path as the key), returns the loaded resource. If the key "path" exists in the map it means the resource has already been loaded, so just return the resource. More...
 
template<>
thor::FrameAnimation & get (std::string const &path)
 

Static Public Member Functions

static std::unique_ptr< ResourceManager< T > > const & instance ()
 Instanciates (or returns the instance of) the ResourceManager. Instanciates (or gets the existing instance of) the ResourceManager<T> where T = an SFML resource type. Each instance of ResourceManager manages a different type of resource (e.g. ResourceManager<Texture>, ResourceManager<Font>).
 

Private Attributes

std::map< std::string, std::unique_ptr< T > > mResources
 
std::mutex mResourceMutex
 

Static Private Attributes

static std::unique_ptr< ResourceManager< T > > mInstance = nullptr
 

Detailed Description

template<typename T>
class ResourceManager< T >

Simple SFML resource manager.

Member Function Documentation

template<typename T >
T & ResourceManager< T >::get ( std::string const &  path)

Gets a resource by its path in the file system. If the resource specified by path has not already been loaded: Loads the resource, puts the resource into the map (with path as the key), returns the loaded resource. If the key "path" exists in the map it means the resource has already been loaded, so just return the resource.

Parameters
pathThe location of the resource in the file system.
Returns
A reference to the requested resource.

Member Data Documentation

template<typename T >
std::map< std::string, std::unique_ptr<T> > ResourceManager< T >::mResources
private

Map of strings to unique resource pointers.


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