| 47 | #include <cstdlib> |
| 48 | |
| 49 | int main(int argc, char** argv) |
| 50 | { |
| 51 | QApplication app(argc, argv); |
| 52 | |
| 53 | qApp->setOrganizationName("CTK"); |
| 54 | qApp->setOrganizationDomain("commontk.org"); |
| 55 | qApp->setApplicationName("ctkExampleHost"); |
| 56 | |
| 57 | ctkPluginFrameworkFactory fwFactory; |
| 58 | QSharedPointer<ctkPluginFramework> framework = fwFactory.getFramework(); |
| 59 | |
| 60 | try |
| 61 | { |
| 62 | framework->init(); |
| 63 | } |
| 64 | catch (const ctkPluginException& exc) |
| 65 | { |
| 66 | qCritical() << "Failed to initialize the plug-in framework:" << exc; |
| 67 | return EXIT_FAILURE; |
| 68 | } |
| 69 | |
| 70 | #ifdef CMAKE_INTDIR |
| 71 | QString pluginPath = CTK_PLUGIN_DIR CMAKE_INTDIR "/"; |
| 72 | #else |
| 73 | QString pluginPath = CTK_PLUGIN_DIR; |
| 74 | #endif |
| 75 | |
| 76 | qApp->addLibraryPath(pluginPath); |
| 77 | |
| 78 | QStringList libFilter; |
| 79 | libFilter << "*.dll" << "*.so" << "*.dylib"; |
| 80 | QDirIterator dirIter(pluginPath, libFilter, QDir::Files); |
| 81 | |
| 82 | QStringList pluginsToInstall; |
| 83 | pluginsToInstall << "org_commontk_dah_core." << "org_commontk_dah_host." |
| 84 | << "org_commontk_dah_examplehost."; |
| 85 | |
| 86 | QList<QSharedPointer<ctkPlugin> > installedPlugins; |
| 87 | while(dirIter.hasNext()) |
| 88 | { |
| 89 | try |
| 90 | { |
| 91 | QString fileLocation = dirIter.next(); |
| 92 | foreach(QString pluginToInstall, pluginsToInstall) |
| 93 | { |
| 94 | if (fileLocation.contains(pluginToInstall)) |
| 95 | { |
| 96 | QSharedPointer<ctkPlugin> plugin = framework->getPluginContext()->installPlugin(QUrl::fromLocalFile(fileLocation)); |
| 97 | installedPlugins << plugin; |
| 98 | break; |
| 99 | } |
| 100 | } |
| 101 | } |
| 102 | catch (const ctkPluginException& e) |
| 103 | { |
| 104 | qCritical() << e.what(); |
| 105 | } |
| 106 | } |
nothing calls this directly
no test coverage detected