Resource is a game object that is managed by the ResourceManager. It can be loaded from a file or generated at runtime. If the resource is loaded from file, a monitor will be created to watch the file changes. When the file is modified, the resource will be reloaded. If the resource is generated at runtime, it can depend on a few other resources and the ResourceManager will update the resource when the dependencies are changed. 更多...
#include <Resource.h>
Public 成员函数 | |
| virtual | ~Resource () |
| std::string | getUri () const |
| std::vector< eve::ref< Resource > > | getDependencies () const |
| virtual void | addDependency (eve::ref< Resource > resource) |
| virtual void | adopt (eve::Resource &replacement)=0 |
Replace this instance's contents with replacement's. The ResourceManager keeps instance identity stable across reloads, so existing holders (raw pointers, refs, script instances) keep a valid object. Subclasses move the payload out of replacement, which is drained and destroyed by the caller afterwards. replacement must be the same concrete type as this. | |
Public 成员函数 继承自 eve::Object | |
| Object () | |
| void | setUpdate (Object *update) |
| Update the current object with a replacement. You don't need to care about the reference to the old object since it will be automatically updated in the ref smart pointer. | |
Protected 成员函数 | |
| Resource (std::string uri) | |
| void | setUri (std::string value) |
| Set the resource URI (the cache key). Used by ResourceManager. | |
Protected 成员函数 继承自 eve::Object | |
| virtual | ~Object () |
| bool | isDirty () const |
| Object * | getUpdate () const |
| void | ref () |
| void | unref () |
Protected 属性 | |
| std::string | uri |
| std::vector< eve::ref< Resource > > | dependencies |
Protected 属性 继承自 eve::Object | |
| Object * | update |
| unsigned | ref_count = 0 |
友元 | |
| class | ResourceManager |
详细描述
Resource is a game object that is managed by the ResourceManager. It can be loaded from a file or generated at runtime. If the resource is loaded from file, a monitor will be created to watch the file changes. When the file is modified, the resource will be reloaded. If the resource is generated at runtime, it can depend on a few other resources and the ResourceManager will update the resource when the dependencies are changed.
Resource ID format:
- File: file://path/to/file
- Generated: res://category/name
- Online: http://example.com/path/to/resource
- Save: save://path/name
- Config: config://name
The ResourceManager cache keys file-backed resources by their normalized VFS path, optionally with ?param=value suffixes for parameters that change the decoded asset (e.g. a font's pixel size). See ResourceManager::makeKey.
在文件 Resource.h 第 35 行定义.
构造及析构函数说明
◆ ~Resource()
|
inlinevirtual |
在文件 Resource.h 第 37 行定义.
◆ Resource()
|
inlineprotected |
在文件 Resource.h 第 55 行定义.
成员函数说明
◆ addDependency()
在文件 Resource.h 第 42 行定义.
引用了 dependencies.
◆ adopt()
|
pure virtual |
Replace this instance's contents with replacement's. The ResourceManager keeps instance identity stable across reloads, so existing holders (raw pointers, refs, script instances) keep a valid object. Subclasses move the payload out of replacement, which is drained and destroyed by the caller afterwards. replacement must be the same concrete type as this.
在 eve::font::FontData, eve::image::ImageData, eve::model3d::ModelData , 以及 eve::sound::SoundData 内被实现.
被这些函数引用 eve::ResourceManager::refreshEntry().
◆ getDependencies()
在文件 Resource.h 第 40 行定义.
引用了 dependencies.
◆ getUri()
|
inline |
在文件 Resource.h 第 39 行定义.
引用了 uri.
◆ setUri()
|
inlineprotected |
Set the resource URI (the cache key). Used by ResourceManager.
在文件 Resource.h 第 58 行定义.
被这些函数引用 eve::ResourceManager::get().
友元及相关函数文档
◆ ResourceManager
|
friend |
在文件 Resource.h 第 60 行定义.
类成员变量说明
◆ dependencies
在文件 Resource.h 第 63 行定义.
被这些函数引用 addDependency() , 以及 getDependencies().
◆ uri
|
protected |
在文件 Resource.h 第 62 行定义.
该类的文档由以下文件生成:
- src/engine/common/Resource.h
Public 成员函数 继承自