Donner
C++20 SVG rendering library
Loading...
Searching...
No Matches
donner::svg::components::ResourceManagerContext Class Reference

Resource manager, which handles loading resources from URLs and caching results. More...

#include "donner/svg/components/resources/ResourceManagerContext.h"

Public Member Functions

 ResourceManagerContext (Registry &registry)
 Constructor.
 
void loadResources (std::vector< parser::ParseError > *outWarnings)
 Load resources such as images.
 
void setResourceLoader (std::unique_ptr< ResourceLoaderInterface > &&loader)
 Set the user-supplied ResourceLoaderInterface which handles loading URLs and returning their contents.
 
std::optional< Vector2igetImageSize (Entity entity) const
 Get the size of an image resource for an entity, if it has one and successfully loaded.
 

Detailed Description

Resource manager, which handles loading resources from URLs and caching results.

Member Function Documentation

◆ getImageSize()

std::optional< Vector2i > donner::svg::components::ResourceManagerContext::getImageSize ( Entity entity) const

Get the size of an image resource for an entity, if it has one and successfully loaded.

Parameters
entityEntity to get the image size for.

◆ loadResources()

void donner::svg::components::ResourceManagerContext::loadResources ( std::vector< parser::ParseError > * outWarnings)

Load resources such as images.

Note that this doesn't issue network calls directly, but relies on the user's application to handle callbacks for loading URLs and returning their contents.

Parameters
outWarningsIf non-null, warnings will be added to this vector.

◆ setResourceLoader()

void donner::svg::components::ResourceManagerContext::setResourceLoader ( std::unique_ptr< ResourceLoaderInterface > && loader)
inline

Set the user-supplied ResourceLoaderInterface which handles loading URLs and returning their contents.

Parameters
loaderResource loader interface, which will be held until overridden. Call this API again with nullptr to unset.

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