ChessPlusPlus  WIP
cplusplus.com Community Project
chesspp::res::ResourceManager Class Referencefinal

Manages resources used by the application. More...

#include <ResourceManager.hpp>

Classes

class  Resource
 The base class for all resource classes. More...
 

Public Member Functions

 ResourceManager (config::Configuration &conf_) noexcept
 Constructs from a chesspp::config::Configuration. More...
 
template<typename ResT , typename... Path>
auto from_config (Path const &...path) -> typename std::enable_if< std::is_base_of< Resource, ResT >::value, ResT & >::type
 Obtains a resource for a config setting, constructing it if it does not yet exist. More...
 

Detailed Description

Manages resources used by the application.

Constructor & Destructor Documentation

chesspp::res::ResourceManager::ResourceManager ( config::Configuration conf_)
inlinenoexcept

Constructs from a chesspp::config::Configuration.

Parameters
conf_the chesspp::config::Conriguration - it is referenced, not copied.

Member Function Documentation

template<typename ResT , typename... Path>
auto chesspp::res::ResourceManager::from_config ( Path const &...  path) -> typename std::enable_if < std::is_base_of<Resource, ResT>::value, ResT & >::type
inline

Obtains a resource for a config setting, constructing it if it does not yet exist.

Example invocation:

using Font_res = res::SfmlFileResource<sf::Font>;
ResourceManager &resmanager = blah;
Font_res &fontres = resmanager.from_config<Font_res>("menu", "font");
sf::Font font (fontres);
//...
Template Parameters
ResTThe type of the Resource to construct or return.
Pathdeduced by the compiler from the argument list.
Parameters
pathThe path, forwarded to chesspp::config::Configuration::setting()
Returns
a reference to the resource, of type ResT

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