载入中...
搜索中...
未找到
Resource.cpp
浏览该文件的文档.
306 eve::Diagnostic::error(eve::DiagnosticCode::Failed, "cached resource could not be resolved", norm));
Capability for submitting CPU work onto a worker pool.
Stable, structured diagnostics shared by engine modules.
static Diagnostic error(DiagnosticCode code, std::string message, std::string path={}, DiagnosticDetails details={}, std::string source={})
Construct an error diagnostic with the standard error severity.
Definition Diagnostic.h:125
ResourceManager is a singleton that manages all resources in the game. It provides a way to load,...
Definition Resource.h:152
void unloadPath(const std::string &path)
Drop every cache entry whose path matches, whatever its parameters.
Definition Resource.cpp:343
bool handlesPath(const std::string &normPath) const override
Handles path.
Definition Resource.cpp:380
eve::Result< ResourcePin > pin(Resource *resource)
Keeps one cached resource alive across unload()/clear()/reload.
Definition Resource.cpp:311
void unload(std::string key)
Drop the exact cache entry key (parameters included). The resource stays alive while other holders st...
Definition Resource.cpp:332
ResultRef< Resource > waitFor(std::string key)
Block until key is cached, failed, or unclaimed.
Definition Resource.cpp:226
eve::Result< void > request(std::string key)
Queue a cache miss load without blocking for decode to finish.
Definition Resource.cpp:149
Resource * get(std::string key)
Get the cached resource for key; on a miss, load it through the registered IAssetReloader providers a...
Definition Resource.cpp:141
eve::Result< void > requestAll(std::span< const std::string > keys)
request() every key; stops at the first hard failure.
Definition Resource.cpp:207
static std::string pathOfKey(const std::string &key)
The path part of a cache key (everything before the first '?').
Definition Resource.cpp:46
static std::string normalizePath(std::string path)
Normalize a VFS path: backslashes to '/', strip leading "./" and trailing '/'.
Definition Resource.cpp:28
size_t pendingCount() const
Number of in-flight request() jobs (including failed-not-yet-consumed).
Definition Resource.cpp:327
std::unordered_map< std::string, std::shared_ptr< AsyncLoad > > pending_
Definition Resource.h:336
Resource * borrowLocked(const ResourceRef &reference)
Borrows the live resource behind a cache entry.
Definition Resource.h:331
eve::Result< bool > reload(const std::string &normPath) override
Reloads .
Definition Resource.cpp:390
void clear()
Drop every entry and re-arm lazy registration (tests / teardown).
Definition Resource.cpp:360
static std::string makeKey(const std::string &path, const std::string &query="")
Build a cache key from a path and optional ?query parameters.
Definition Resource.cpp:37
OptionalRef< Resource > peek(const std::string &key)
Cache lookup that never starts a load.
Definition Resource.cpp:216
script::RuntimeObjectRegistry< Resource, ResourceCacheTag > registry_
Registry that exclusively owns every cached resource.
Definition Resource.h:334
std::map< std::string, ResourceRef > resources
Definition Resource.h:335
Resource is a game object that is managed by the ResourceManager. It can be loaded from a file or gen...
Definition Resource.h:51
void setUri(std::string value)
Set the resource URI (the cache key). Used by ResourceManager.
Definition Resource.h:117
EVENGINE_API_FOUNDATION std::vector< Resource * > getDependencies() const
Borrowed views of the resources this instance keeps alive.
Definition Resource.cpp:504
EVENGINE_API_FOUNDATION eve::Result< void > addDependency(Resource &dependency)
Keeps dependency alive for as long as this instance lives.
Definition Resource.cpp:511
std::vector< ResourcePin > dependencies
Keep-alive pins; see getDependencies()/addDependency().
Definition Resource.h:123
static Result failure(Status status)
Construct a failed result from a structured status.
Definition Result.h:175
static Status success(StatusCode code=StatusCode::Ok)
Construct a successful status with an explicit non-error outcome.
Definition Status.h:81
std::unique_ptr< T > Owned
C++ owning storage used by an object factory.
Definition RuntimeRegistry.h:33
@ InvalidArgument
@ NotFound
@ Failed
@ Pending
@ NotFound
@ NoOp
@ Applied
std::optional< std::reference_wrapper< T > > OptionalRef
Optional borrowed reference; it does not extend T's lifetime.
Definition BorrowedRef.h:24