|
utility 2026.1.9
A comprehensive C++ utilities library tailored for the development of modern desktop and extended reality (XR) applications.
|
The DefaultSystemIO class is a concrete implementation of the SystemIO interface that loads assets from the file system. More...
#include <headers/utility/system_io/default_system_io.hpp>


Public Member Functions | |
| DefaultSystemIO () | |
| Constructs a DefaultSystemIO. | |
| ~DefaultSystemIO () override | |
| Default destructor for DefaultSystemIO. | |
| bool | loadDirectory (const std::string &directory) override |
| Loads assets from a directory. | |
| std::shared_ptr< utility::File > | add (const std::string &path) override |
| Adds an asset to the manager by loading it from the file system. | |
| void | remove (const std::string &path, bool save=true) override |
| Removes an asset from the manager. | |
| bool | save (const std::string &path, const std::string &newPath="") override |
| Saves an asset to the file system. | |
| virtual std::shared_ptr< utility::File > | add (const std::string &path)=0 |
| Adds an asset to the manager. | |
| std::shared_ptr< utility::File > | add (const std::filesystem::path &path) |
| Adds an asset to the manager. | |
| virtual bool | loadDirectory (const std::string &directory)=0 |
| Loads assets from a directory. | |
| bool | loadDirectory (const std::filesystem::path &directory) |
| Loads assets from a directory. | |
| virtual void | remove (const std::string &path, bool save=true)=0 |
| Removes an asset from the manager. | |
| void | remove (const std::filesystem::path &path, bool save=true) |
| Removes an asset from the manager. | |
| virtual bool | save (const std::string &path, const std::string &newPath="")=0 |
| Saves an asset to the disk. | |
| bool | save (const std::filesystem::path &path, const std::filesystem::path &newPath) |
| Saves an asset to the disk. | |
| bool | save (const std::filesystem::path &path) |
| Saves an asset to its original path. | |
Public Member Functions inherited from utility::SystemIO | |
| virtual | ~SystemIO ()=default |
| Default destructor for SystemIO. | |
| bool | loadDirectory (const std::filesystem::path &directory) |
| Loads assets from a directory. | |
| std::shared_ptr< utility::File > | add (const std::filesystem::path &path) |
| Adds an asset to the manager. | |
| void | remove (const std::filesystem::path &path, bool save=true) |
| Removes an asset from the manager. | |
| bool | save (const std::filesystem::path &path, const std::filesystem::path &newPath) |
| Saves an asset to the disk. | |
| bool | save (const std::filesystem::path &path) |
| Saves an asset to its original path. | |
| bool | exists (const std::string &path) const |
| Checks if an asset exists in the manager. | |
| bool | exists (const std::filesystem::path &path) const |
| Checks if an asset exists in the manager. | |
| std::shared_ptr< utility::File > | open (const std::string &path) const |
| Opens an asset from the manager. | |
| std::shared_ptr< utility::File > | open (const std::filesystem::path &path) const |
| Opens an asset from the manager. | |
Protected Member Functions | |
| utility::logging::Logger & | getLogger (void) |
| Get the internal logger. | |
| utility::logging::Logger & | getLogger (void) const |
| Get the internal logger. | |
Additional Inherited Members | |
Protected Attributes inherited from utility::SystemIO | |
| std::map< std::string, std::shared_ptr< utility::File > > | _assets |
| Map of loaded assets. | |
The DefaultSystemIO class is a concrete implementation of the SystemIO interface that loads assets from the file system.
Logging is kept private behind an opaque logger to avoid leaking logging headers into the public API.
Definition at line 49 of file default_system_io.hpp.
| utility::DefaultSystemIO::DefaultSystemIO | ( | ) |
Constructs a DefaultSystemIO.
Definition at line 38 of file default_system_io.cpp.
|
inline |
Adds an asset to the manager.
| path | The filesystem path to the asset. |
Definition at line 96 of file system_io.hpp.
|
overridevirtual |
Adds an asset to the manager by loading it from the file system.
| path | The path to the asset file. |
Implements utility::SystemIO.
Definition at line 89 of file default_system_io.cpp.
|
virtual |
Adds an asset to the manager.
| path | The path to the asset. |
This method is pure virtual and must be implemented by derived classes. This method is responsible for loading the asset from the specified path by reading the file content and storing it in the _assets map.
Implements utility::SystemIO.
|
protected |
Get the internal logger.
Definition at line 46 of file default_system_io.cpp.
|
protected |
Get the internal logger.
Definition at line 51 of file default_system_io.cpp.
|
inline |
Loads assets from a directory.
| directory | The filesystem path to the directory containing assets. |
Definition at line 74 of file system_io.hpp.
|
overridevirtual |
Loads assets from a directory.
| directory | The path to the directory containing the assets. |
Implements utility::SystemIO.
Definition at line 56 of file default_system_io.cpp.
|
virtual |
Loads assets from a directory.
| directory | The path to the directory containing the assets. |
This method is pure virtual and must be implemented by derived classes. It is responsible for loading all assets from the specified directory by reading the file content and storing it in the _assets map.
Implements utility::SystemIO.
|
inline |
Removes an asset from the manager.
| path | The filesystem path to the asset. |
| save | Whether to save the asset before removing it. |
Definition at line 121 of file system_io.hpp.
|
overridevirtual |
Removes an asset from the manager.
| path | The path to the asset to remove. |
| save | Whether to save the asset before removing it. |
Implements utility::SystemIO.
Definition at line 131 of file default_system_io.cpp.
|
virtual |
Removes an asset from the manager.
| path | The path to the asset. |
| save | Whether to save the asset before removing it (default is true). |
This method removes the asset from the _assets map. When removing an asset, the asset file will not be deleted from the disk. When removing an asset, its content is updated on the disk if save is true. If save is false, the asset will be removed from the _assets map without saving its content on the disk. Using a deleted asset will result in undefined behavior.
Implements utility::SystemIO.
|
inline |
Saves an asset to its original path.
| path | The filesystem path to the managed asset. |
Definition at line 158 of file system_io.hpp.
|
inline |
Saves an asset to the disk.
| path | The filesystem path to the managed asset. |
| newPath | The target filesystem path where the asset is written. |
Definition at line 147 of file system_io.hpp.
|
overridevirtual |
Saves an asset to the file system.
| path | The path to the asset to save. |
| newPath | An optional new path to save the asset to. If not provided, the asset will be saved to its original path. |
Implements utility::SystemIO.
Definition at line 145 of file default_system_io.cpp.
|
virtual |
Saves an asset to the disk.
| path | The path to the asset. |
| newPath | The new path to save the asset to (optional). |
This method is pure virtual and must be implemented by derived classes. It is responsible for saving the content of the asset to the specified path. If newPath is provided, it will save the asset to that path and will not update the original path. If newPath is not provided, it will save the asset to the original path.
Implements utility::SystemIO.