20 #include <QApplication> 50 void *handle = dlopen(library.toStdString().c_str(),RTLD_GLOBAL|RTLD_NOW);
54 std::string plugin_dir = std::string(EXEC_PREFIX) + std::string(
"/lib/rtxi/");
55 handle = dlopen((plugin_dir+library.toStdString()).c_str(),RTLD_GLOBAL|RTLD_NOW);
59 ERROR_MSG(
"Plugin::load : failed to load %s: %s\n",library.toStdString().c_str(),dlerror());
68 Object *(*create)(void) = (
Object *(*)(void))(dlsym(handle,
"createRTXIPlugin"));
71 ERROR_MSG(
"Plugin::load : failed to load %s : %s\n",library.toStdString().c_str(),dlerror());
79 ERROR_MSG(
"Plugin::load : failed to load %s : failed to create instance\n",library.toStdString().c_str());
83 if (plugin->magic_number != Plugin::Object::MAGIC_NUMBER)
85 ERROR_MSG(
"Plugin::load : the pointer returned from %s::createRTXIPlugin() isn't a valid Plugin::Object *.\n",library.toStdString().c_str());
90 plugin->handle = handle;
91 plugin->library = library.toStdString();
94 event.setParam(
"plugin",plugin);
104 ERROR_MSG(
"Plugin::Manager::unload : invalid plugin\n");
113 event->data =
reinterpret_cast<void *
>(plugin);
114 QApplication::postEvent(
this,
reinterpret_cast<QEvent *
>(event));
120 for (std::list<Object *>::iterator i = pluginList.begin(); i != pluginList.end(); i = pluginList.begin())
123 event.setParam(
"plugin",*i);
126 handle = (*i)->handle;
135 for (std::list<Plugin::Object *>::iterator i = pluginList.begin(); i != pluginList.end(); ++i)
143 ERROR_MSG(
"Plugin::Manager::insertPlugin : invalid plugin\n");
148 pluginList.push_back(plugin);
155 ERROR_MSG(
"Plugin::Manager::removePlugin : invalid plugin\n");
161 pluginList.remove(plugin);
166 if (e->type() == CloseEvent)
175 event.setParam(
"plugin",plugin);
178 void *handle = plugin->handle;