OpenLexocad  27.1
entt::loader< Loader, Resource > Class Template Reference

Base class for resource loaders. More...

#include <entt.hpp>

Friends

struct cache< Resource >
 Resource loaders are friends of their caches. More...
 

Detailed Description

template<typename Loader, typename Resource>
class entt::loader< Loader, Resource >

Base class for resource loaders.

Resource loaders must inherit from this class and stay true to the CRTP idiom. Moreover, a resource loader must expose a public, const member function named load that accepts a variable number of arguments and returns a shared pointer to the resource just created.
As an example:

struct my_resource {};
struct my_loader: entt::loader<my_loader, my_resource> {
std::shared_ptr<my_resource> load(int) const {
// use the integer value somehow
return std::make_shared<my_resource>();
}
};

In general, resource loaders should not have a state or retain data of any type. They should let the cache manage their resources instead.

Note
Base class and CRTP idiom aren't strictly required with the current implementation. One could argue that a cache can easily work with loaders of any type. However, future changes won't be breaking ones by forcing the use of a base class today and that's why the model is already in its place.
Template Parameters
LoaderType of the derived class.
ResourceType of resource for which to use the loader.

Friends And Related Function Documentation

◆ cache< Resource >

template<typename Loader , typename Resource >
friend struct cache< Resource >
friend

Resource loaders are friends of their caches.


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