DotNameLib
Loading...
Searching...
No Matches
AssetManager.hpp
Go to the documentation of this file.
1#pragma once
2
4#include <memory>
5#include <mutex>
6
7namespace dotnamecpp::assets {
8 class AssetManager : public IAssetManager {
9 public:
15 explicit AssetManager(std::filesystem::path assetsPath);
16
24 static std::unique_ptr<IAssetManager> create(const std::filesystem::path &executablePath,
25 const std::string &appName);
26
27 [[nodiscard]]
28 const std::filesystem::path &getAssetsPath() const override;
29
30 [[nodiscard]]
31 std::filesystem::path resolveAsset(const std::filesystem::path &relativePath) const override;
32
33 [[nodiscard]]
34 bool assetExists(const std::filesystem::path &relativePath) const override;
35
36 [[nodiscard]]
37 bool validate() const override;
38
39 private:
40 std::filesystem::path assetsPath_;
41 mutable std::mutex mutex_;
42 static std::filesystem::path findAssetsPath(const std::filesystem::path &executablePath,
43 const std::string &appName);
44 };
45
46} // namespace dotnamecpp::assets
bool assetExists(const std::filesystem::path &relativePath) const override
Check if an asset exists given its relative path.
Definition AssetManager.cpp:26
bool validate() const override
Validate the asset manager configuration.
Definition AssetManager.cpp:31
std::filesystem::path resolveAsset(const std::filesystem::path &relativePath) const override
Resolve the full path of an asset given its relative path.
Definition AssetManager.cpp:21
const std::filesystem::path & getAssetsPath() const override
Get the Assets Path object.
Definition AssetManager.cpp:15
AssetManager(std::filesystem::path assetsPath)
Construct a new Asset Manager object.
Definition AssetManager.cpp:6
static std::unique_ptr< IAssetManager > create(const std::filesystem::path &executablePath, const std::string &appName)
Create a new Asset Manager instance.
Definition AssetManager.cpp:9
Definition IAssetManager.hpp:6
Definition AssetManager.cpp:4