sftools  2.0 dev
Bunch of tools for SFML application development
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Pages
Public Member Functions | List of all members
sftools::loader::ResourceLoader< R > Struct Template Referenceabstract

Generic resource loader. More...

#include <Loaders.hpp>

+ Collaboration diagram for sftools::loader::ResourceLoader< R >:

Public Member Functions

virtual ~ResourceLoader ()
 Virtual destructor.
 
R * operator() (std::string const &id)
 Load operator.
 
virtual bool load (R &res, std::string src)=0
 Load the content of a resource with the given file.
 

Detailed Description

template<typename R>
struct sftools::loader::ResourceLoader< R >

Generic resource loader.

It's primary use is to help the GenericManager. This generic loader must be specialized by implementing load().

Template Parameters
RResource type
See Also
GenericManager
LoadFromFile
OpenFromFile

Definition at line 61 of file Loaders.hpp.

Constructor & Destructor Documentation

template<typename R >
virtual sftools::loader::ResourceLoader< R >::~ResourceLoader ( )
inlinevirtual

Virtual destructor.

Definition at line 66 of file Loaders.hpp.

Member Function Documentation

template<typename R >
virtual bool sftools::loader::ResourceLoader< R >::load ( R &  res,
std::string  src 
)
pure virtual

Load the content of a resource with the given file.

Note
subclasses must implement this function in order to customize ResourceLoader.
Parameters
resResource to be feed with a new content
srcFile containing the new content to be loaded
Returns
true if loading the resource succeed; false otherwise

Implemented in sftools::loader::OpenFromFile< R >, and sftools::loader::LoadFromFile< R >.

Referenced by sftools::loader::ResourceLoader< R >::operator()().

template<typename R >
R* sftools::loader::ResourceLoader< R >::operator() ( std::string const &  id)
inline

Load operator.

It create a resource and use load() to initialize its content.

Parameters
idResource id to load
Returns
a pointer to a valid R object if load() succeed or 0 if it failed

Definition at line 80 of file Loaders.hpp.

References sftools::Locations::begin(), sftools::Locations::end(), sftools::Singleton< T, F >::getInstance(), and sftools::loader::ResourceLoader< R >::load().


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