载入中...
搜索中...
未找到
AssetReloader.h
浏览该文件的文档.
1#pragma once
2
3// Asset ownership interface, shared by two consumers:
4//
5// 1. Hot reload: let each module react to its own asset files. The filesystem
6// watcher knows a path changed but nothing about what lives at that path,
7// so every module that owns an asset kind registers a reloader and the
8// watcher just dispatches. Modules the build does not contain simply are
9// not registered.
10// 2. Unified resource cache (common/Resource.h): on a cache miss the
11// ResourceManager asks the same registered providers to `load()` the CPU
12// resource for a key, so the engine-common layer still knows nothing about
13// graphics / particles / map / font / model / sound.
14//
15// Ordering matters when several reloaders react to one file: the cached CPU
16// resource must refresh before the GPU texture is re-uploaded, and the GPU
17// texture before the emitters / tile layers that sample it re-bind. Register
18// with a priority to express that.
19
20#include "common/Export.h"
21
22#include <string>
23
24namespace eve {
25class Resource;
26}
27
28namespace eve::caps {
29
31public:
33 enum Priority {
34 kCache = 0, // refresh cached CPU resources (ResourceManager)
35 kTexture = 10, // refresh GPU resources before their consumers re-bind
36 kConsumer = 20, // things that reference a reloaded resource
37 };
38
39 static constexpr const char* capabilityName = "IAssetReloader";
40 virtual ~IAssetReloader() = default;
41
46 virtual const char* reloadKind() const = 0;
47
53 virtual bool handlesPath(const std::string& normPath) const = 0;
54
65 virtual Resource* load(const std::string& key) { return nullptr; }
66
68 virtual bool reload(const std::string& normPath) { return false; }
69};
70
71} // namespace eve::caps
#define EVENGINE_API
宿主(eve / libmain)导出宏;插件从进程导入同一批符号。
Definition Export.h:16
Resource is a game object that is managed by the ResourceManager. It can be loaded from a file or gen...
Definition Resource.h:35
virtual const char * reloadKind() const =0
virtual bool handlesPath(const std::string &normPath) const =0
virtual ~IAssetReloader()=default
virtual Resource * load(const std::string &key)
virtual bool reload(const std::string &normPath)
Definition Build.cpp:11