![]() |
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>
Public Member Functions | |
Cache () noexcept | |
Constructor. | |
~Cache () | |
Destructor. | |
void | load (const std::string &file) |
Load a resource. | |
void | load_folder (const std::string &dir) |
Load resources of a specific type. | |
void | insert (std::string_view id, std::unique_ptr< Resource > &resource) |
Insert a resource directly into the cache. | |
Resource * | get (std::string_view id) |
Retrieve a resource. | |
void | clear () |
Destroy resources. | |
bool | has (std::string_view id) |
Check if a resource exists. | |
bool | empty () const |
Does the cache have any resources. | |
std::size_t | size () const |
Get amount of resources cached. | |
const CacheType & | cache () const |
Get entire resource cache. | |
const meta::vector< std::string > & | keys () |
Get a list of keys in the cache. | |
Private Types | |
using | CacheType = ankerl::unordered_dense::map<std::uint64_t, std::unique_ptr<Resource>> |
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. | |
std::uint64_t | hash (std::string_view str) |
Hashes the key into an integer for faster map lookup time. | |
Private Attributes | |
Loader | m_loader |
Used to load a resource into the cache. Allows for flexiblity. | |
CacheType | m_cache |
The actual data store. | |
meta::vector< std::string > | m_keys |
A list of keys currently in the cache. | |
Cache for resources such as audio, fonts, etc.
|
private |
|
inlinenoexcept |
|
inline |
|
privatedelete |
Copy constructor.
|
privatedelete |
Move constructor.
|
inline |
|
inline |
|
inline |
|
inlinenodiscard |
|
inline |
|
inlinenodiscard |
|
inlinenodiscard |
|
inlinenodiscard |
|
inlinenodiscard |
|
inlinenodiscard |
|
privatedelete |
Copy assignment operator.
|
privatedelete |
Move assignment operator.
|
inlineprivate |
|
private |
|
private |
|
private |