8std::unordered_map<std::string, ResourceTypeDef>& ResourceTypeRegistry::types() {
9 static std::unordered_map<std::string, ResourceTypeDef> s_types;
14 if (def.
id.empty())
return false;
15 types()[def.
id] = def;
21 auto it =
all.find(
id);
22 return it ==
all.end() ? nullptr : &it->second;
28 if (
index < 0)
return nullptr;
29 std::vector<const std::string*>
ids;
31 for (
const auto& entry : types())
ids.push_back(&entry.first);
32 if (
index >=
static_cast<int>(
ids.size()))
return nullptr;
33 std::sort(
ids.begin(),
ids.end(), [](
const std::string*
left,
const std::string*
right) { return *left < *right; });
static void clear()
清空注册表(测试用)。
static const ResourceTypeDef * find(const std::string &id)
按 id 查询;未注册时返回 nullptr。
static int count()
已注册类型数量。
static bool registerType(const ResourceTypeDef &def)
注册或替换一个资源类型定义。
static const ResourceTypeDef * typeAt(int index)
按 id 字典序返回第 index 个类型定义。