12 using ResourceType = ResourceType_t;
13 using ResourceLocation = ResourceLocation_t;
14 using ResourceHandle = ResourceType;
20 ResourceType& operator[](
const ResourceLocation& loc) {
return mContainer[loc]; }
22 ResourceType& addResource(
const ResourceLocation& loc, ResourceType res) {
23 auto [it, inserted] = mContainer.try_emplace(loc, std::move(res));
24 if (!inserted) it->second = std::move(res);
28 void clear() { mContainer.clear(); }
30 ResourceHandle getResource(
const ResourceLocation& loc)
const {
31 auto it = mContainer.find(loc);
32 if (it == mContainer.end())
return nullptr;
36 bool removeResource(
const ResourceLocation& loc) {
return mContainer.erase(loc) > 0; }
38 bool extract(
const ResourceLocation& loc, ResourceType& out) {
39 auto it = mContainer.find(loc);
40 if (it == mContainer.end())
return false;
41 out = std::move(it->second);