29 #ifndef PLUGINLIB_FACTORY_H
30 #define PLUGINLIB_FACTORY_H
34 #include <QStringList>
60 Type* (*factory_function_)();
78 for (
size_t i = 0; i < std_ids.size(); i++)
80 ids.push_back(QString::fromStdString(std_ids[i]));
82 typename QHash<QString, BuiltInClassRecord>::const_iterator iter;
85 ids.push_back(iter.key());
92 typename QHash<QString, BuiltInClassRecord>::const_iterator iter =
built_ins_.find(class_id);
95 return iter->description_;
102 typename QHash<QString, BuiltInClassRecord>::const_iterator iter =
built_ins_.find(class_id);
112 typename QHash<QString, BuiltInClassRecord>::const_iterator iter =
built_ins_.find(class_id);
115 return iter->package_;
122 typename QHash<QString, BuiltInClassRecord>::const_iterator iter =
built_ins_.find(class_id);
130 QIcon
getIcon(
const QString& class_id)
const override
132 QString
package = getClassPackage(class_id);
134 QIcon icon =
loadPixmap(
"package://" +
package +
"/icons/classes/" + class_name +
".svg");
137 icon =
loadPixmap(
"package://" +
package +
"/icons/classes/" + class_name +
".png");
140 icon =
loadPixmap(
"package://rviz/icons/default_class_icon.png");
148 const QString& description,
149 Type* (*factory_function)())
151 BuiltInClassRecord record;
152 record.class_id_ =
package + "/" + name;
156 record.factory_function_ = factory_function;
173 Type*
makeRaw(
const QString& class_id, QString* error_return =
nullptr)
override
175 typename QHash<QString, BuiltInClassRecord>::const_iterator iter =
built_ins_.find(class_id);
178 Type* instance = iter->factory_function_();
179 if (instance ==
nullptr && error_return !=
nullptr)
181 *error_return =
"Factory function for built-in class '" + class_id +
"' returned NULL.";
191 ROS_ERROR(
"PluginlibFactory: The plugin for class '%s' failed to load. Error: %s",
192 qPrintable(class_id), ex.what());
195 *error_return = QString::fromStdString(ex.what());
208 #endif // PLUGINLIB_FACTORY_H