Infinity Engine v0.6.20
C++ API Documentation
Loading...
Searching...
No Matches
AssetPluginStore.hpp
1#pragma once
2
3#include <Infinity/api.h>
4#include <Infinity/Assets/AssetPlugin.hpp>
5
6#include <string>
7#include <filesystem>
8#include <unordered_map>
9#include <typeindex>
10
11namespace Infinity::Assets
12{
33 class INFINITY_API_PUBLIC AssetPluginStore {
34 public:
35 // Loader configuration
36
46 static void setDefaultLoader(const std::string& name);
47
60 template<typename T>
61 static void setDefaultLoader()
62 {
63 setDefaultLoader(std::type_index(typeid(T)));
64 }
65
76 static void setSecondaryLoader(const std::string& name);
77
90 template<typename T>
91 static void setSecondaryLoader()
92 {
93 setSecondaryLoader(std::type_index(typeid(T)));
94 }
95
102 static void resetDefaults();
103
115 static void addPlugin(const std::filesystem::path& path);
116
126 static void addPlugin(CreateAssetPluginFunction* factory);
127
128 // Loader retrieval
129
140
151
162
177 template<typename T>
179 {
180 return getLoader(std::type_index(typeid(T)));
181 }
182
193 static AssetPlugin& getLoader(const std::string& name);
194
195 private:
201 static void setDefaultLoader(std::type_index type);
202
208 static void setSecondaryLoader(std::type_index type);
209
216 static AssetPlugin& getLoader(std::type_index type);
217 };
218}
Central registry and management system for source-specific AssetPlugin instances.
Definition AssetPluginStore.hpp:33
static AssetPlugin & getFallbackLoader()
Gets the fallback loader.
static void addPlugin(const std::filesystem::path &path)
Loads and registers a plugin from a shared library file.
static AssetPlugin & getLoader()
Gets a loader by its C++ type.
Definition AssetPluginStore.hpp:178
static AssetPlugin & getDefaultLoader()
Gets the currently configured default loader.
static void resetDefaults()
Resets all loader preferences to their default state.
static void setDefaultLoader(const std::string &name)
Sets the default asset loader by plugin name.
static void addPlugin(CreateAssetPluginFunction *factory)
Registers a plugin using a factory function.
static void setSecondaryLoader()
Sets the secondary asset loader by plugin type.
Definition AssetPluginStore.hpp:91
static void setSecondaryLoader(const std::string &name)
Sets the secondary asset loader by plugin name.
static void setDefaultLoader()
Sets the default asset loader by plugin type.
Definition AssetPluginStore.hpp:61
static AssetPlugin & getLoader(const std::string &name)
Gets a loader by its plugin name.
static AssetPlugin & getSecondaryLoader()
Gets the currently configured secondary loader.
Abstract base class for source-specific asset loading plugins.
Definition AssetPlugin.hpp:52
Definition Asset.hpp:11