2#ifndef LIBSBX_IO_LOADER_FACTORY_HPP_
3#define LIBSBX_IO_LOADER_FACTORY_HPP_
8#include <unordered_map>
12template<
typename Type,
typename Result>
15 using load_function_type = std::function<Result(
const std::filesystem::path&)>;
16 using unload_function_type = std::function<void(Result&)>;
18 struct function_handle_type {
19 load_function_type load_function;
20 unload_function_type unload_function;
23 using loader_container_type = std::unordered_map<std::string, function_handle_type>;
27 template<
typename Derived>
32 using result_type = Result;
36 template<
typename... Extensions>
37 static auto register_extensions(Extensions&&... extensions) ->
bool {
39 .load_function = &Derived::load,
40 .unload_function = &Derived::unload_wrapper
46 static auto unload_wrapper(Result& result) ->
void {
47 Derived::unload(result);
50 static auto unload(Result& result) ->
void {
51 static_cast<void>(result);
58 static auto _loaders() -> loader_container_type& {
59 static auto loaders = loader_container_type{};
Definition: loader_factory.hpp:28
Definition: loader_factory.hpp:13