3 #ifndef ROBOWFLEX_IO_PLUGIN_
4 #define ROBOWFLEX_IO_PLUGIN_
10 #include <ros/package.h>
15 #include <pluginlib/class_loader.hpp>
60 if (ros::package::getPath(package).empty())
62 RBX_ERROR(
"Package `%s` does not exist.", package);
66 auto loader = getLoader<T>(package);
73 catch (pluginlib::LibraryLoadException &e)
75 RBX_ERROR(
"Failed to library: %s", e.what());
85 using Loader = pluginlib::ClassLoader<T>;
114 template <
typename T>
127 loader = std::dynamic_pointer_cast<Loader<T>>(cached->second);
130 RBX_INFO(
"Creating Class Loader for type `%s` from package `%s`!", type, package);
132 loader.
reset(
new pluginlib::ClassLoader<T>(package, type));
133 loaders_[key] = std::static_pointer_cast<BaseLoader>(loader);
A singleton class for dynamic loading classes through pluginlib.
PluginManager(PluginManager const &)=delete
static std::shared_ptr< T > load(const std::string &package, const std::string &plugin)
Load a plugin named plugin of type T using the singleton instance.
std::map< std::pair< std::string, std::string >, BaseLoaderPtr > loaders_
Cached loaders.
PluginManager()
Constructor.
pluginlib::ClassLoader< T > Loader
A typed class loader.
std::shared_ptr< T > loadPlugin(const std::string &package, const std::string &plugin)
Load a plugin named plugin of type T.
std::mutex mutex_
Class loading mutex.
LoaderPtr< T > getLoader(const std::string &package)
Gets the plugin loader for a plugin type T. Grabs the loader from cached loaders if available,...
static PluginManager & getInstance()
Get the singleton instance of PluginManager.
void operator=(PluginManager const &)=delete
pluginlib::ClassLoaderBase BaseLoader
The base class of the class loader.
#define RBX_ERROR(fmt,...)
Output a error logging message.
#define RBX_INFO(fmt,...)
Output a info logging message.
#define ROBOWFLEX_DEMANGLE(x)
Main namespace. Contains all library classes and functions.