![]() |
galaxy 1.0.0
Real-Time C++23 Game Programming Framework. Built on data-driven design principles and agile software engineering.
|
Cache for resources such as audio, fonts, etc. More...
#include <Cache.hpp>
Collaboration diagram for galaxy::Cache< Resource, SpecLoader >:Public Member Functions | |
| Cache () noexcept | |
| Constructor. | |
| ~Cache () | |
| Destructor. | |
| void | load_file (const std::string &file) |
| Load a resource. | |
| template<typename... Args> requires meta::not_memory<Resource> && meta::is_class<Resource> && meta::is_instance_of_v<SpecLoader, Loader> | |
| void | load_resource (const std::string &key, Args &&... args) |
| Loads a resource with custom args. | |
| void | load_folder (const std::string &dir) |
| Load all resources in a folder. | |
| void | insert (const std::string &key, std::shared_ptr< Resource > resource) noexcept |
| Insert a resource directly into the cache. | |
| std::shared_ptr< Resource > | get (const std::string &key) noexcept |
| Get a resource. | |
| bool | has (const std::string &key) noexcept |
| Check if a resource exists. | |
| void | clear () |
| Destroy all data in cache. | |
| bool | empty () const noexcept |
| Does the cache have any resources. | |
| std::size_t | size () const noexcept |
| Get amount of resources cached. | |
| const Map & | cache () const noexcept |
| Get entire resource cache. | |
Private Types | |
| using | Map = ankerl::unordered_dense::map<std::uint64_t, std::shared_ptr<Resource>> |
| Use a dense map for storage. | |
Private Member Functions | |
| Cache (const Cache &)=delete | |
| Copy constructor. | |
| Cache (Cache &&)=delete | |
| Move constructor. | |
| Cache & | operator= (const Cache &)=delete |
| Copy assignment operator. | |
| Cache & | operator= (Cache &&)=delete |
| Move assignment operator. | |
Private Attributes | |
| SpecLoader | m_loader |
| Flexible Loader used to create/load a Resource into the cache. | |
| Map | m_cache |
| Resource storage map. | |
Cache for resources such as audio, fonts, etc.
| Resource | A resource is a class containing data, and cannot be a ref or ptr. |
| SpecLoader | A template specialization of a Loader, to load the Resource. |
|
private |
|
inlinenoexcept |
|
inline |
|
privatedelete |
Copy constructor.
|
privatedelete |
Move constructor.
|
inline |
|
inline |
|
inline |
Load all resources in a folder.
Key becomes filename. This expects the resource to have a compatible string constructor.
| dir | The directory in the vfs to load from. |
Definition at line 212 of file Cache.hpp.
Here is the call graph for this function:
Here is the caller graph for this function:
|
inlinenoexcept |
|
inlinenodiscardnoexcept |
|
inlinenodiscardnoexcept |
|
inline |
|
inlinenodiscardnoexcept |
|
inlinenodiscardnoexcept |
|
inlinenodiscardnoexcept |
|
privatedelete |
Copy assignment operator.
|
privatedelete |
Move assignment operator.
|
private |
|
private |