Smolgui
Immediate gui library based on SFML
Loading...
Searching...
No Matches
sgui::ResourcesHolder< Resource, Identifier > Class Template Reference

load and hold resources of all kind (image, music, etc.), that can be retrieved with Identifier that are comparable. Note that Resource should implement a "bool loadFromFile" function for this holder to work. sf::Font use openFromFile, but it's handled with type test. More...

#include <ResourcesHolder.h>

Public Member Functions

template<typename... Parameters>
bool load (const Identifier &id, const std::string &filename, Parameters &&... args)
 load resource from file. Note that for TextContainer or GuiLayout, you can store resource in several files and call load with the same id but different files name.
template<typename... Parameters>
bool reload (const Identifier &id, Parameters &&... args)
 reload resource from file (will not work if load was not called before)
const Resource & get (const Identifier &id) const
 get resource from its identifier, return first element if id was not registered
Resource & get (const Identifier &id)
 get mutable resource from its identifier, return first element if id was not registered

Detailed Description

template<typename Resource, typename Identifier = std::string>
class sgui::ResourcesHolder< Resource, Identifier >

load and hold resources of all kind (image, music, etc.), that can be retrieved with Identifier that are comparable. Note that Resource should implement a "bool loadFromFile" function for this holder to work. sf::Font use openFromFile, but it's handled with type test.

Member Function Documentation

◆ get() [1/2]

template<typename Resource, typename Identifier = std::string>
Resource & sgui::ResourcesHolder< Resource, Identifier >::get ( const Identifier & id)

get mutable resource from its identifier, return first element if id was not registered

◆ get() [2/2]

template<typename Resource, typename Identifier = std::string>
const Resource & sgui::ResourcesHolder< Resource, Identifier >::get ( const Identifier & id) const

get resource from its identifier, return first element if id was not registered

◆ load()

template<typename Resource, typename Identifier = std::string>
template<typename... Parameters>
bool sgui::ResourcesHolder< Resource, Identifier >::load ( const Identifier & id,
const std::string & filename,
Parameters &&... args )

load resource from file. Note that for TextContainer or GuiLayout, you can store resource in several files and call load with the same id but different files name.

◆ reload()

template<typename Resource, typename Identifier = std::string>
template<typename... Parameters>
bool sgui::ResourcesHolder< Resource, Identifier >::reload ( const Identifier & id,
Parameters &&... args )

reload resource from file (will not work if load was not called before)


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