Antkeeper
0.0.1
|
Manages the loading, caching, and saving of resources. More...
#include <resource-manager.hpp>
Public Member Functions | |
resource_manager () | |
Constructs a resource manager. More... | |
~resource_manager () | |
Destructs a resource manager. More... | |
bool | mount (const std::filesystem::path &path) |
Adds a directory or archive to the search path. More... | |
bool | unmount (const std::filesystem::path &path) |
Removes a directory or archive from the search path. More... | |
template<class T > | |
std::shared_ptr< T > | load (const std::filesystem::path &path) |
Loads and caches a resource. More... | |
template<class T > | |
bool | save (const T &resource, const std::filesystem::path &path) const |
Saves a resource to a file. More... | |
bool | set_write_path (const std::filesystem::path &path) |
Sets the path to a directory or archive where files can be written. More... | |
const std::filesystem::path & | get_write_path () const noexcept |
Returns the path to the directory or archive to which files are written. More... | |
Manages the loading, caching, and saving of resources.
Definition at line 37 of file resource-manager.hpp.
resource_manager::resource_manager | ( | ) |
Constructs a resource manager.
std::runtime_error | Failed to initialize PhysicsFS. |
Definition at line 27 of file resource-manager.cpp.
resource_manager::~resource_manager | ( | ) |
Destructs a resource manager.
Definition at line 58 of file resource-manager.cpp.
|
inlinenoexcept |
Returns the path to the directory or archive to which files are written.
Definition at line 107 of file resource-manager.hpp.
std::shared_ptr< T > resource_manager::load | ( | const std::filesystem::path & | path | ) |
Loads and caches a resource.
If the resource has already been loaded the cached resource will be returned.
T | Resource type. |
path | Path to the resource to load. |
nullptr
if the resource could not be loaded. Definition at line 145 of file resource-manager.hpp.
bool resource_manager::mount | ( | const std::filesystem::path & | path | ) |
Adds a directory or archive to the search path.
path | Path to the directory or archive to mount. |
true
if the directory or archive was successfully mounted, false
otherwise. Definition at line 72 of file resource-manager.cpp.
bool resource_manager::save | ( | const T & | resource, |
const std::filesystem::path & | path | ||
) | const |
Saves a resource to a file.
T | Resource type. |
resource | Resource to save. |
path | Path to where the resource file should be written. |
true
if the resource was successfully saved, false
otherwise. Definition at line 179 of file resource-manager.hpp.
bool resource_manager::set_write_path | ( | const std::filesystem::path & | path | ) |
Sets the path to a directory or archive where files can be written.
path | Path to the directory or archive to which files should be written. |
true
if the write path was set successfully, false
otherwise. Definition at line 106 of file resource-manager.cpp.
bool resource_manager::unmount | ( | const std::filesystem::path & | path | ) |
Removes a directory or archive from the search path.
path | Path to the directory or archive to unmount. |
true
if the directory or archive was successfully unmounted, false
otherwise. Definition at line 89 of file resource-manager.cpp.