project-kyoku/include/core/resourceholder.h

52 lines
649 B
C
Raw Normal View History

2021-12-29 09:59:18 -05:00
#pragma once
#include <map>
#include <memory>
2021-12-29 09:59:18 -05:00
namespace kku
{
template <typename Resource, typename Id> class ResourceHolder
2021-12-29 09:59:18 -05:00
{
public:
inline void load(Id id, std::unique_ptr<Resource> &&resource) noexcept
2021-12-29 09:59:18 -05:00
{
_resources[id] = std::move(resource);
}
inline std::shared_ptr<Resource> get(Id id) const
2021-12-29 09:59:18 -05:00
{
return _resources.find(id)->second;
}
private:
2021-12-29 09:59:18 -05:00
std::map<Id, std::shared_ptr<Resource>> _resources;
};
namespace Font
{
enum class Id
{
GUI
};
2021-12-29 09:59:18 -05:00
}
namespace Texture
{
enum class Id
{
GUI
};
}
namespace GUISprite
{
enum class Id
{
SFML_LOGO,
CRYPTOPP_LOGO
};
}
} // namespace kku