141 const std::string & base_package,
const std::string & base_class,
161 const std::string & base_package,
const std::string & base_class,
const std::set<std::string> & exclude_packages,
162 const std::map<std::string, std::string> & reserved_names)
164 std::map<std::string, std::vector<std::string>> packages_for_class_name;
165 const std::set<std::string> packages =
167 for (
const auto & package : packages) {
168 auto single_package_loader =
169 pluginlib::ClassLoader<BaseT>(base_package, base_class,
"", {
getPluginXMLPath(package)});
170 for (
const auto & class_name : single_package_loader.getDeclaredClasses()) {
171 packages_for_class_name[class_name].push_back(package);
176 for (
const auto & [class_name, package] : reserved_names) {
177 packages_for_class_name[class_name].push_back(package +
"(Build package)");
181 std::vector<std::string> error_details;
182 for (
const auto & [class_name, packages] : packages_for_class_name) {
183 if (packages.size() > 1) {
184 error_details.push_back(
185 "- Class '" + class_name +
"' found in packages ['" + auto_apms_util::join(packages,
"', '") +
"'].");
188 if (!error_details.empty()) {
189 throw exceptions::ResourceError(
190 "Ambiguous class names found! PluginClassLoader (Base: '" + base_class +
191 "') created with makeUnambiguousPluginClassLoader() won't register resources from packages "
192 "that use already existing lookup names. Found the following duplicates:\n" +
193 auto_apms_util::join(error_details,
"\n"));
195 return {base_package, base_class, exclude_packages};