int ScriptManager::RegisterScript(const Tag &tag, IScript *script) { if (!script) { LogError("ScriptManager::RegisterScript: Script parameter cannot be null"); return InvalidId; } if (tag.IsEmpty()) { LogError("ScriptManager::RegisterScript: Tag parameter cannot be null"); return InvalidId; } int id = scripts.size(); scripts.push_back(script); tags[tag] = id; return id; }
std::vector<int> ScriptManager::ScriptIdsForTag(const Tag &tag) const { std::vector<int> ids; if (tag.IsEmpty()) { LogError("ScriptIdsForTag(const Tag&): Empty tag as parameter."); return ids; } QMapIterator<Tag, int> it(tags); while(it.hasNext()) { it.next(); if (!it.key().IsEmpty() && (it.key().Type() == tag.Type() || it.key().Data() == tag.Data())) ids.push_back(it.value()); } return ids; }