15 void* ret= dlsym(
m_lib, symbol_name.c_str());
21 return nullptr !=
raw(symbol_name);
35 Plugin* plugin =
get(plugin_name);
37 l->debug(
"already have plugin {}", plugin_name);
42 for (
int ind=0; ind<2; ++ind) {
53 void* lib = dlopen(lname.c_str(), RTLD_NOW);
55 l->error(
"Failed to load {}: {}", lname, dlerror());
59 m_plugins[plugin_name] =
new Plugin(lib);
60 l->debug(
"loaded plugin #{} \"{}\" from library \"{}\": {}",
61 m_plugins.size(), plugin_name, lname,
62 (
void*)m_plugins[plugin_name]);
63 return m_plugins[plugin_name];
66 l->critical(
"no such plugin: \"{}\"", plugin_name);
73 auto pit = m_plugins.find(plugin_name);
74 if (pit == m_plugins.end()) {
82 for (
auto pit : m_plugins) {
83 Plugin* maybe = pit.second;
Thrown when an error involving accessing input or output has occurred.
bool contains(const std::string &symbol_name)
boost::error_info< struct tag_errmsg, std::string > errmsg
static PluginManager & instance()
Plugin * get(const std::string &plugin_name)
Plugin * find(const std::string &symbol_name)
std::map< std::string, Plugin * > m_plugins
logptr_t logger(std::string name)
Plugin * add(const std::string &plugin_name, const std::string &libname="")
Add a plugin. If libname is not given, try to derive it.
void * raw(const std::string &symbol_name)