![]() |
AutoAPMS
Resilient Robot Mission Management
|
Class for loading plugin resources registered according to the conventions defined by the pluginlib package. More...
#include <auto_apms_util/resource.hpp>
Public Member Functions | |
PluginClassLoader (const std::string &base_package, const std::string &base_class, const std::set< std::string > &exclude_packages={}) | |
Standard PluginClassLoader constructor. | |
std::map< std::string, std::string > | getClassPackageMap () |
Retrieve a map that contains information about which package a plugin class belongs to. | |
Static Public Member Functions | |
static PluginClassLoader | makeUnambiguousPluginClassLoader (const std::string &base_package, const std::string &base_class, const std::set< std::string > &exclude_packages={}, const std::map< std::string, std::string > &reserved_names={}) |
Parse all associated plugin manifest files registered with the ament resource index and instantiate a PluginClassLoader. | |
Class for loading plugin resources registered according to the conventions defined by the pluginlib package.
BaseT | Base class of the plugin. |
For a class to be discoverable, you must call the C++ macro PLUGINLIB_EXPORT_CLASS
and provide the arguments according to your definitions. AutoAPMS provides convenient wrappers that encapsulate this macro.
You must also make sure, that you create a plugins.xml file, add the corresponding entries and export it in the CMakeLists.txt of your ROS 2 package. Again, AutoAPMS provides convenient wrapper macros for specific use cases.
If you did all the above and want to instantiate a plugin class, you must call e.g. createSharedInstance and provide a lookup name for the plugin formatted like this:
<namespace>::<class_name>
Token Name | Description |
---|---|
<namespace> | Full C++ namespace that the class <class_name> can be found in. It can be flat foo or arbitrarily nested foo::bar (individual levels must be separated by :: ). |
<class_name> | Name you specified when declaring the plugin class using the class keyword in C++. If the class takes template arguments, you must provide it using the MyClass<T> syntax as you would in the source code. |
Definition at line 115 of file resource.hpp.
|
inline |
Standard PluginClassLoader constructor.
Alternatively, if you want to verify that only unique class names are loaded, have a look at PluginClassLoader::makeUnambiguousPluginClassLoader.
base_package | Name of the package containing the base_class . Will throw an error if it is not installed. |
base_class | Fully qualified name of the base class that the class loader will use for determining which classes listed in a plugins.xml file are associated with this instance. |
exclude_packages | Packages to exclude when searching for plugins. |
ament_index_cpp::PackageNotFoundError | if base_package is not installed. |
auto_apms_util::exceptions::ResourceError | if no plugins of type base_class were found. |
Definition at line 176 of file resource.hpp.
|
inlinestatic |
Parse all associated plugin manifest files registered with the ament resource index and instantiate a PluginClassLoader.
This factory method additionally performs an ambiguity check. This means that it verifies that only unique class names are being registered by the searched packages. Using the standard constructor, previously registered classes are being overriden if the same class name is being parsed again. Therefore, this method offers the preferred way of instantiating a PluginClassLoader.
LoaderT | Type of the plugin class loader. |
base_package | Name of the package containing the base_class . Will throw an error if it is not installed. |
base_class | Fully qualified name of the base class that the class loader will use for determining which classes listed in a plugins.xml file are associated with this instance. |
exclude_packages | Packages to exclude when searching for plugins. |
reserved_names | Map of reserved class names and the package name that makes the reservation. If any of these class names are found, an error is being raised (Used internally during build time when installed resources aren't available yet). |
ament_index_cpp::PackageNotFoundError | if base_package is not installed. |
auto_apms_util::exceptions::ResourceError | if no plugins of type base_class were found. |
auto_apms_util::exceptions::ResourceError | if multiple packages register a resource using the same class name (or a name in reserved_names is found). |
Definition at line 183 of file resource.hpp.
|
inline |
Retrieve a map that contains information about which package a plugin class belongs to.
Definition at line 222 of file resource.hpp.