![]() |
Olympe Engine 2.0
2D Game Engine with ECS Architecture
|
Singleton cache for engine assets. More...
#include <AssetManager.h>
Public Member Functions | |
| AssetID | LoadTaskGraph (const std::string &path, std::vector< std::string > &outErrors) |
Loads a TaskGraphTemplate from path and caches it. | |
| const TaskGraphTemplate * | GetTaskGraph (AssetID id) const |
| Returns a non-owning pointer to the cached TaskGraphTemplate. | |
| const TaskGraphTemplate * | LoadTaskGraphFromFile (const std::string &path, std::vector< std::string > &outErrors) |
Loads a TaskGraphTemplate from path and returns a direct pointer. | |
| void | UnloadTaskGraph (AssetID id) |
Releases the cached TaskGraphTemplate for id. | |
Static Public Member Functions | |
| static AssetManager & | Get () |
| Returns the singleton AssetManager instance. | |
| static AssetID | ComputeAssetID (const std::string &path) |
| Computes the 32-bit FNV-1a hash of a file path string. | |
Private Member Functions | |
| AssetManager ()=default | |
| ~AssetManager ()=default | |
| AssetManager (const AssetManager &)=delete | |
| AssetManager & | operator= (const AssetManager &)=delete |
Private Attributes | |
| std::unordered_map< AssetID, std::unique_ptr< TaskGraphTemplate > > | m_taskGraphs |
| Cached task graph templates: AssetID -> owned template. | |
Singleton cache for engine assets.
Call Get() to obtain the singleton instance. All TaskGraphTemplate assets loaded through LoadTaskGraph() are owned by AssetManager; callers must not delete the pointers returned by GetTaskGraph().
Definition at line 61 of file AssetManager.h.
|
privatedefault |
|
privatedefault |
|
privatedelete |
Computes the 32-bit FNV-1a hash of a file path string.
The hash is used as the AssetID so that the same path always maps to the same identifier. Exposed publicly so callers can pre-compute IDs.
| path | Any non-empty string. |
Definition at line 29 of file AssetManager.cpp.
References GetComponentTypeID_Static(), and Olympe::INVALID_ASSET_ID.
Referenced by LoadTaskGraph().
Here is the call graph for this function:
Here is the caller graph for this function:
|
static |
Returns the singleton AssetManager instance.
Definition at line 19 of file AssetManager.cpp.
Referenced by Olympe::VSGraphExecutor::HandleSubGraph(), Olympe::BlueprintEditor::PreloadATSGraphs(), and Olympe::TaskSystem::Process().
Here is the caller graph for this function:| const TaskGraphTemplate * Olympe::AssetManager::GetTaskGraph | ( | AssetID | id | ) | const |
Returns a non-owning pointer to the cached TaskGraphTemplate.
| id | AssetID previously returned by LoadTaskGraph(). |
id is unknown.Definition at line 97 of file AssetManager.cpp.
References GetComponentTypeID_Static(), and m_taskGraphs.
Referenced by LoadTaskGraphFromFile(), and Olympe::TaskSystem::Process().
Here is the call graph for this function:
Here is the caller graph for this function:| AssetID Olympe::AssetManager::LoadTaskGraph | ( | const std::string & | path, |
| std::vector< std::string > & | outErrors | ||
| ) |
Loads a TaskGraphTemplate from path and caches it.
If the asset has already been loaded (same path hash), the cached AssetID is returned immediately without re-reading the file.
| path | Absolute or relative path to the JSON task graph file. |
| outErrors | Receives human-readable error messages on failure. |
Definition at line 60 of file AssetManager.cpp.
References ComputeAssetID(), GetComponentTypeID_Static(), Olympe::INVALID_ASSET_ID, Olympe::TaskGraphLoader::LoadFromFile(), m_taskGraphs, and SYSTEM_LOG.
Referenced by LoadTaskGraphFromFile(), and Olympe::BlueprintEditor::PreloadATSGraphs().
Here is the call graph for this function:
Here is the caller graph for this function:| const TaskGraphTemplate * Olympe::AssetManager::LoadTaskGraphFromFile | ( | const std::string & | path, |
| std::vector< std::string > & | outErrors | ||
| ) |
Loads a TaskGraphTemplate from path and returns a direct pointer.
Convenience wrapper around LoadTaskGraph() + GetTaskGraph() for use in code that needs a template pointer without managing AssetIDs (e.g., SubGraph execution in VSGraphExecutor).
| path | Absolute or relative path to the JSON task graph file. |
| outErrors | Receives human-readable error messages on failure. |
Definition at line 107 of file AssetManager.cpp.
References GetComponentTypeID_Static(), GetTaskGraph(), Olympe::INVALID_ASSET_ID, and LoadTaskGraph().
Referenced by Olympe::VSGraphExecutor::HandleSubGraph().
Here is the call graph for this function:
Here is the caller graph for this function:
|
privatedelete |
Releases the cached TaskGraphTemplate for id.
After this call, any raw pointers previously obtained from GetTaskGraph() for the same id are dangling and must not be used.
| id | AssetID returned by LoadTaskGraph(). |
Definition at line 118 of file AssetManager.cpp.
References GetComponentTypeID_Static(), m_taskGraphs, and SYSTEM_LOG.
Here is the call graph for this function:
|
private |
Cached task graph templates: AssetID -> owned template.
Definition at line 159 of file AssetManager.h.
Referenced by GetTaskGraph(), LoadTaskGraph(), and UnloadTaskGraph().