wPlot2D version: 0.1.0
A lightweight C++ library for clear and customizable 2D scientific plots.
Loading...
Searching...
No Matches
wEngine::AssetManager Class Reference

Manages graphical assets such as fonts for reuse across the application. More...

#include <wAssetManager.hpp>

Public Member Functions

 AssetManager ()=default
 AssetManager (const AssetManager &)=delete
AssetManageroperator= (const AssetManager &)=delete
 ~AssetManager ()=default
void LoadFont (const std::string &name, const std::string &fileName)
 Loads a font from file and stores it under a given name.
sf::Font & getFont (const std::string &name)
 Retrieves a reference to a previously loaded font.
void RemoveFont (const std::string &name)
 Removes a previously loaded font from memory.
void debugPrintFonts () const
 Prints the list of loaded fonts to standard output.

Detailed Description

Manages graphical assets such as fonts for reuse across the application.

This class provides a centralized way to load, access, and manage graphical assets, currently supporting fonts via SFML. Assets are identified by string keys and stored internally to avoid reloading them multiple times.

Key features:

  • Load fonts from file and associate them with a name.
  • Access loaded fonts via their name.
  • Remove fonts from memory when no longer needed.
  • Debug printing of loaded assets.

This manager is non-copyable to ensure centralized ownership and avoid accidental duplication of resources.

Note
If an asset fails to load or is accessed without being loaded first, a std::runtime_error is thrown.
Author
Wilfried Koch

Constructor & Destructor Documentation

◆ AssetManager() [1/2]

wEngine::AssetManager::AssetManager ( )
default

◆ AssetManager() [2/2]

wEngine::AssetManager::AssetManager ( const AssetManager & )
delete

◆ ~AssetManager()

wEngine::AssetManager::~AssetManager ( )
default

Member Function Documentation

◆ operator=()

AssetManager & wEngine::AssetManager::operator= ( const AssetManager & )
delete

◆ LoadFont()

void wEngine::AssetManager::LoadFont ( const std::string & name,
const std::string & fileName )

Loads a font from file and stores it under a given name.

If successful, the font is stored under the given name and can later be retrieved with getFont( name ). If loading fails, an exception is thrown.

Parameters
nameThe unique name used to identify the font.
fileNameThe path to the font file on disk.
Exceptions
std::runtime_errorif the font cannot be loaded from file.

◆ getFont()

sf::Font & wEngine::AssetManager::getFont ( const std::string & name)

Retrieves a reference to a previously loaded font.

Parameters
nameThe name of the font previously loaded.
Returns
Reference to the corresponding sf::Font object.
Exceptions
std::runtime_errorif the font does not exist.

◆ RemoveFont()

void wEngine::AssetManager::RemoveFont ( const std::string & name)

Removes a previously loaded font from memory.

Parameters
nameThe name of the font to remove.
Exceptions
std::runtime_errorif the font does not exist.

◆ debugPrintFonts()

void wEngine::AssetManager::debugPrintFonts ( ) const

Prints the list of loaded fonts to standard output.


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