forked from NaiJi/project-kyoku
35 lines
523 B
C++
35 lines
523 B
C++
#pragma once
|
|
|
|
#include <memory>
|
|
#include <map>
|
|
|
|
namespace kku
|
|
{
|
|
|
|
template <typename Resource, typename Id>
|
|
class ResourceHolder
|
|
{
|
|
public:
|
|
inline void load(Id id, std::unique_ptr<Resource>&& resource) noexcept
|
|
{
|
|
_resources[id] = std::move(resource);
|
|
}
|
|
|
|
inline const std::shared_ptr<Resource>& get(Id id) const
|
|
{
|
|
return _resources.find(id)->second;
|
|
}
|
|
|
|
private:
|
|
std::map<Id, std::shared_ptr<Resource>> _resources;
|
|
};
|
|
|
|
namespace Font
|
|
{
|
|
enum class Id
|
|
{
|
|
GUI
|
|
};
|
|
}
|
|
|
|
} |