The SystemIO class is an abstract base class for managing file assets.
More...
#include <headers/utility/system_io/system_io.hpp>
|
|
virtual | ~SystemIO ()=default |
| | Default destructor for SystemIO.
|
| |
| 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 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 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.
|
| |
| 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.
|
| |
The SystemIO class is an abstract base class for managing file assets.
Definition at line 48 of file system_io.hpp.
◆ add() [1/2]
| std::shared_ptr< utility::File > utility::SystemIO::add |
( |
const std::filesystem::path & |
path | ) |
|
|
inline |
Adds an asset to the manager.
- Parameters
-
| path | The filesystem path to the asset. |
- Returns
- A shared pointer to the File object.
Definition at line 96 of file system_io.hpp.
◆ add() [2/2]
| virtual std::shared_ptr< utility::File > utility::SystemIO::add |
( |
const std::string & |
path | ) |
|
|
pure virtual |
Adds an asset to the manager.
- Parameters
-
| path | The path to the asset. |
- Returns
- A shared pointer to the File object.
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.
Implemented in utility::DefaultSystemIO, and utility::DefaultSystemIO.
◆ exists() [1/2]
| bool utility::SystemIO::exists |
( |
const std::filesystem::path & |
path | ) |
const |
|
inline |
Checks if an asset exists in the manager.
- Parameters
-
| path | The filesystem path to the asset. |
- Returns
- True if the asset exists, false otherwise.
Definition at line 177 of file system_io.hpp.
◆ exists() [2/2]
| bool utility::SystemIO::exists |
( |
const std::string & |
path | ) |
const |
Checks if an asset exists in the manager.
- Parameters
-
| path | The path to the asset. |
- Returns
- True if the asset exists, false otherwise.
This method checks if the asset is present in the _assets map.
Definition at line 33 of file system_io.cpp.
◆ loadDirectory() [1/2]
| bool utility::SystemIO::loadDirectory |
( |
const std::filesystem::path & |
directory | ) |
|
|
inline |
Loads assets from a directory.
- Parameters
-
| directory | The filesystem path to the directory containing assets. |
- Returns
- True if the assets were loaded successfully, false otherwise.
Definition at line 74 of file system_io.hpp.
◆ loadDirectory() [2/2]
| virtual bool utility::SystemIO::loadDirectory |
( |
const std::string & |
directory | ) |
|
|
pure virtual |
Loads assets from a directory.
- Parameters
-
| directory | The path to the directory containing the assets. |
- Returns
- True if the assets were loaded successfully, false otherwise.
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.
Implemented in utility::DefaultSystemIO, and utility::DefaultSystemIO.
◆ open() [1/2]
| std::shared_ptr< utility::File > utility::SystemIO::open |
( |
const std::filesystem::path & |
path | ) |
const |
|
inline |
Opens an asset from the manager.
- Parameters
-
| path | The filesystem path to the asset. |
- Returns
- A shared pointer to the File object.
Definition at line 198 of file system_io.hpp.
◆ open() [2/2]
| std::shared_ptr< utility::File > utility::SystemIO::open |
( |
const std::string & |
path | ) |
const |
Opens an asset from the manager.
- Parameters
-
| path | The path to the asset. |
- Returns
- A shared pointer to the File object.
This method retrieves the asset from the _assets map. If the asset does not exist, it returns a nullptr.
Definition at line 39 of file system_io.cpp.
◆ remove() [1/2]
| void utility::SystemIO::remove |
( |
const std::filesystem::path & |
path, |
|
|
bool |
save = true |
|
) |
| |
|
inline |
Removes an asset from the manager.
- Parameters
-
| 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.
◆ remove() [2/2]
| virtual void utility::SystemIO::remove |
( |
const std::string & |
path, |
|
|
bool |
save = true |
|
) |
| |
|
pure virtual |
Removes an asset from the manager.
- Parameters
-
| 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.
Implemented in utility::DefaultSystemIO, and utility::DefaultSystemIO.
◆ save() [1/3]
| bool utility::SystemIO::save |
( |
const std::filesystem::path & |
path | ) |
|
|
inline |
Saves an asset to its original path.
- Parameters
-
| path | The filesystem path to the managed asset. |
- Returns
- True if the asset was saved successfully, false otherwise.
Definition at line 158 of file system_io.hpp.
◆ save() [2/3]
| bool utility::SystemIO::save |
( |
const std::filesystem::path & |
path, |
|
|
const std::filesystem::path & |
newPath |
|
) |
| |
|
inline |
Saves an asset to the disk.
- Parameters
-
| path | The filesystem path to the managed asset. |
| newPath | The target filesystem path where the asset is written. |
- Returns
- True if the asset was saved successfully, false otherwise.
Definition at line 147 of file system_io.hpp.
◆ save() [3/3]
| virtual bool utility::SystemIO::save |
( |
const std::string & |
path, |
|
|
const std::string & |
newPath = "" |
|
) |
| |
|
pure virtual |
Saves an asset to the disk.
- Parameters
-
| path | The path to the asset. |
| newPath | The new path to save the asset to (optional). |
- Returns
- True if the asset was saved successfully, false otherwise.
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.
Implemented in utility::DefaultSystemIO, and utility::DefaultSystemIO.
◆ _assets
| std::map<std::string, std::shared_ptr<utility::File> > utility::SystemIO::_assets |
|
protected |
Map of loaded assets.
Key: asset path. Value: shared pointer to the corresponding File.
Definition at line 210 of file system_io.hpp.
The documentation for this class was generated from the following files: