├── .DS_Store ├── Client1 ├── .DS_Store ├── Client1.pro ├── MANIFEST.MF ├── client1.qrc ├── client1activator.cpp ├── client1activator.h ├── client1dlg.cpp ├── client1dlg.h ├── client1dlg.ui ├── client1plugin.cpp └── client1plugin.h ├── MainWindow ├── .DS_Store ├── MANIFEST.MF ├── MainWindow.pro ├── mainwindow.qrc ├── mainwindowactivator.cpp ├── mainwindowactivator.h ├── mainwindowdlg.cpp ├── mainwindowdlg.h ├── mainwindowdlg.ui ├── mainwindowplugin.cpp └── mainwindowplugin.h ├── console ├── console.pro └── main.cpp ├── ctkExample.pro ├── includes ├── .DS_Store ├── core │ ├── .DS_Store │ ├── ctkAbstractFactory.h │ ├── ctkAbstractFileBasedFactory.h │ ├── ctkAbstractLibraryFactory.h │ ├── ctkAbstractObjectFactory.h │ ├── ctkAbstractPluginFactory.h │ ├── ctkAbstractQObjectFactory.h │ ├── ctkBackTrace.h │ ├── ctkBinaryFileDescriptor.h │ ├── ctkBooleanMapper.h │ ├── ctkCallback.h │ ├── ctkCommandLineParser.h │ ├── ctkCompilerDetections_p.h │ ├── ctkCoreExport.h │ ├── ctkCorePythonQtDecorators.h │ ├── ctkCoreTestingMacros.h │ ├── ctkCoreTestingUtilities.h │ ├── ctkDependencyGraph.h │ ├── ctkErrorLogAbstractMessageHandler.h │ ├── ctkErrorLogContext.h │ ├── ctkErrorLogFDMessageHandler.h │ ├── ctkErrorLogFDMessageHandler_p.h │ ├── ctkErrorLogLevel.h │ ├── ctkErrorLogQtMessageHandler.h │ ├── ctkErrorLogStreamMessageHandler.h │ ├── ctkErrorLogTerminalOutput.h │ ├── ctkException.h │ ├── ctkFileLogger.h │ ├── ctkHighPrecisionTimer.h │ ├── ctkLinearValueProxy.h │ ├── ctkLogger.h │ ├── ctkModelTester.h │ ├── ctkPimpl.h │ ├── ctkScopedCurrentDir.h │ ├── ctkSetName.h │ ├── ctkSingleton.h │ ├── ctkUtils.h │ ├── ctkValueProxy.h │ ├── ctkWorkflow.h │ ├── ctkWorkflowStep.h │ ├── ctkWorkflowStep_p.h │ ├── ctkWorkflowTransitions.h │ └── ctkWorkflow_p.h ├── imainwindow.h └── pluginFramework │ ├── .DS_Store │ ├── ctkApplicationRunnable.cpp │ ├── ctkApplicationRunnable.h │ ├── ctkBasicLocation.cpp │ ├── ctkBasicLocation_p.h │ ├── ctkDefaultApplicationLauncher.cpp │ ├── ctkDefaultApplicationLauncher_p.h │ ├── ctkDictionary.h │ ├── ctkLDAPExpr.cpp │ ├── ctkLDAPExpr_p.h │ ├── ctkLDAPSearchFilter.cpp │ ├── ctkLDAPSearchFilter.h │ ├── ctkLocationManager.cpp │ ├── ctkLocationManager_p.h │ ├── ctkPlugin.cpp │ ├── ctkPlugin.h │ ├── ctkPluginAbstractTracked.tpp │ ├── ctkPluginAbstractTracked_p.h │ ├── ctkPluginActivator.h │ ├── ctkPluginArchive.cpp │ ├── ctkPluginArchiveSQL.cpp │ ├── ctkPluginArchiveSQL_p.h │ ├── ctkPluginArchive_p.h │ ├── ctkPluginConstants.cpp │ ├── ctkPluginConstants.h │ ├── ctkPluginContext.cpp │ ├── ctkPluginContext.h │ ├── ctkPluginContext_p.h │ ├── ctkPluginDatabaseException.cpp │ ├── ctkPluginDatabaseException.h │ ├── ctkPluginEvent.cpp │ ├── ctkPluginEvent.h │ ├── ctkPluginException.cpp │ ├── ctkPluginException.h │ ├── ctkPluginFramework.cpp │ ├── ctkPluginFramework.h │ ├── ctkPluginFrameworkContext.cpp │ ├── ctkPluginFrameworkContext_p.h │ ├── ctkPluginFrameworkDebug.cpp │ ├── ctkPluginFrameworkDebugOptions.cpp │ ├── ctkPluginFrameworkDebugOptions_p.h │ ├── ctkPluginFrameworkDebug_p.h │ ├── ctkPluginFrameworkEvent.cpp │ ├── ctkPluginFrameworkEvent.h │ ├── ctkPluginFrameworkExport.h │ ├── ctkPluginFrameworkFactory.cpp │ ├── ctkPluginFrameworkFactory.h │ ├── ctkPluginFrameworkLauncher.cpp │ ├── ctkPluginFrameworkLauncher.h │ ├── ctkPluginFrameworkListeners.cpp │ ├── ctkPluginFrameworkListeners_p.h │ ├── ctkPluginFrameworkProperties.cpp │ ├── ctkPluginFrameworkProperties_p.h │ ├── ctkPluginFrameworkUtil.cpp │ ├── ctkPluginFrameworkUtil_p.h │ ├── ctkPluginFramework_global.h │ ├── ctkPluginFramework_p.cpp │ ├── ctkPluginFramework_p.h │ ├── ctkPluginLocalization.cpp │ ├── ctkPluginLocalization.h │ ├── ctkPluginManifest.cpp │ ├── ctkPluginManifest_p.h │ ├── ctkPluginStorageSQL.cpp │ ├── ctkPluginStorageSQL_p.h │ ├── ctkPluginStorage_p.h │ ├── ctkPluginTracker.h │ ├── ctkPluginTracker.tpp │ ├── ctkPluginTrackerCustomizer.h │ ├── ctkPluginTracker_p.h │ ├── ctkPluginTracker_p.tpp │ ├── ctkPlugin_p.cpp │ ├── ctkPlugin_p.h │ ├── ctkPlugins.cpp │ ├── ctkPlugins_p.h │ ├── ctkRequirePlugin.cpp │ ├── ctkRequirePlugin_p.h │ ├── ctkServiceEvent.cpp │ ├── ctkServiceEvent.h │ ├── ctkServiceException.cpp │ ├── ctkServiceException.h │ ├── ctkServiceFactory.h │ ├── ctkServiceProperties.cpp │ ├── ctkServiceProperties_p.h │ ├── ctkServiceReference.cpp │ ├── ctkServiceReference.h │ ├── ctkServiceReference_p.cpp │ ├── ctkServiceReference_p.h │ ├── ctkServiceRegistration.cpp │ ├── ctkServiceRegistration.h │ ├── ctkServiceRegistration_p.cpp │ ├── ctkServiceRegistration_p.h │ ├── ctkServiceSlotEntry.cpp │ ├── ctkServiceSlotEntry_p.h │ ├── ctkServiceTracker.h │ ├── ctkServiceTracker.tpp │ ├── ctkServiceTrackerCustomizer.h │ ├── ctkServiceTracker_p.h │ ├── ctkServiceTracker_p.tpp │ ├── ctkServices.cpp │ ├── ctkServices_p.h │ ├── ctkTrackedPlugin.tpp │ ├── ctkTrackedPluginListener_p.h │ ├── ctkTrackedPlugin_p.h │ ├── ctkTrackedService.tpp │ ├── ctkTrackedServiceListener_p.h │ ├── ctkTrackedService_p.h │ ├── ctkVersion.cpp │ ├── ctkVersion.h │ ├── ctkVersionRange.cpp │ ├── ctkVersionRange_p.h │ └── service │ ├── application │ ├── ctkApplicationDescriptor.cpp │ ├── ctkApplicationDescriptor.h │ ├── ctkApplicationException.cpp │ ├── ctkApplicationException.h │ ├── ctkApplicationHandle.cpp │ ├── ctkApplicationHandle.h │ └── ctkApplicationLauncher.h │ ├── cm │ ├── ctkConfiguration.cpp │ ├── ctkConfiguration.h │ ├── ctkConfigurationAdmin.cpp │ ├── ctkConfigurationAdmin.h │ ├── ctkConfigurationEvent.cpp │ ├── ctkConfigurationEvent.h │ ├── ctkConfigurationException.cpp │ ├── ctkConfigurationException.h │ ├── ctkConfigurationListener.h │ ├── ctkConfigurationPlugin.cpp │ ├── ctkConfigurationPlugin.h │ ├── ctkManagedService.h │ └── ctkManagedServiceFactory.h │ ├── datalocation │ ├── ctkLocation.cpp │ └── ctkLocation.h │ ├── debug │ ├── ctkDebugOptions.cpp │ ├── ctkDebugOptions.h │ └── ctkDebugOptionsListener.h │ ├── event │ ├── ctkEvent.cpp │ ├── ctkEvent.h │ ├── ctkEventAdmin.h │ ├── ctkEventConstants.cpp │ ├── ctkEventConstants.h │ └── ctkEventHandler.h │ ├── log │ ├── ctkLogEntry.h │ ├── ctkLogListener.h │ ├── ctkLogReaderService.h │ ├── ctkLogService.cpp │ ├── ctkLogService.h │ ├── ctkLogStream.cpp │ └── ctkLogStream.h │ └── metatype │ ├── ctkAttributeDefinition.cpp │ ├── ctkAttributeDefinition.h │ ├── ctkMetaTypeInformation.h │ ├── ctkMetaTypeProvider.cpp │ ├── ctkMetaTypeProvider.h │ ├── ctkMetaTypeService.cpp │ ├── ctkMetaTypeService.h │ └── ctkObjectClassDefinition.h └── libs ├── .DS_Store ├── libCTKCore.0.1.0.dylib ├── libCTKCore.0.1.dylib ├── libCTKCore.dylib ├── libCTKPluginFramework.0.1.0.dylib ├── libCTKPluginFramework.0.1.dylib ├── libCTKPluginFramework.dylib └── liborg_commontk_eventadmin.dylib /.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Iyme/ctkExample/3e99e30049d0b2055fa3a9625ca7efbff273a94b/.DS_Store -------------------------------------------------------------------------------- /Client1/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Iyme/ctkExample/3e99e30049d0b2055fa3a9625ca7efbff273a94b/Client1/.DS_Store -------------------------------------------------------------------------------- /Client1/Client1.pro: -------------------------------------------------------------------------------- 1 | TEMPLATE = lib 2 | TARGET = Client1 3 | DESTDIR = $$PWD/../bin/plugins/$$TARGET 4 | QT += core gui 5 | greaterThan(QT_MAJOR_VERSION, 4): QT += widgets 6 | 7 | #加载ctk库 8 | macx: LIBS += -L$$PWD/../libs/ -lCTKCore.0.1.0 9 | macx: LIBS += -L$$PWD/../libs/ -lCTKPluginFramework.0.1.0 10 | 11 | INCLUDEPATH += $$PWD/../inclues \ 12 | += $$PWD/../includes/core \ 13 | += $$PWD/../includes/pluginFramework 14 | 15 | INCLUDEPATH += $$PWD/../libs 16 | DEPENDPATH += $$PWD/../libs 17 | 18 | HEADERS += \ 19 | client1activator.h \ 20 | client1plugin.h \ 21 | client1dlg.h 22 | 23 | SOURCES += \ 24 | client1activator.cpp \ 25 | client1plugin.cpp \ 26 | client1dlg.cpp 27 | 28 | RESOURCES += \ 29 | client1.qrc 30 | 31 | FORMS += \ 32 | client1dlg.ui 33 | -------------------------------------------------------------------------------- /Client1/MANIFEST.MF: -------------------------------------------------------------------------------- 1 | Plugin-SymbolicName:Client1 2 | Plugin-Version:1.0.0 3 | Require-Plugin:MainWindow 4 | -------------------------------------------------------------------------------- /Client1/client1.qrc: -------------------------------------------------------------------------------- 1 | 2 | 3 | MANIFEST.MF 4 | 5 | 6 | -------------------------------------------------------------------------------- /Client1/client1activator.cpp: -------------------------------------------------------------------------------- 1 | #include "client1activator.h" 2 | #include 3 | Client1Activator::Client1Activator() 4 | :m_plugin(NULL) 5 | { 6 | 7 | } 8 | void Client1Activator::start(ctkPluginContext *context) 9 | { 10 | qDebug() << "client1 start"; 11 | m_plugin = new Client1Plugin(context); 12 | } 13 | void Client1Activator::stop(ctkPluginContext *context) 14 | { 15 | if(m_plugin) 16 | delete(m_plugin); 17 | m_plugin = NULL; 18 | } 19 | -------------------------------------------------------------------------------- /Client1/client1activator.h: -------------------------------------------------------------------------------- 1 | #ifndef CLIENT1ACTIVATOR_H 2 | #define CLIENT1ACTIVATOR_H 3 | #include 4 | #include "ctkPluginActivator.h" 5 | #include "client1plugin.h" 6 | class Client1Activator : public QObject, public ctkPluginActivator 7 | { 8 | Q_OBJECT 9 | Q_PLUGIN_METADATA(IID "Client1") 10 | Q_INTERFACES(ctkPluginActivator) 11 | public: 12 | Client1Activator(); 13 | void start(ctkPluginContext *context); 14 | void stop(ctkPluginContext *context); 15 | private: 16 | Client1Plugin* m_plugin; 17 | }; 18 | 19 | #endif // CLIENT1ACTIVATOR_H 20 | -------------------------------------------------------------------------------- /Client1/client1dlg.cpp: -------------------------------------------------------------------------------- 1 | #include "client1dlg.h" 2 | #include "ui_client1dlg.h" 3 | 4 | Client1Dlg::Client1Dlg(QWidget *parent) : 5 | QDialog(parent), 6 | ui(new Ui::Client1Dlg) 7 | { 8 | ui->setupUi(this); 9 | } 10 | 11 | Client1Dlg::~Client1Dlg() 12 | { 13 | delete ui; 14 | } 15 | -------------------------------------------------------------------------------- /Client1/client1dlg.h: -------------------------------------------------------------------------------- 1 | #ifndef CLIENT1DLG_H 2 | #define CLIENT1DLG_H 3 | 4 | #include 5 | 6 | namespace Ui { 7 | class Client1Dlg; 8 | } 9 | 10 | class Client1Dlg : public QDialog 11 | { 12 | Q_OBJECT 13 | 14 | public: 15 | explicit Client1Dlg(QWidget *parent = 0); 16 | ~Client1Dlg(); 17 | 18 | private: 19 | Ui::Client1Dlg *ui; 20 | }; 21 | 22 | #endif // CLIENT1DLG_H 23 | -------------------------------------------------------------------------------- /Client1/client1dlg.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | Client1Dlg 4 | 5 | 6 | 7 | 0 8 | 0 9 | 400 10 | 300 11 | 12 | 13 | 14 | Dialog 15 | 16 | 17 | 18 | 19 | 20 | 21 | 26 22 | 23 | 24 | 25 | color: rgb(255, 0, 0); 26 | 27 | 28 | 芝麻开门 29 | 30 | 31 | Qt::AlignCenter 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | -------------------------------------------------------------------------------- /Client1/client1plugin.cpp: -------------------------------------------------------------------------------- 1 | #include "client1plugin.h" 2 | #include 3 | 4 | Client1Plugin::Client1Plugin(ctkPluginContext *context) 5 | :m_context(context) 6 | { 7 | m_clientDlg = new Client1Dlg; 8 | connect(this, SIGNAL(openDlg()), this, SLOT(onOpenDlg()),Qt::QueuedConnection); 9 | //注册监听信号"zhimakaimen" 10 | ctkDictionary dic; 11 | dic.insert(ctkEventConstants::EVENT_TOPIC, "zhimakaimen"); 12 | context->registerService(this, dic); 13 | 14 | //注册窗口 15 | registToMainWindow(); 16 | 17 | } 18 | 19 | void Client1Plugin::handleEvent(const ctkEvent& event) 20 | { 21 | //接收监听事件接口 22 | if(event.getTopic() == "zhimakaimen") 23 | { 24 | emit openDlg(); 25 | //这里用了信号槽异步,因为线程中不能调用界面元素 26 | } 27 | 28 | } 29 | void Client1Plugin::onOpenDlg() 30 | { 31 | m_clientDlg->show(); 32 | } 33 | void Client1Plugin::registToMainWindow() 34 | { 35 | ctkServiceReference ref; 36 | ctkEventAdmin* eventAdmin; 37 | 38 | ref = m_context->getServiceReference(); 39 | 40 | if(ref) 41 | { 42 | eventAdmin = m_context->getService(ref); 43 | m_context->ungetService(ref); 44 | } 45 | 46 | ctkDictionary message; 47 | message.insert("id", "00"); 48 | message.insert("name", "用户1"); 49 | message.insert("topic","zhimakaimen"); 50 | if(eventAdmin) 51 | eventAdmin->postEvent(ctkEvent("event/registAction", message)); 52 | 53 | } 54 | -------------------------------------------------------------------------------- /Client1/client1plugin.h: -------------------------------------------------------------------------------- 1 | #ifndef CLIENT1PLUGIN_H 2 | #define CLIENT1PLUGIN_H 3 | #include 4 | #include "ctkPluginContext.h" 5 | #include "service/event/ctkEventAdmin.h" 6 | #include "service/event/ctkEventHandler.h" 7 | #include "client1dlg.h" 8 | class Client1Plugin : public QObject, public ctkEventHandler 9 | { 10 | Q_OBJECT 11 | Q_INTERFACES(ctkEventHandler) 12 | public: 13 | Client1Plugin(ctkPluginContext *context); 14 | 15 | protected: 16 | void handleEvent(const ctkEvent& event); 17 | 18 | signals: 19 | void openDlg(); 20 | 21 | public slots: 22 | void onOpenDlg(); 23 | 24 | private: 25 | void registToMainWindow(); 26 | ctkPluginContext *m_context; 27 | Client1Dlg* m_clientDlg; 28 | }; 29 | 30 | #endif 31 | 32 | -------------------------------------------------------------------------------- /MainWindow/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Iyme/ctkExample/3e99e30049d0b2055fa3a9625ca7efbff273a94b/MainWindow/.DS_Store -------------------------------------------------------------------------------- /MainWindow/MANIFEST.MF: -------------------------------------------------------------------------------- 1 | Plugin-SymbolicName:MainWindow 2 | Plugin-Version:1.0.0 3 | -------------------------------------------------------------------------------- /MainWindow/MainWindow.pro: -------------------------------------------------------------------------------- 1 | TEMPLATE = lib 2 | TARGET = MainWindow 3 | DESTDIR = $$PWD/../bin/plugins/$$TARGET 4 | QT += core gui 5 | greaterThan(QT_MAJOR_VERSION, 4): QT += widgets 6 | 7 | #加载ctk库 8 | macx: LIBS += -L$$PWD/../libs/ -lCTKCore.0.1.0 9 | macx: LIBS += -L$$PWD/../libs/ -lCTKPluginFramework.0.1.0 10 | 11 | INCLUDEPATH += $$PWD/../inclues \ 12 | += $$PWD/../includes/core \ 13 | += $$PWD/../includes/pluginFramework 14 | 15 | INCLUDEPATH += $$PWD/../libs 16 | DEPENDPATH += $$PWD/../libs 17 | 18 | HEADERS += \ 19 | mainwindowactivator.h \ 20 | mainwindowplugin.h \ 21 | ../includes/imainwindow.h \ 22 | mainwindowdlg.h 23 | 24 | SOURCES += \ 25 | mainwindowactivator.cpp \ 26 | mainwindowplugin.cpp \ 27 | mainwindowdlg.cpp 28 | 29 | RESOURCES += \ 30 | mainwindow.qrc 31 | 32 | file.path = $$DESTDIR 33 | file.files = MANIFEST.MF 34 | 35 | INSTALLS += file 36 | 37 | FORMS += \ 38 | mainwindowdlg.ui 39 | -------------------------------------------------------------------------------- /MainWindow/mainwindow.qrc: -------------------------------------------------------------------------------- 1 | 2 | 3 | MANIFEST.MF 4 | 5 | 6 | -------------------------------------------------------------------------------- /MainWindow/mainwindowactivator.cpp: -------------------------------------------------------------------------------- 1 | #include "mainwindowactivator.h" 2 | #include 3 | #include 4 | 5 | MainWindowActivator::MainWindowActivator() 6 | { 7 | 8 | } 9 | void MainWindowActivator::start(ctkPluginContext *context) 10 | { 11 | qDebug() << "mainwindow start"; 12 | m_plugin = new MainWindowPlugin(context); 13 | ctkDictionary dic; 14 | dic.insert(ctkEventConstants::PLUGIN_SYMBOLICNAME, "MainWindow"); 15 | context->registerService(m_plugin, dic); 16 | } 17 | void MainWindowActivator::stop(ctkPluginContext *context) 18 | { 19 | 20 | } 21 | -------------------------------------------------------------------------------- /MainWindow/mainwindowactivator.h: -------------------------------------------------------------------------------- 1 | #ifndef MAINWINDOWACTIVATOR_H 2 | #define MAINWINDOWACTIVATOR_H 3 | #include 4 | #include "ctkPluginActivator.h" 5 | #include "mainwindowplugin.h" 6 | class MainWindowActivator : public QObject, public ctkPluginActivator 7 | { 8 | public: 9 | Q_OBJECT 10 | Q_PLUGIN_METADATA(IID "MainWindow") 11 | Q_INTERFACES(ctkPluginActivator) 12 | 13 | public: 14 | MainWindowActivator(); 15 | 16 | void start(ctkPluginContext *context); 17 | void stop(ctkPluginContext *context); 18 | private: 19 | MainWindowPlugin* m_plugin; 20 | }; 21 | 22 | #endif // MAINWINDOWACTIVATOR_H 23 | -------------------------------------------------------------------------------- /MainWindow/mainwindowdlg.cpp: -------------------------------------------------------------------------------- 1 | #include "mainwindowdlg.h" 2 | #include "ui_mainwindowdlg.h" 3 | #include "service/event/ctkEvent.h" 4 | #include "service/event/ctkEventAdmin.h" 5 | #include "service/event/ctkEventHandler.h" 6 | 7 | MainWindowDlg::MainWindowDlg(ctkPluginContext *context,QWidget *parent) : 8 | QMainWindow(parent), 9 | ui(new Ui::MainWindowDlg), 10 | m_context(context) 11 | { 12 | ui->setupUi(this); 13 | } 14 | 15 | MainWindowDlg::~MainWindowDlg() 16 | { 17 | delete ui; 18 | } 19 | 20 | void MainWindowDlg::registAction(QString id, QString name, QString topic) 21 | { 22 | QAction* action = new QAction(name); 23 | action->setObjectName(id); 24 | action->setStatusTip(topic); 25 | ui->menubar->addAction(action); 26 | 27 | connect(action, SIGNAL(triggered(bool)), this, SLOT(action_clicked())); 28 | } 29 | 30 | void MainWindowDlg::action_clicked() 31 | { 32 | if(QAction* action = dynamic_cast(sender())) 33 | { 34 | //获取事件服务接口 35 | ctkServiceReference ref; 36 | ctkEventAdmin* eventAdmin; 37 | QString topic = action->statusTip(); 38 | 39 | ref = m_context->getServiceReference(); 40 | 41 | if(ref) 42 | { 43 | eventAdmin = m_context->getService(ref); 44 | m_context->ungetService(ref); 45 | } 46 | 47 | //发送事件 48 | ctkDictionary message; 49 | if(eventAdmin) 50 | eventAdmin->postEvent(ctkEvent(topic, message)); 51 | 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /MainWindow/mainwindowdlg.h: -------------------------------------------------------------------------------- 1 | #ifndef MAINWINDOWDLG_H 2 | #define MAINWINDOWDLG_H 3 | 4 | #include 5 | #include "ctkPluginContext.h" 6 | 7 | namespace Ui { 8 | class MainWindowDlg; 9 | } 10 | 11 | class MainWindowDlg : public QMainWindow 12 | { 13 | Q_OBJECT 14 | 15 | public: 16 | explicit MainWindowDlg(ctkPluginContext *context,QWidget *parent = 0); 17 | ~MainWindowDlg(); 18 | void registAction(QString id, QString name, QString topic); 19 | 20 | public slots: 21 | void action_clicked(); 22 | 23 | private: 24 | Ui::MainWindowDlg *ui; 25 | ctkPluginContext *m_context; 26 | }; 27 | 28 | #endif // MAINWINDOWDLG_H 29 | -------------------------------------------------------------------------------- /MainWindow/mainwindowdlg.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | MainWindowDlg 4 | 5 | 6 | 7 | 0 8 | 0 9 | 800 10 | 600 11 | 12 | 13 | 14 | 15 | 0 16 | 30 17 | 18 | 19 | 20 | MainWindow 21 | 22 | 23 | 24 | 25 | 26 | 0 27 | 0 28 | 800 29 | 30 30 | 31 | 32 | 33 | 34 | 0 35 | 30 36 | 37 | 38 | 39 | 40 | 41 | 42 | true 43 | 44 | 45 | false 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | -------------------------------------------------------------------------------- /MainWindow/mainwindowplugin.cpp: -------------------------------------------------------------------------------- 1 | #include "mainwindowplugin.h" 2 | #include 3 | #include 4 | 5 | MainWindowPlugin::MainWindowPlugin(ctkPluginContext *context) 6 | :m_context(context) 7 | { 8 | m_windowDlg = new MainWindowDlg(context); 9 | ctkDictionary dic; 10 | dic.insert(ctkEventConstants::EVENT_TOPIC, "event/registAction"); 11 | context->registerService(this, dic); 12 | connect(this, SIGNAL(registAction(ctkEvent)), this, SLOT(onRegistAction(ctkEvent))); 13 | 14 | } 15 | 16 | void MainWindowPlugin::popMainWindow() 17 | { 18 | m_windowDlg->show(); 19 | } 20 | void MainWindowPlugin::handleEvent(const ctkEvent& event) 21 | { 22 | if(event.getTopic() == "event/registAction") 23 | emit registAction(event); 24 | 25 | } 26 | 27 | void MainWindowPlugin::onRegistAction(const ctkEvent& event) 28 | { 29 | QString name, id, topic; 30 | name = event.getProperty("name").toString(); 31 | id = event.getProperty("id").toString(); 32 | topic = event.getProperty("topic").toString(); 33 | m_windowDlg->registAction(id, name, topic); 34 | } 35 | -------------------------------------------------------------------------------- /MainWindow/mainwindowplugin.h: -------------------------------------------------------------------------------- 1 | #ifndef MAINWINDOWPLUGIN_H 2 | #define MAINWINDOWPLUGIN_H 3 | #include 4 | #include "../includes/imainwindow.h" 5 | #include "ctkPluginContext.h" 6 | #include "mainwindowdlg.h" 7 | #include "service/event/ctkEventHandler.h" 8 | 9 | class MainWindowPlugin : public QObject, public iMainWindow, public ctkEventHandler 10 | { 11 | Q_OBJECT 12 | Q_INTERFACES(iMainWindow ctkEventHandler) 13 | public: 14 | MainWindowPlugin(ctkPluginContext *context); 15 | virtual void popMainWindow(); 16 | signals: 17 | void registAction(const ctkEvent& event); 18 | public slots: 19 | void onRegistAction(const ctkEvent& event); 20 | 21 | protected: 22 | virtual void handleEvent(const ctkEvent& event); 23 | 24 | private: 25 | ctkPluginContext *m_context; 26 | MainWindowDlg* m_windowDlg; 27 | }; 28 | 29 | #endif // MAINWINDOWPLUGIN_H 30 | -------------------------------------------------------------------------------- /console/console.pro: -------------------------------------------------------------------------------- 1 | QT += core gui 2 | greaterThan(QT_MAJOR_VERSION, 4): QT += widgets 3 | 4 | 5 | CONFIG += c++11 console 6 | CONFIG -= app_bundle 7 | 8 | # The following define makes your compiler emit warnings if you use 9 | # any feature of Qt which as been marked deprecated (the exact warnings 10 | # depend on your compiler). Please consult the documentation of the 11 | # deprecated API in order to know how to port your code away from it. 12 | DEFINES += QT_DEPRECATED_WARNINGS 13 | DESTDIR = $$PWD/../bin 14 | # You can also make your code fail to compile if you use deprecated APIs. 15 | # In order to do so, uncomment the following line. 16 | # You can also select to disable deprecated APIs only up to a certain version of Qt. 17 | #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 18 | 19 | 20 | macx: LIBS += -L$$PWD/../libs/ -lCTKCore.0.1.0 21 | macx: LIBS += -L$$PWD/../libs/ -lCTKPluginFramework.0.1.0 22 | 23 | INCLUDEPATH += $$PWD/../inclues \ 24 | += $$PWD/../includes/core \ 25 | += $$PWD/../includes/pluginFramework 26 | 27 | INCLUDEPATH += $$PWD/../libs 28 | DEPENDPATH += $$PWD/../libs 29 | SOURCES += main.cpp 30 | -------------------------------------------------------------------------------- /console/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "ctkPluginFrameworkFactory.h" 4 | #include "ctkPluginFramework.h" 5 | #include "ctkPluginException.h" 6 | #include "ctkPluginContext.h" 7 | #include "ctkPluginFrameworkLauncher.h" 8 | #include 9 | #include 10 | #include 11 | 12 | #include "../includes/imainwindow.h" 13 | 14 | void loadPlugins(QString path, ctkPluginContext* context, QList >* list) 15 | { 16 | QDir dir(path); 17 | if(!dir.exists()) 18 | return; 19 | 20 | QStringList filters; 21 | filters << "*.dylib"; 22 | QDirIterator dir_iterator(path, filters, QDir::Files | QDir::Writable, 23 | QDirIterator::Subdirectories); 24 | 25 | while (dir_iterator.hasNext()) { 26 | dir_iterator.next(); 27 | QFileInfo file = dir_iterator.fileInfo(); 28 | 29 | QString file_path = file.absoluteFilePath(); 30 | if(file_path.contains(".1")) 31 | continue; 32 | 33 | qDebug() << file_path; 34 | 35 | QUrl url = QUrl::fromLocalFile(file_path); 36 | 37 | QSharedPointer plugin; 38 | try 39 | { 40 | plugin = context->installPlugin(url); 41 | }catch(ctkPluginException e){ 42 | qDebug() << e.message() << e.getType(); 43 | return; 44 | } 45 | list->append(plugin); 46 | } 47 | 48 | 49 | } 50 | 51 | int main(int argc, char *argv[]) 52 | { 53 | QApplication a(argc, argv); 54 | 55 | a.setApplicationName("ctkExample");//给框架创建名称,Linux下没有这步会报错 56 | 57 | ctkPluginFrameworkLauncher::addSearchPath("/Users/Shared/qt/ctkExample/libs"); 58 | ctkPluginFrameworkLauncher::start("org.commontk.eventadmin"); 59 | 60 | ctkPluginFrameworkFactory factory;//插件工厂类 61 | QSharedPointer framework; 62 | framework = factory.getFramework(); 63 | 64 | try{ 65 | framework->init(); 66 | framework->start(); 67 | } 68 | catch(const ctkPluginException& e){ 69 | qDebug() << "framework init fail"; 70 | qDebug() << e.message() << e.getType(); 71 | } 72 | 73 | 74 | QString dir = QCoreApplication::applicationDirPath() + "/plugins"; 75 | ctkPluginContext* context = framework->getPluginContext(); 76 | 77 | QList > ctkPluginList; 78 | loadPlugins(dir, context, &ctkPluginList); 79 | 80 | 81 | foreach (QSharedPointer plugin, ctkPluginList) { 82 | try{ 83 | plugin->start(ctkPlugin::START_TRANSIENT); 84 | }catch(ctkPluginException e){ 85 | qDebug() << e.message() << e.getType(); 86 | } 87 | } 88 | 89 | 90 | 91 | ctkServiceReference ref =context->getServiceReference(); 92 | iMainWindow* mainWindow; 93 | if(ref) 94 | mainWindow = context->getService(ref); 95 | 96 | if(mainWindow) 97 | { 98 | mainWindow->popMainWindow(); 99 | context->ungetService(ref); 100 | } 101 | 102 | // ctkPluginFrameworkLauncher::stop("org.commontk.eventadmin"); 103 | 104 | 105 | return a.exec(); 106 | } 107 | -------------------------------------------------------------------------------- /ctkExample.pro: -------------------------------------------------------------------------------- 1 | TEMPLATE = subdirs 2 | 3 | SUBDIRS += \ 4 | console \ 5 | MainWindow \ 6 | Client1 7 | -------------------------------------------------------------------------------- /includes/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Iyme/ctkExample/3e99e30049d0b2055fa3a9625ca7efbff273a94b/includes/.DS_Store -------------------------------------------------------------------------------- /includes/core/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Iyme/ctkExample/3e99e30049d0b2055fa3a9625ca7efbff273a94b/includes/core/.DS_Store -------------------------------------------------------------------------------- /includes/core/ctkAbstractFileBasedFactory.h: -------------------------------------------------------------------------------- 1 | /*========================================================================= 2 | 3 | Library: CTK 4 | 5 | Copyright (c) Kitware Inc. 6 | 7 | Licensed under the Apache License, Version 2.0 (the "License"); 8 | you may not use this file except in compliance with the License. 9 | You may obtain a copy of the License at 10 | 11 | http://www.apache.org/licenses/LICENSE-2.0.txt 12 | 13 | Unless required by applicable law or agreed to in writing, software 14 | distributed under the License is distributed on an "AS IS" BASIS, 15 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | See the License for the specific language governing permissions and 17 | limitations under the License. 18 | 19 | =========================================================================*/ 20 | 21 | #ifndef __ctkAbstractFileBasedFactory_h 22 | #define __ctkAbstractFileBasedFactory_h 23 | 24 | // Qt includes 25 | #include 26 | #include 27 | 28 | // CTK includes 29 | #include "ctkAbstractFactory.h" 30 | 31 | //---------------------------------------------------------------------------- 32 | /// \ingroup Core 33 | template 34 | class ctkAbstractFactoryFileBasedItem 35 | : public ctkAbstractFactoryItem 36 | { 37 | public: 38 | /// Get path associated with the object identified by \a key 39 | void setPath(const QString& path); 40 | QString path()const; 41 | 42 | private: 43 | QString Path; 44 | }; 45 | 46 | //---------------------------------------------------------------------------- 47 | /// \ingroup Core 48 | template 49 | class ctkAbstractFileBasedFactory : public ctkAbstractFactory 50 | { 51 | public: 52 | virtual bool isValidFile(const QFileInfo& file)const; 53 | QString itemKey(const QFileInfo& file)const; 54 | 55 | /// Register the item and return the itemkey on success, otherwise return an 56 | /// empty string. 57 | QString registerFileItem(const QFileInfo& file); 58 | 59 | /// Get path associated with the library identified by \a key 60 | virtual QString path(const QString& key); 61 | 62 | protected: 63 | void registerAllFileItems(const QStringList& directories); 64 | 65 | bool registerFileItem(const QString& key, const QFileInfo& file); 66 | 67 | virtual ctkAbstractFactoryItem* createFactoryFileBasedItem(); 68 | virtual void initItem(ctkAbstractFactoryItem* item); 69 | 70 | virtual QString fileNameToKey(const QString& path)const; 71 | }; 72 | 73 | #include "ctkAbstractFileBasedFactory.tpp" 74 | 75 | #endif 76 | -------------------------------------------------------------------------------- /includes/core/ctkAbstractLibraryFactory.h: -------------------------------------------------------------------------------- 1 | /*========================================================================= 2 | 3 | Library: CTK 4 | 5 | Copyright (c) Kitware Inc. 6 | 7 | Licensed under the Apache License, Version 2.0 (the "License"); 8 | you may not use this file except in compliance with the License. 9 | You may obtain a copy of the License at 10 | 11 | http://www.apache.org/licenses/LICENSE-2.0.txt 12 | 13 | Unless required by applicable law or agreed to in writing, software 14 | distributed under the License is distributed on an "AS IS" BASIS, 15 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | See the License for the specific language governing permissions and 17 | limitations under the License. 18 | 19 | =========================================================================*/ 20 | 21 | #ifndef __ctkAbstractLibraryFactory_h 22 | #define __ctkAbstractLibraryFactory_h 23 | 24 | // Qt includes 25 | #include 26 | #include 27 | #include 28 | 29 | // CTK includes 30 | #include "ctkAbstractFileBasedFactory.h" 31 | 32 | //---------------------------------------------------------------------------- 33 | /// \ingroup Core 34 | template 35 | class ctkFactoryLibraryItem : public ctkAbstractFactoryFileBasedItem 36 | { 37 | 38 | public: 39 | 40 | #if QT_VERSION < 0x50000 41 | typedef void* SymbolAddressType; 42 | #else 43 | typedef QFunctionPointer SymbolAddressType; 44 | #endif 45 | 46 | protected: 47 | typedef typename QHash::const_iterator ConstIterator; 48 | typedef typename QHash::iterator Iterator; 49 | 50 | public: 51 | //explicit ctkFactoryLibraryItem(const QString& path); 52 | 53 | virtual bool load(); 54 | 55 | /// 56 | /// Set list of required symbols 57 | void setSymbols(const QStringList& symbols); 58 | 59 | /// Set lookup hints for symbol resolution. See QLibrary documentation. 60 | void setLoadHints(QLibrary::LoadHints hints); 61 | 62 | /// 63 | /// \brief Resolve symbols 64 | /// \note The function will return False if it fails to resolve one 65 | /// of the required symbols set using setSymbols(const QStringList&) 66 | bool resolve(); 67 | 68 | /// 69 | /// Get symbol address 70 | SymbolAddressType symbolAddress(const QString& symbol)const; 71 | 72 | protected: 73 | mutable QLibrary Library; 74 | QHash ResolvedSymbols; 75 | QStringList Symbols; 76 | }; 77 | 78 | //---------------------------------------------------------------------------- 79 | /// \ingroup Core 80 | template 81 | class ctkAbstractLibraryFactory 82 | : public ctkAbstractFileBasedFactory 83 | { 84 | public: 85 | /// Set the list of symbols 86 | void setSymbols(const QStringList& symbols); 87 | 88 | protected: 89 | virtual bool isValidFile(const QFileInfo& file)const; 90 | virtual void initItem(ctkAbstractFactoryItem* item); 91 | 92 | private: 93 | QStringList Symbols; 94 | }; 95 | 96 | #include "ctkAbstractLibraryFactory.tpp" 97 | 98 | #endif 99 | -------------------------------------------------------------------------------- /includes/core/ctkAbstractObjectFactory.h: -------------------------------------------------------------------------------- 1 | /*========================================================================= 2 | 3 | Library: CTK 4 | 5 | Copyright (c) Kitware Inc. 6 | 7 | Licensed under the Apache License, Version 2.0 (the "License"); 8 | you may not use this file except in compliance with the License. 9 | You may obtain a copy of the License at 10 | 11 | http://www.apache.org/licenses/LICENSE-2.0.txt 12 | 13 | Unless required by applicable law or agreed to in writing, software 14 | distributed under the License is distributed on an "AS IS" BASIS, 15 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | See the License for the specific language governing permissions and 17 | limitations under the License. 18 | 19 | =========================================================================*/ 20 | 21 | #ifndef __ctkAbstractObjectFactory_h 22 | #define __ctkAbstractObjectFactory_h 23 | 24 | // Qt includes 25 | #include 26 | 27 | // CTK includes 28 | #include "ctkAbstractFactory.h" 29 | 30 | //---------------------------------------------------------------------------- 31 | namespace{ 32 | /// \ingroup Core 33 | /// Function in charge of instanciating an object of type: ClassType 34 | template 35 | BaseClassType *instantiateObject() 36 | { 37 | return new ClassType; 38 | } 39 | } 40 | 41 | //---------------------------------------------------------------------------- 42 | /// \ingroup Core 43 | template 44 | class ctkFactoryObjectItem : public ctkAbstractFactoryItem 45 | { 46 | protected: 47 | typedef BaseClassType *(*InstantiateObjectFunc)(); 48 | public: 49 | virtual bool load(); 50 | protected: 51 | virtual BaseClassType* instanciator(); 52 | private: 53 | InstantiateObjectFunc instantiateObjectFunc; 54 | }; 55 | 56 | //---------------------------------------------------------------------------- 57 | /// \ingroup Core 58 | template 59 | class ctkAbstractObjectFactory : public ctkAbstractFactory 60 | { 61 | public: 62 | explicit ctkAbstractObjectFactory(); 63 | 64 | /// Register an object in the factory 65 | template 66 | bool registerObject(const QString& key); 67 | 68 | private: 69 | ctkAbstractObjectFactory(const ctkAbstractObjectFactory &); /// Not implemented 70 | void operator=(const ctkAbstractObjectFactory&); /// Not implemented 71 | }; 72 | 73 | #include "ctkAbstractObjectFactory.tpp" 74 | 75 | #endif 76 | -------------------------------------------------------------------------------- /includes/core/ctkAbstractPluginFactory.h: -------------------------------------------------------------------------------- 1 | /*========================================================================= 2 | 3 | Library: CTK 4 | 5 | Copyright (c) Kitware Inc. 6 | 7 | Licensed under the Apache License, Version 2.0 (the "License"); 8 | you may not use this file except in compliance with the License. 9 | You may obtain a copy of the License at 10 | 11 | http://www.apache.org/licenses/LICENSE-2.0.txt 12 | 13 | Unless required by applicable law or agreed to in writing, software 14 | distributed under the License is distributed on an "AS IS" BASIS, 15 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | See the License for the specific language governing permissions and 17 | limitations under the License. 18 | 19 | =========================================================================*/ 20 | 21 | #ifndef __ctkAbstractPluginFactory_h 22 | #define __ctkAbstractPluginFactory_h 23 | 24 | // Qt includes 25 | #include 26 | #include 27 | 28 | // CTK includes 29 | #include "ctkAbstractFileBasedFactory.h" 30 | 31 | //---------------------------------------------------------------------------- 32 | /// \ingroup Core 33 | template 34 | class ctkFactoryPluginItem : public ctkAbstractFactoryFileBasedItem 35 | { 36 | public: 37 | virtual bool load(); 38 | virtual QString loadErrorString()const; 39 | 40 | protected: 41 | virtual BaseClassType* instanciator(); 42 | 43 | private: 44 | QPluginLoader Loader; 45 | }; 46 | 47 | //---------------------------------------------------------------------------- 48 | /// \ingroup Core 49 | template 50 | class ctkAbstractPluginFactory : public ctkAbstractFileBasedFactory 51 | { 52 | protected: 53 | virtual bool isValidFile(const QFileInfo& file)const; 54 | virtual ctkAbstractFactoryItem* createFactoryFileBasedItem(); 55 | }; 56 | 57 | #include "ctkAbstractPluginFactory.tpp" 58 | 59 | #endif 60 | -------------------------------------------------------------------------------- /includes/core/ctkAbstractQObjectFactory.h: -------------------------------------------------------------------------------- 1 | /*========================================================================= 2 | 3 | Library: CTK 4 | 5 | Copyright (c) Kitware Inc. 6 | 7 | Licensed under the Apache License, Version 2.0 (the "License"); 8 | you may not use this file except in compliance with the License. 9 | You may obtain a copy of the License at 10 | 11 | http://www.apache.org/licenses/LICENSE-2.0.txt 12 | 13 | Unless required by applicable law or agreed to in writing, software 14 | distributed under the License is distributed on an "AS IS" BASIS, 15 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | See the License for the specific language governing permissions and 17 | limitations under the License. 18 | 19 | =========================================================================*/ 20 | 21 | #ifndef __ctkAbstractQObjectFactory_h 22 | #define __ctkAbstractQObjectFactory_h 23 | 24 | // Qt includes 25 | #include 26 | 27 | // CTK includes 28 | #include "ctkAbstractObjectFactory.h" 29 | 30 | //---------------------------------------------------------------------------- 31 | /// \ingroup Core 32 | template 33 | class ctkAbstractQObjectFactory : public ctkAbstractObjectFactory 34 | { 35 | public: 36 | 37 | /// Constructor/Desctructor 38 | explicit ctkAbstractQObjectFactory(); 39 | virtual ~ctkAbstractQObjectFactory(); 40 | 41 | /// \brief Return a name allowing to uniquely identify the QObject 42 | /// By default, it return \a objectName obtained using staticMetaObject.className() 43 | virtual QString objectNameToKey(const QString& objectName); 44 | 45 | /// \brief Register an object in the factory 46 | /// The parameter \a key passed by reference will be updated with the 47 | /// associated object name obtained using objectNameToKey(const QString&) 48 | template 49 | bool registerQObject(QString& key); 50 | 51 | private: 52 | ctkAbstractQObjectFactory(const ctkAbstractQObjectFactory &); /// Not implemented 53 | void operator=(const ctkAbstractQObjectFactory&); /// Not implemented 54 | }; 55 | 56 | #include "ctkAbstractQObjectFactory.tpp" 57 | 58 | #endif 59 | -------------------------------------------------------------------------------- /includes/core/ctkBackTrace.h: -------------------------------------------------------------------------------- 1 | /*============================================================================= 2 | 3 | Library: CTK 4 | 5 | Copyright (c) German Cancer Research Center, 6 | Division of Medical and Biological Informatics 7 | 8 | Licensed under the Apache License, Version 2.0 (the "License"); 9 | you may not use this file except in compliance with the License. 10 | You may obtain a copy of the License at 11 | 12 | http://www.apache.org/licenses/LICENSE-2.0 13 | 14 | Unless required by applicable law or agreed to in writing, software 15 | distributed under the License is distributed on an "AS IS" BASIS, 16 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | See the License for the specific language governing permissions and 18 | limitations under the License. 19 | 20 | =============================================================================*/ 21 | 22 | #ifndef __ctkBackTrace_h 23 | #define __ctkBackTrace_h 24 | 25 | // CTK includes 26 | #include 27 | 28 | // Qt includes 29 | #include 30 | #include 31 | 32 | 33 | struct ctkBackTracePrivate; 34 | 35 | //--------------------------------------------------------------------------- 36 | /** 37 | * \ingroup Core 38 | * 39 | * \brief Obtains a back trace from the current execution context. 40 | * 41 | * \remarks It is generally not safe to use this class in signal handlers. 42 | */ 43 | class CTK_CORE_EXPORT ctkBackTrace 44 | { 45 | public: 46 | 47 | static size_t const DefaultStackSize; 48 | 49 | ctkBackTrace(const ctkBackTrace& other); 50 | 51 | /** 52 | * \brief Create a back trace. 53 | * \param framesNumber The default maximum stack size. 54 | */ 55 | ctkBackTrace(size_t framesNumber = DefaultStackSize); 56 | 57 | virtual ~ctkBackTrace() throw(); 58 | 59 | /** 60 | * @brief Get the stack size. 61 | * @return The number of stack frames for this back trace. 62 | */ 63 | size_t stackSize() const; 64 | 65 | /** 66 | * @brief Get the return address for a given stack frame. 67 | * @param frameNumber The stack frame number. 68 | * @return The return address for the stack frame with number frameNumber 69 | * or NULL if there is no corresponding stack frame. 70 | */ 71 | void* returnAddress(unsigned frameNumber) const; 72 | 73 | /** 74 | * @brief Get a textual representation for a given stack frame. 75 | * @param frameNumber The stack frame number. 76 | * @return A string describing the stack frame with number frameNumber 77 | * or a null QString if there is no corresponding stack frame. 78 | */ 79 | QString stackFrame(unsigned frameNumber) const; 80 | 81 | /** 82 | * @brief Provides programmatic access to the stack trace information. 83 | * 84 | * The zeroth element of the returned list (assuming the list's size is non-zero) 85 | * represents the top of the stack, which is the last method invocation in the sequence. 86 | * 87 | * @return A list of string representations for each stack frame. 88 | */ 89 | QList stackTrace() const; 90 | 91 | private: 92 | 93 | QScopedPointer d; 94 | }; 95 | 96 | #ifdef Q_CC_MSVC 97 | namespace ctk { 98 | CTK_CORE_EXPORT bool DebugSymInitialize(); 99 | } 100 | #endif 101 | 102 | #endif // __ctkBackTrace_h 103 | -------------------------------------------------------------------------------- /includes/core/ctkBinaryFileDescriptor.h: -------------------------------------------------------------------------------- 1 | /*========================================================================= 2 | 3 | Library: CTK 4 | 5 | Copyright (c) Kitware Inc. 6 | 7 | Licensed under the Apache License, Version 2.0 (the "License"); 8 | you may not use this file except in compliance with the License. 9 | You may obtain a copy of the License at 10 | 11 | http://www.apache.org/licenses/LICENSE-2.0.txt 12 | 13 | Unless required by applicable law or agreed to in writing, software 14 | distributed under the License is distributed on an "AS IS" BASIS, 15 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | See the License for the specific language governing permissions and 17 | limitations under the License. 18 | 19 | =========================================================================*/ 20 | /*========================================================================= 21 | 22 | Portions (c) Copyright Brigham and Women's Hospital (BWH) 23 | All Rights Reserved. 24 | 25 | See http://www.slicer.org/copyright/copyright.txt for details. 26 | 27 | Program: Module Description Parser 28 | 29 | =========================================================================*/ 30 | 31 | #ifndef __ctkBinaryFileDescriptor_h 32 | #define __ctkBinaryFileDescriptor_h 33 | 34 | // Qt includes 35 | #include 36 | #include 37 | 38 | #include "ctkCoreExport.h" 39 | 40 | 41 | class ctkBinaryFileDescriptorPrivate; 42 | 43 | /// \ingroup Core 44 | /// Allows to resolve global symbols contained into an executable. 45 | /// Implementation valid only for unix-like systems (Linux, Mac, ...) 46 | class CTK_CORE_EXPORT ctkBinaryFileDescriptor 47 | { 48 | public: 49 | ctkBinaryFileDescriptor(); 50 | ctkBinaryFileDescriptor(const QString& _fileName); 51 | virtual ~ctkBinaryFileDescriptor(); 52 | 53 | QString fileName()const; 54 | void setFileName(const QString& _fileName); 55 | 56 | /// Load the object file containing the symbols 57 | bool load(); 58 | 59 | /// Unload / close the object file 60 | bool unload(); 61 | 62 | bool isLoaded() const; 63 | 64 | /// Get the address of a symbol in memory 65 | void* resolve(const char * symbol); 66 | 67 | protected: 68 | QScopedPointer d_ptr; 69 | 70 | private: 71 | Q_DECLARE_PRIVATE(ctkBinaryFileDescriptor); 72 | Q_DISABLE_COPY(ctkBinaryFileDescriptor); 73 | 74 | }; 75 | 76 | #endif 77 | -------------------------------------------------------------------------------- /includes/core/ctkCallback.h: -------------------------------------------------------------------------------- 1 | /*========================================================================= 2 | 3 | Library: CTK 4 | 5 | Copyright (c) Kitware Inc. 6 | 7 | Licensed under the Apache License, Version 2.0 (the "License"); 8 | you may not use this file except in compliance with the License. 9 | You may obtain a copy of the License at 10 | 11 | http://www.apache.org/licenses/LICENSE-2.0.txt 12 | 13 | Unless required by applicable law or agreed to in writing, software 14 | distributed under the License is distributed on an "AS IS" BASIS, 15 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | See the License for the specific language governing permissions and 17 | limitations under the License. 18 | 19 | =========================================================================*/ 20 | 21 | #ifndef __ctkCallback_h 22 | #define __ctkCallback_h 23 | 24 | // Qt includes 25 | #include 26 | 27 | // CTK includes 28 | #include "ctkCoreExport.h" 29 | 30 | //--------------------------------------------------------------------------- 31 | /// \ingroup Core 32 | /// The following example prints debug statement everytime the current value 33 | /// of the slider is changed: 34 | /// void print() { qDebug() << "signal called"; } 35 | /// ... 36 | /// QSlider slider(Qt::Horizontal); 37 | /// ctkCallback callback(print); 38 | /// QObject::connect(&slider, SIGNAL(valueChanged(int)), 39 | /// &callback, SLOT(invoke())); 40 | /// ... 41 | /// The following example prints the new value of the slider 42 | /// void print(void* data){ 43 | /// qDebug() << reinterpret_cast(data)->value(); 44 | /// } 45 | /// QSlider slider(Qt::Horizontal); 46 | /// ctkCallback callback(print); 47 | /// callback.setData(&slider); 48 | /// QObject::connect(&slider, SIGNAL(valueChanged(int)), 49 | /// &callback, SLOT(invoke())); 50 | class CTK_CORE_EXPORT ctkCallback : public QObject 51 | { 52 | Q_OBJECT 53 | public: 54 | 55 | ctkCallback(QObject * parentObject = 0); 56 | ctkCallback(void (*callback)(void * data), QObject * parentObject = 0); 57 | virtual ~ctkCallback(); 58 | 59 | /// Returns the current pointer function 60 | void (*callback()const)(void*); 61 | /// Sets a pointer function to call when invoke() is called. 62 | void setCallback(void (*callback)(void * data)); 63 | 64 | /// Returns the current callback data. 65 | /// \note By default ctkCallback itself will be passed as callback data 66 | /// \sa setCallbackData 67 | void * callbackData()const; 68 | /// Set callback data 69 | void setCallbackData(void * data); 70 | 71 | public Q_SLOTS: 72 | /// Internally calls the pointer function \a callback. 73 | virtual void invoke(); 74 | 75 | private: 76 | void (*Callback)(void * data); 77 | void * CallbackData; 78 | }; 79 | 80 | #endif 81 | 82 | -------------------------------------------------------------------------------- /includes/core/ctkCompilerDetections_p.h: -------------------------------------------------------------------------------- 1 | /*========================================================================= 2 | 3 | Library: CTK 4 | 5 | Copyright (c) Kitware Inc. 6 | 7 | Licensed under the Apache License, Version 2.0 (the "License"); 8 | you may not use this file except in compliance with the License. 9 | You may obtain a copy of the License at 10 | 11 | http://www.apache.org/licenses/LICENSE-2.0.txt 12 | 13 | Unless required by applicable law or agreed to in writing, software 14 | distributed under the License is distributed on an "AS IS" BASIS, 15 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | See the License for the specific language governing permissions and 17 | limitations under the License. 18 | 19 | =========================================================================*/ 20 | 21 | #ifndef __ctkCompilerDetections_p_h 22 | #define __ctkCompilerDetections_p_h 23 | 24 | // 25 | // This file is not part of the CTK API. It exists purely as an 26 | // implementation detail. This header file may change from version to 27 | // version without notice, or even be removed. 28 | // 29 | // We mean it. 30 | // 31 | 32 | /* 33 | * C++11 keywords and expressions 34 | */ 35 | #ifdef Q_NULLPTR 36 | # define CTK_NULLPTR Q_NULLPTR 37 | #else 38 | # define CTK_NULLPTR NULL 39 | #endif 40 | 41 | #endif 42 | -------------------------------------------------------------------------------- /includes/core/ctkCoreExport.h: -------------------------------------------------------------------------------- 1 | 2 | 3 | // .NAME __ctkCoreExport - manage Windows system differences 4 | // .SECTION Description 5 | // The __ctkCoreExport captures some system differences between Unix 6 | // and Windows operating systems. 7 | 8 | #ifndef __ctkCoreExport_h 9 | #define __ctkCoreExport_h 10 | 11 | #include "ctkCompilerDetections_p.h" 12 | 13 | #include 14 | 15 | #if defined(Q_OS_WIN) || defined(Q_OS_SYMBIAN) 16 | # if defined(CTKCore_EXPORTS) 17 | # define CTK_CORE_EXPORT Q_DECL_EXPORT 18 | # else 19 | # define CTK_CORE_EXPORT Q_DECL_IMPORT 20 | # endif 21 | #endif 22 | 23 | #if !defined(CTK_CORE_EXPORT) 24 | //# if defined(CTK_SHARED) 25 | # define CTK_CORE_EXPORT Q_DECL_EXPORT 26 | //# else 27 | //# define CTK_CORE_EXPORT 28 | //# endif 29 | #endif 30 | 31 | #endif 32 | 33 | -------------------------------------------------------------------------------- /includes/core/ctkCoreTestingUtilities.h: -------------------------------------------------------------------------------- 1 | /*========================================================================= 2 | 3 | Library: CTK 4 | 5 | Copyright (c) Kitware Inc. 6 | 7 | Licensed under the Apache License, Version 2.0 (the "License"); 8 | you may not use this file except in compliance with the License. 9 | You may obtain a copy of the License at 10 | 11 | http://www.apache.org/licenses/LICENSE-2.0.txt 12 | 13 | Unless required by applicable law or agreed to in writing, software 14 | distributed under the License is distributed on an "AS IS" BASIS, 15 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | See the License for the specific language governing permissions and 17 | limitations under the License. 18 | 19 | =========================================================================*/ 20 | 21 | #ifndef __ctkCoreTestingUtilities_h 22 | #define __ctkCoreTestingUtilities_h 23 | 24 | // CTK includes 25 | #include 26 | 27 | // Qt includes 28 | #include 29 | #include 30 | #include 31 | 32 | /// This module provides functions to facilitate writing tests. 33 | /// 34 | /// Before using this module, first consider the QTestLib 35 | /// unit testing framework available in Qt. 36 | /// 37 | /// Example: 38 | /// 39 | /// \code{.cpp} 40 | /// int current = 40 + 2; 41 | /// int expected = 43; 42 | /// if (!CheckInt(__LINE__, "40 + 2", current, expected)) 43 | /// { 44 | /// return false; 45 | /// } 46 | /// \endcode 47 | /// 48 | /// Usually these test methods are used by single-line convenience macros 49 | /// defined in ctkCoreTestingMacros.h. 50 | 51 | namespace ctkCoreTestingUtilities 52 | { 53 | 54 | CTK_CORE_EXPORT 55 | bool CheckInt(int line, const QString& description, 56 | int current, int expected); 57 | 58 | CTK_CORE_EXPORT 59 | bool CheckNotNull(int line, const QString& description, 60 | const void* pointer); 61 | 62 | CTK_CORE_EXPORT 63 | bool CheckNull(int line, const QString& description, 64 | const void* pointer); 65 | 66 | CTK_CORE_EXPORT 67 | bool CheckPointer(int line, const QString& description, 68 | void* current, void* expected, bool errorIfDifferent = true); 69 | 70 | CTK_CORE_EXPORT 71 | bool CheckString(int line, const QString& description, 72 | const char* current, const char* expected, bool errorIfDifferent = true ); 73 | 74 | CTK_CORE_EXPORT 75 | bool CheckStringList(int line, const QString& description, 76 | const QStringList& current, const QStringList& expected); 77 | 78 | CTK_CORE_EXPORT 79 | bool CheckVariant(int line, const QString& description, 80 | const QVariant& current, const QVariant& expected); 81 | 82 | } // namespace ctkCoreTestingUtilities 83 | 84 | #include "ctkCoreTestingUtilities.tpp" 85 | 86 | #endif 87 | -------------------------------------------------------------------------------- /includes/core/ctkErrorLogAbstractMessageHandler.h: -------------------------------------------------------------------------------- 1 | /*========================================================================= 2 | 3 | Library: CTK 4 | 5 | Copyright (c) Kitware Inc. 6 | 7 | Licensed under the Apache License, Version 2.0 (the "License"); 8 | you may not use this file except in compliance with the License. 9 | You may obtain a copy of the License at 10 | 11 | http://www.apache.org/licenses/LICENSE-2.0.txt 12 | 13 | Unless required by applicable law or agreed to in writing, software 14 | distributed under the License is distributed on an "AS IS" BASIS, 15 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | See the License for the specific language governing permissions and 17 | limitations under the License. 18 | 19 | =========================================================================*/ 20 | 21 | #ifndef CTKERRORLOGABSTRACTMESSAGEHANDLER_H 22 | #define CTKERRORLOGABSTRACTMESSAGEHANDLER_H 23 | 24 | // Qt includes 25 | #include 26 | #include 27 | 28 | // CTK includes 29 | #include "ctkCoreExport.h" 30 | #include "ctkErrorLogLevel.h" 31 | #include "ctkErrorLogTerminalOutput.h" 32 | 33 | //------------------------------------------------------------------------------ 34 | class ctkErrorLogAbstractMessageHandlerPrivate; 35 | struct ctkErrorLogContext; 36 | 37 | //------------------------------------------------------------------------------ 38 | /// \ingroup Core 39 | class CTK_CORE_EXPORT ctkErrorLogAbstractMessageHandler : public QObject 40 | { 41 | Q_OBJECT 42 | public: 43 | typedef QObject Superclass; 44 | /// Disabled by default. 45 | ctkErrorLogAbstractMessageHandler(); 46 | virtual ~ctkErrorLogAbstractMessageHandler(); 47 | 48 | virtual QString handlerName()const = 0; 49 | 50 | QString handlerPrettyName()const; 51 | 52 | bool enabled()const; 53 | void setEnabled(bool value); 54 | 55 | void handleMessage(const QString& threadId, ctkErrorLogLevel::LogLevel logLevel, 56 | const QString& origin, const ctkErrorLogContext& logContext, 57 | const QString &text); 58 | 59 | ctkErrorLogTerminalOutput* terminalOutput(ctkErrorLogTerminalOutput::TerminalOutput terminalOutputType)const; 60 | void setTerminalOutput(ctkErrorLogTerminalOutput::TerminalOutput terminalOutputType, 61 | ctkErrorLogTerminalOutput * terminalOutput); 62 | 63 | Q_SIGNALS: 64 | void messageHandled(const QDateTime& currentDateTime, const QString& threadId, 65 | ctkErrorLogLevel::LogLevel logLevel, const QString& origin, 66 | const ctkErrorLogContext& logContext, const QString& text); 67 | 68 | protected: 69 | void setHandlerPrettyName(const QString& newHandlerPrettyName); 70 | 71 | virtual void setEnabledInternal(bool value) = 0; 72 | 73 | protected: 74 | QScopedPointer d_ptr; 75 | 76 | private: 77 | Q_DECLARE_PRIVATE(ctkErrorLogAbstractMessageHandler) 78 | Q_DISABLE_COPY(ctkErrorLogAbstractMessageHandler) 79 | }; 80 | 81 | 82 | #endif // CTKERRORLOGABSTRACTMESSAGEHANDLER_H 83 | -------------------------------------------------------------------------------- /includes/core/ctkErrorLogContext.h: -------------------------------------------------------------------------------- 1 | /*========================================================================= 2 | 3 | Library: CTK 4 | 5 | Copyright (c) Kitware Inc. 6 | 7 | Licensed under the Apache License, Version 2.0 (the "License"); 8 | you may not use this file except in compliance with the License. 9 | You may obtain a copy of the License at 10 | 11 | http://www.apache.org/licenses/LICENSE-2.0.txt 12 | 13 | Unless required by applicable law or agreed to in writing, software 14 | distributed under the License is distributed on an "AS IS" BASIS, 15 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | See the License for the specific language governing permissions and 17 | limitations under the License. 18 | 19 | =========================================================================*/ 20 | 21 | #ifndef __ctkErrorLogContext_h 22 | #define __ctkErrorLogContext_h 23 | 24 | // Qt includes 25 | #include 26 | 27 | // CTK includes 28 | #include "ctkCoreExport.h" 29 | 30 | //------------------------------------------------------------------------------ 31 | /// \ingroup Core 32 | struct CTK_CORE_EXPORT ctkErrorLogContext 33 | { 34 | ctkErrorLogContext():Line(0),File("unknown"), Function("unknown"), Message(""){} 35 | ctkErrorLogContext(const QString& msg): 36 | Line(0),File("unknown"), Function("unknown"), Message(msg){} 37 | QString Category; 38 | int Line; 39 | QString File; 40 | QString Function; 41 | QString Message; 42 | }; 43 | 44 | #endif 45 | -------------------------------------------------------------------------------- /includes/core/ctkErrorLogFDMessageHandler.h: -------------------------------------------------------------------------------- 1 | /*========================================================================= 2 | 3 | Library: CTK 4 | 5 | Copyright (c) Kitware Inc. 6 | 7 | Licensed under the Apache License, Version 2.0 (the "License"); 8 | you may not use this file except in compliance with the License. 9 | You may obtain a copy of the License at 10 | 11 | http://www.apache.org/licenses/LICENSE-2.0.txt 12 | 13 | Unless required by applicable law or agreed to in writing, software 14 | distributed under the License is distributed on an "AS IS" BASIS, 15 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | See the License for the specific language governing permissions and 17 | limitations under the License. 18 | 19 | =========================================================================*/ 20 | 21 | #ifndef __ctkErrorLogFDMessageHandler_h 22 | #define __ctkErrorLogFDMessageHandler_h 23 | 24 | // CTK includes 25 | #include 26 | #include "ctkCoreExport.h" 27 | 28 | class ctkErrorLogFDMessageHandlerPrivate; 29 | 30 | //------------------------------------------------------------------------------ 31 | /// \ingroup Core 32 | class CTK_CORE_EXPORT ctkErrorLogFDMessageHandler : public ctkErrorLogAbstractMessageHandler 33 | { 34 | public: 35 | typedef ctkErrorLogAbstractMessageHandler Superclass; 36 | 37 | ctkErrorLogFDMessageHandler(); 38 | virtual ~ctkErrorLogFDMessageHandler(); 39 | 40 | static QString HandlerName; 41 | 42 | virtual QString handlerName()const; 43 | virtual void setEnabledInternal(bool value); 44 | 45 | protected: 46 | QScopedPointer d_ptr; 47 | 48 | private: 49 | Q_DECLARE_PRIVATE(ctkErrorLogFDMessageHandler); 50 | Q_DISABLE_COPY(ctkErrorLogFDMessageHandler); 51 | }; 52 | 53 | #endif 54 | 55 | -------------------------------------------------------------------------------- /includes/core/ctkErrorLogFDMessageHandler_p.h: -------------------------------------------------------------------------------- 1 | /*========================================================================= 2 | 3 | Library: CTK 4 | 5 | Copyright (c) Kitware Inc. 6 | 7 | Licensed under the Apache License, Version 2.0 (the "License"); 8 | you may not use this file except in compliance with the License. 9 | You may obtain a copy of the License at 10 | 11 | http://www.apache.org/licenses/LICENSE-2.0.txt 12 | 13 | Unless required by applicable law or agreed to in writing, software 14 | distributed under the License is distributed on an "AS IS" BASIS, 15 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | See the License for the specific language governing permissions and 17 | limitations under the License. 18 | 19 | =========================================================================*/ 20 | 21 | #ifndef __ctkErrorLogFDMessageHandler_p_h 22 | #define __ctkErrorLogFDMessageHandler_p_h 23 | 24 | // Qt includes 25 | #include 26 | #include 27 | 28 | // CTK includes 29 | #include "ctkErrorLogAbstractMessageHandler.h" 30 | #include "ctkErrorLogTerminalOutput.h" 31 | 32 | // STD includes 33 | #include 34 | 35 | class ctkErrorLogFDMessageHandler; 36 | 37 | // -------------------------------------------------------------------------- 38 | // ctkFDHandler 39 | 40 | // -------------------------------------------------------------------------- 41 | /// \ingroup Core 42 | class ctkFDHandler : public QThread 43 | { 44 | Q_OBJECT 45 | Q_PROPERTY(bool enabled READ enabled WRITE setEnabled) 46 | public: 47 | typedef ctkFDHandler Self; 48 | 49 | ctkFDHandler(ctkErrorLogFDMessageHandler* messageHandler, 50 | ctkErrorLogLevel::LogLevel logLevel, 51 | ctkErrorLogTerminalOutput::TerminalOutput terminalOutput); 52 | virtual ~ctkFDHandler(); 53 | 54 | /// Enable/Disable the handler. 55 | void setEnabled(bool value); 56 | 57 | /// Return if the handler is enabled. This methods is thread-safe. 58 | bool enabled()const; 59 | 60 | FILE* terminalOutputFile(); 61 | 62 | protected: 63 | void setupPipe(); 64 | 65 | void run(); 66 | 67 | private: 68 | ctkErrorLogFDMessageHandler * MessageHandler; 69 | ctkErrorLogLevel::LogLevel LogLevel; 70 | 71 | ctkErrorLogTerminalOutput::TerminalOutput TerminalOutput; 72 | 73 | int SavedFDNumber; 74 | fpos_t SavedFDPos; 75 | 76 | int Pipe[2]; // 0: Read, 1: Write 77 | 78 | bool Initialized; 79 | 80 | mutable QMutex EnableMutex; 81 | bool Enabled; 82 | }; 83 | 84 | 85 | #endif 86 | -------------------------------------------------------------------------------- /includes/core/ctkErrorLogLevel.h: -------------------------------------------------------------------------------- 1 | /*========================================================================= 2 | 3 | Library: CTK 4 | 5 | Copyright (c) Kitware Inc. 6 | 7 | Licensed under the Apache License, Version 2.0 (the "License"); 8 | you may not use this file except in compliance with the License. 9 | You may obtain a copy of the License at 10 | 11 | http://www.apache.org/licenses/LICENSE-2.0.txt 12 | 13 | Unless required by applicable law or agreed to in writing, software 14 | distributed under the License is distributed on an "AS IS" BASIS, 15 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | See the License for the specific language governing permissions and 17 | limitations under the License. 18 | 19 | =========================================================================*/ 20 | 21 | #ifndef CTKERRORLOGLEVEL_H 22 | #define CTKERRORLOGLEVEL_H 23 | 24 | // Qt includes 25 | #include 26 | 27 | // CTK includes 28 | #include "ctkCoreExport.h" 29 | 30 | //------------------------------------------------------------------------------ 31 | /// \ingroup Core 32 | class CTK_CORE_EXPORT ctkErrorLogLevel : public QObject 33 | { 34 | Q_OBJECT 35 | Q_FLAGS(LogLevel) 36 | public: 37 | ctkErrorLogLevel(); 38 | 39 | enum LogLevel 40 | { 41 | None = 0x0, 42 | Unknown = 0x1, 43 | Status = 0x2, 44 | Trace = 0x4, 45 | Debug = 0x8, 46 | Info = 0x10, 47 | Warning = 0x20, 48 | Error = 0x40, 49 | Critical = 0x80, 50 | Fatal = 0x100 51 | }; 52 | Q_DECLARE_FLAGS(LogLevels, LogLevel) 53 | 54 | QString operator ()(LogLevel logLevel); 55 | 56 | static QString logLevelAsString(ctkErrorLogLevel::LogLevel logLevel); 57 | }; 58 | Q_DECLARE_OPERATORS_FOR_FLAGS(ctkErrorLogLevel::LogLevels) 59 | 60 | 61 | #endif // CTKERRORLOGLEVEL_H 62 | -------------------------------------------------------------------------------- /includes/core/ctkErrorLogQtMessageHandler.h: -------------------------------------------------------------------------------- 1 | /*========================================================================= 2 | 3 | Library: CTK 4 | 5 | Copyright (c) Kitware Inc. 6 | 7 | Licensed under the Apache License, Version 2.0 (the "License"); 8 | you may not use this file except in compliance with the License. 9 | You may obtain a copy of the License at 10 | 11 | http://www.apache.org/licenses/LICENSE-2.0.txt 12 | 13 | Unless required by applicable law or agreed to in writing, software 14 | distributed under the License is distributed on an "AS IS" BASIS, 15 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | See the License for the specific language governing permissions and 17 | limitations under the License. 18 | 19 | =========================================================================*/ 20 | 21 | #ifndef __ctkErrorLogQtMessageHandler_h 22 | #define __ctkErrorLogQtMessageHandler_h 23 | 24 | // CTK includes 25 | #include "ctkErrorLogAbstractMessageHandler.h" 26 | #include "ctkCoreExport.h" 27 | 28 | // Qt includes 29 | #if QT_VERSION >= 0x50000 30 | #include 31 | #endif 32 | 33 | //------------------------------------------------------------------------------ 34 | /// \ingroup Core 35 | class CTK_CORE_EXPORT ctkErrorLogQtMessageHandler : public ctkErrorLogAbstractMessageHandler 36 | { 37 | Q_OBJECT 38 | 39 | public: 40 | typedef ctkErrorLogAbstractMessageHandler Superclass; 41 | 42 | ctkErrorLogQtMessageHandler(); 43 | 44 | static QString HandlerName; 45 | 46 | virtual QString handlerName()const; 47 | virtual void setEnabledInternal(bool value); 48 | 49 | #if QT_VERSION >= 0x50000 50 | QtMessageHandler SavedQtMessageHandler; 51 | #else 52 | QtMsgHandler SavedQtMessageHandler; 53 | #endif 54 | }; 55 | 56 | #endif 57 | 58 | -------------------------------------------------------------------------------- /includes/core/ctkErrorLogStreamMessageHandler.h: -------------------------------------------------------------------------------- 1 | /*========================================================================= 2 | 3 | Library: CTK 4 | 5 | Copyright (c) Kitware Inc. 6 | 7 | Licensed under the Apache License, Version 2.0 (the "License"); 8 | you may not use this file except in compliance with the License. 9 | You may obtain a copy of the License at 10 | 11 | http://www.apache.org/licenses/LICENSE-2.0.txt 12 | 13 | Unless required by applicable law or agreed to in writing, software 14 | distributed under the License is distributed on an "AS IS" BASIS, 15 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | See the License for the specific language governing permissions and 17 | limitations under the License. 18 | 19 | =========================================================================*/ 20 | 21 | #ifndef __ctkErrorLogStreamMessageHandler_h 22 | #define __ctkErrorLogStreamMessageHandler_h 23 | 24 | // CTK includes 25 | #include 26 | #include "ctkCoreExport.h" 27 | 28 | class ctkErrorLogStreamMessageHandlerPrivate; 29 | 30 | //------------------------------------------------------------------------------ 31 | /// \ingroup Core 32 | class CTK_CORE_EXPORT ctkErrorLogStreamMessageHandler 33 | : public ctkErrorLogAbstractMessageHandler 34 | { 35 | public: 36 | typedef ctkErrorLogAbstractMessageHandler Superclass; 37 | 38 | ctkErrorLogStreamMessageHandler(); 39 | virtual ~ctkErrorLogStreamMessageHandler(); 40 | 41 | static QString HandlerName; 42 | 43 | virtual QString handlerName()const; 44 | virtual void setEnabledInternal(bool value); 45 | 46 | protected: 47 | QScopedPointer d_ptr; 48 | 49 | private: 50 | Q_DECLARE_PRIVATE(ctkErrorLogStreamMessageHandler); 51 | Q_DISABLE_COPY(ctkErrorLogStreamMessageHandler); 52 | }; 53 | 54 | #endif 55 | 56 | -------------------------------------------------------------------------------- /includes/core/ctkErrorLogTerminalOutput.h: -------------------------------------------------------------------------------- 1 | /*========================================================================= 2 | 3 | Library: CTK 4 | 5 | Copyright (c) Kitware Inc. 6 | 7 | Licensed under the Apache License, Version 2.0 (the "License"); 8 | you may not use this file except in compliance with the License. 9 | You may obtain a copy of the License at 10 | 11 | http://www.apache.org/licenses/LICENSE-2.0.txt 12 | 13 | Unless required by applicable law or agreed to in writing, software 14 | distributed under the License is distributed on an "AS IS" BASIS, 15 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | See the License for the specific language governing permissions and 17 | limitations under the License. 18 | 19 | =========================================================================*/ 20 | 21 | #ifndef CTKERRORLOGTERMINALOUTPUT_H 22 | #define CTKERRORLOGTERMINALOUTPUT_H 23 | 24 | // Qt includes 25 | #include 26 | #include 27 | 28 | // CTK includes 29 | #include 30 | 31 | //------------------------------------------------------------------------------ 32 | class ctkErrorLogTerminalOutputPrivate; 33 | 34 | //------------------------------------------------------------------------------ 35 | /// \ingroup Core 36 | class CTK_CORE_EXPORT ctkErrorLogTerminalOutput : public QObject 37 | { 38 | Q_OBJECT 39 | Q_FLAGS(TerminalOutputs) 40 | 41 | public: 42 | ctkErrorLogTerminalOutput(); 43 | virtual ~ctkErrorLogTerminalOutput(); 44 | 45 | enum TerminalOutput 46 | { 47 | None = 0x0, 48 | StandardError = 0x1, 49 | StandardOutput = 0x2, 50 | All = StandardError | StandardOutput 51 | }; 52 | Q_DECLARE_FLAGS(TerminalOutputs, TerminalOutput) 53 | 54 | bool enabled()const; 55 | void setEnabled(bool value); 56 | 57 | int fileDescriptor()const; 58 | void setFileDescriptor(int fd); 59 | 60 | void output(const QString& text); 61 | 62 | protected: 63 | QScopedPointer d_ptr; 64 | 65 | private: 66 | Q_DECLARE_PRIVATE(ctkErrorLogTerminalOutput) 67 | Q_DISABLE_COPY(ctkErrorLogTerminalOutput) 68 | }; 69 | 70 | Q_DECLARE_OPERATORS_FOR_FLAGS(ctkErrorLogTerminalOutput::TerminalOutputs) 71 | 72 | #endif // CTKERRORLOGTERMINALOUTPUT_H 73 | -------------------------------------------------------------------------------- /includes/core/ctkFileLogger.h: -------------------------------------------------------------------------------- 1 | /*========================================================================= 2 | 3 | Library: CTK 4 | 5 | Copyright (c) Kitware Inc. 6 | 7 | Licensed under the Apache License, Version 2.0 (the "License"); 8 | you may not use this file except in compliance with the License. 9 | You may obtain a copy of the License at 10 | 11 | http://www.apache.org/licenses/LICENSE-2.0.txt 12 | 13 | Unless required by applicable law or agreed to in writing, software 14 | distributed under the License is distributed on an "AS IS" BASIS, 15 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | See the License for the specific language governing permissions and 17 | limitations under the License. 18 | 19 | =========================================================================*/ 20 | 21 | #ifndef __ctkFileLogger_h 22 | #define __ctkFileLogger_h 23 | 24 | // Qt includes 25 | #include 26 | 27 | // CTK includes 28 | #include "ctkCoreExport.h" 29 | 30 | //------------------------------------------------------------------------------ 31 | class ctkFileLoggerPrivate; 32 | 33 | //------------------------------------------------------------------------------ 34 | /// \ingroup Core 35 | class CTK_CORE_EXPORT ctkFileLogger : public QObject 36 | { 37 | Q_OBJECT 38 | Q_PROPERTY(bool enabled READ enabled WRITE setEnabled) 39 | Q_PROPERTY(QString filePath READ filePath WRITE setFilePath) 40 | 41 | public: 42 | typedef QObject Superclass; 43 | typedef ctkFileLogger Self; 44 | explicit ctkFileLogger(QObject* parentObject = 0); 45 | virtual ~ctkFileLogger(); 46 | 47 | bool enabled()const; 48 | void setEnabled(bool value); 49 | 50 | QString filePath()const; 51 | void setFilePath(const QString& filePath); 52 | 53 | int numberOfFilesToKeep()const; 54 | void setNumberOfFilesToKeep(int value); 55 | 56 | public Q_SLOTS: 57 | void logMessage(const QString& msg); 58 | 59 | protected: 60 | QScopedPointer d_ptr; 61 | 62 | private: 63 | Q_DECLARE_PRIVATE(ctkFileLogger); 64 | Q_DISABLE_COPY(ctkFileLogger); 65 | }; 66 | 67 | #endif 68 | -------------------------------------------------------------------------------- /includes/core/ctkLinearValueProxy.h: -------------------------------------------------------------------------------- 1 | /*========================================================================= 2 | 3 | Library: CTK 4 | 5 | Copyright (c) Kitware Inc. 6 | 7 | Licensed under the Apache License, Version 2.0 (the "License"); 8 | you may not use this file except in compliance with the License. 9 | You may obtain a copy of the License at 10 | 11 | http://www.apache.org/licenses/LICENSE-2.0.txt 12 | 13 | Unless required by applicable law or agreed to in writing, software 14 | distributed under the License is distributed on an "AS IS" BASIS, 15 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | See the License for the specific language governing permissions and 17 | limitations under the License. 18 | 19 | =========================================================================*/ 20 | 21 | #ifndef __ctkLinearValueProxy_h 22 | #define __ctkLinearValueProxy_h 23 | 24 | // CTK includes 25 | #include "ctkCoreExport.h" 26 | #include "ctkValueProxy.h" 27 | #include "ctkPimpl.h" 28 | 29 | class ctkLinearValueProxyPrivate; 30 | 31 | /// \ingroup Core 32 | /// \brief Implementation of an affine value proxy. 33 | /// The ctkLinearValueProxy takes a coefficient and an offset, 34 | /// effectively implementing a value proxy such as: 35 | /// valueProxy = coefficient * value + offset 36 | /// Note: If the coefficient is null then the property value given 37 | /// by value = (valueProxy - offset) / coefficient can give bad results 38 | /// (+ or - infinity depending on the sign of valueProxy - offset). 39 | /// \sa ctkValueProxy 40 | class CTK_CORE_EXPORT ctkLinearValueProxy : public ctkValueProxy 41 | { 42 | Q_OBJECT 43 | Q_PROPERTY(double coefficient READ coefficient WRITE setCoefficient) 44 | Q_PROPERTY(double offset READ offset WRITE setOffset) 45 | 46 | public: 47 | typedef ctkValueProxy Superclass; 48 | explicit ctkLinearValueProxy(QObject* parent = 0); 49 | virtual ~ctkLinearValueProxy(); 50 | 51 | virtual double proxyValueFromValue(double value) const; 52 | 53 | virtual double valueFromProxyValue(double proxyValue) const; 54 | 55 | virtual double coefficient() const; 56 | virtual double offset() const; 57 | 58 | public Q_SLOTS: 59 | virtual void setCoefficient(double newCoeff); 60 | virtual void setOffset(double newOffset); 61 | 62 | protected: 63 | QScopedPointer d_ptr; 64 | 65 | private: 66 | Q_DECLARE_PRIVATE(ctkLinearValueProxy); 67 | Q_DISABLE_COPY(ctkLinearValueProxy); 68 | }; 69 | 70 | #endif 71 | -------------------------------------------------------------------------------- /includes/core/ctkLogger.h: -------------------------------------------------------------------------------- 1 | /*========================================================================= 2 | 3 | Library: CTK 4 | 5 | Copyright (c) Kitware Inc. 6 | 7 | Licensed under the Apache License, Version 2.0 (the "License"); 8 | you may not use this file except in compliance with the License. 9 | You may obtain a copy of the License at 10 | 11 | http://www.apache.org/licenses/LICENSE-2.0.txt 12 | 13 | Unless required by applicable law or agreed to in writing, software 14 | distributed under the License is distributed on an "AS IS" BASIS, 15 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | See the License for the specific language governing permissions and 17 | limitations under the License. 18 | 19 | =========================================================================*/ 20 | 21 | #ifndef __ctkLogger_h 22 | #define __ctkLogger_h 23 | 24 | // Qt includes 25 | #include 26 | 27 | // CTK includes 28 | #include 29 | #include "ctkCoreExport.h" 30 | 31 | class ctkLoggerPrivate; 32 | 33 | /// \deprecated This class was a wrapper around Log4Qt. Since Log4Qt dependency has been 34 | /// removed, it is advised to use qDebug(), qWarning() and qCritical() instead. 35 | /// \ingroup Core 36 | class CTK_CORE_EXPORT ctkLogger : public QObject 37 | { 38 | Q_OBJECT 39 | public: 40 | typedef QObject Superclass; 41 | /// Default mode is Off 42 | explicit ctkLogger(QString name, QObject* parent = 0); 43 | virtual ~ctkLogger (); 44 | 45 | void debug(const QString& s); 46 | void info(const QString& s); 47 | void trace(const QString& s); 48 | void warn(const QString& s); 49 | void error(const QString& s); 50 | void fatal(const QString& s); 51 | 52 | protected: 53 | QScopedPointer d_ptr; 54 | 55 | private: 56 | Q_DECLARE_PRIVATE(ctkLogger); 57 | Q_DISABLE_COPY(ctkLogger); 58 | }; 59 | 60 | #endif 61 | -------------------------------------------------------------------------------- /includes/core/ctkScopedCurrentDir.h: -------------------------------------------------------------------------------- 1 | /*========================================================================= 2 | 3 | Library: CTK 4 | 5 | Copyright (c) Kitware Inc. 6 | 7 | Licensed under the Apache License, Version 2.0 (the "License"); 8 | you may not use this file except in compliance with the License. 9 | You may obtain a copy of the License at 10 | 11 | http://www.apache.org/licenses/LICENSE-2.0.txt 12 | 13 | Unless required by applicable law or agreed to in writing, software 14 | distributed under the License is distributed on an "AS IS" BASIS, 15 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | See the License for the specific language governing permissions and 17 | limitations under the License. 18 | 19 | =========================================================================*/ 20 | 21 | #ifndef __ctkScopedCurrentDir_h 22 | #define __ctkScopedCurrentDir_h 23 | 24 | // Qt includes 25 | #include 26 | 27 | // CTK includes 28 | #include "ctkCoreExport.h" 29 | 30 | class ctkScopedCurrentDirPrivate; 31 | 32 | /// 33 | /// \brief Use this class to change the current application directory in a given scope 34 | /// and automatically restore it. 35 | /// 36 | /// This is particulary useful in case a plugin and its dependent libraries should be loaded from 37 | /// a known directory. 38 | /// Indeed, changing the application PATH, LD_LIBRARY_PATH or DYLD_LIBRARY_PATH within the current 39 | /// process won't have the desired effect. The loader checks for these variables only once when 40 | /// the process starts. 41 | /// \sa http://stackoverflow.com/questions/856116/changing-ld-library-path-at-runtime-for-ctypes 42 | /// \sa http://stackoverflow.com/questions/1178094/change-current-process-environment 43 | /// 44 | /// \ingroup Core 45 | class CTK_CORE_EXPORT ctkScopedCurrentDir 46 | { 47 | public: 48 | explicit ctkScopedCurrentDir(const QString& path); 49 | virtual ~ctkScopedCurrentDir(); 50 | 51 | /// Return the current application path 52 | /// \sa QDir::currentPath 53 | QString currentPath()const; 54 | 55 | /// Return saved current path 56 | QString savedCurrentPath()const; 57 | 58 | protected: 59 | QScopedPointer d_ptr; 60 | 61 | private: 62 | Q_DECLARE_PRIVATE(ctkScopedCurrentDir); 63 | Q_DISABLE_COPY(ctkScopedCurrentDir); 64 | }; 65 | 66 | #endif 67 | 68 | 69 | -------------------------------------------------------------------------------- /includes/core/ctkSetName.h: -------------------------------------------------------------------------------- 1 | /*========================================================================= 2 | 3 | Library: CTK 4 | 5 | Copyright (c) Kitware Inc. 6 | 7 | Licensed under the Apache License, Version 2.0 (the "License"); 8 | you may not use this file except in compliance with the License. 9 | You may obtain a copy of the License at 10 | 11 | http://www.apache.org/licenses/LICENSE-2.0.txt 12 | 13 | Unless required by applicable law or agreed to in writing, software 14 | distributed under the License is distributed on an "AS IS" BASIS, 15 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | See the License for the specific language governing permissions and 17 | limitations under the License. 18 | 19 | =========================================================================*/ 20 | /*========================================================================= 21 | 22 | Program: ParaView 23 | Module: pqSetName.h 24 | 25 | Copyright (c) 2005-2008 Sandia Corporation, Kitware Inc. 26 | All rights reserved. 27 | 28 | ParaView is a free software; you can redistribute it and/or modify it 29 | under the terms of the ParaView license version 1.2. 30 | 31 | See License_v1.2.txt for the full ParaView license. 32 | A copy of this license can be obtained by contacting 33 | Kitware Inc. 34 | 28 Corporate Drive 35 | Clifton Park, NY 12065 36 | USA 37 | 38 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 39 | ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 40 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 41 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR 42 | CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 43 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 44 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 45 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 46 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 47 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 48 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 49 | 50 | =========================================================================*/ 51 | 52 | #ifndef __ctkSetName_h 53 | #define __ctkSetName_h 54 | 55 | // Qt includes 56 | #include 57 | 58 | // CTK includes 59 | #include "ctkCoreExport.h" 60 | 61 | /** 62 | Using ctkSetName, you can create and initialize Qt objects without having to create a bunch of temporaries: 63 | 64 | \code 65 | menu->addAction("Open") << ctkSetName("FileOpenMenu"); 66 | \endcode 67 | 68 | \sa pqSetData, pqConnect 69 | */ 70 | struct CTK_CORE_EXPORT ctkSetName 71 | { 72 | ctkSetName(const QString& Name); 73 | const QString Name; 74 | }; 75 | 76 | //----------------------------------------------------------------------------- 77 | /// Sets a Qt object's name 78 | template 79 | T* operator<<(T* LHS, const ctkSetName& RHS) 80 | { 81 | LHS->setObjectName(RHS.Name); 82 | return LHS; 83 | } 84 | 85 | #endif 86 | -------------------------------------------------------------------------------- /includes/core/ctkValueProxy.h: -------------------------------------------------------------------------------- 1 | /*========================================================================= 2 | 3 | Library: CTK 4 | 5 | Copyright (c) Kitware Inc. 6 | 7 | Licensed under the Apache License, Version 2.0 (the "License"); 8 | you may not use this file except in compliance with the License. 9 | You may obtain a copy of the License at 10 | 11 | http://www.apache.org/licenses/LICENSE-2.0.txt 12 | 13 | Unless required by applicable law or agreed to in writing, software 14 | distributed under the License is distributed on an "AS IS" BASIS, 15 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | See the License for the specific language governing permissions and 17 | limitations under the License. 18 | 19 | =========================================================================*/ 20 | 21 | #ifndef __ctkValueProxy_h 22 | #define __ctkValueProxy_h 23 | 24 | // Qt includes 25 | #include 26 | #include 27 | 28 | // CTK includes 29 | #include "ctkCoreExport.h" 30 | 31 | class ctkValueProxyPrivate; 32 | 33 | /// \ingroup Core 34 | /// \brief Base class for value proxies. 35 | /// Value proxy allows to decouple the displayed value from the values 36 | /// accessed within the program. For example, one may want to display 37 | /// Fahrenheit while still working with Celsius. 38 | /// 39 | /// A ctkValueProxy can be used by connecting signal/slots to the 40 | /// value and proxyValue properties or by using directly the 41 | /// valueFromProxyValue and proxyValueFromValue functions. 42 | /// 43 | /// Subclasses should reimplement the function proxyValueFromValue() 44 | /// and valueFromProxyValue(). 45 | /// \sa ctkLinearValueProxy 46 | class CTK_CORE_EXPORT ctkValueProxy : public QObject 47 | { 48 | Q_OBJECT 49 | 50 | /// The value holds the current value. If the value proxy is 51 | /// considered as a function, then this function applied to the value is 52 | /// the proxy value. 53 | /// The value is updated if the proxy value is changed. 54 | Q_PROPERTY(double value READ value WRITE setValue NOTIFY valueChanged) 55 | 56 | /// The proxy value holds the value transformed. If the value proxy is 57 | /// considered as a function, then the proxy value is the result of 58 | /// this function applied to value. 59 | /// The proxy value is updated if the value is changed. 60 | Q_PROPERTY(double proxyValue READ proxyValue WRITE setProxyValue NOTIFY proxyValueChanged) 61 | 62 | public: 63 | typedef QObject Superclass; 64 | explicit ctkValueProxy(QObject* parent = 0); 65 | virtual ~ctkValueProxy(); 66 | 67 | virtual double proxyValueFromValue(double value) const = 0; 68 | virtual double valueFromProxyValue(double proxyValue) const = 0; 69 | 70 | double value() const; 71 | virtual double proxyValue() const; 72 | 73 | public Q_SLOTS: 74 | void setValue(double newValue); 75 | void setProxyValue(double newProxyValue); 76 | 77 | Q_SIGNALS: 78 | void valueChanged(double); 79 | void proxyValueChanged(double); 80 | 81 | void proxyAboutToBeModified(); 82 | void proxyModified(); 83 | 84 | protected: 85 | QScopedPointer d_ptr; 86 | 87 | /// Utilities function for subclasses. 88 | /// Can be called to update the value/proxyValue from the proxyValue/value. 89 | void updateProxyValue(); 90 | void updateValue(); 91 | 92 | private: 93 | Q_DECLARE_PRIVATE(ctkValueProxy); 94 | Q_DISABLE_COPY(ctkValueProxy); 95 | }; 96 | 97 | #endif 98 | -------------------------------------------------------------------------------- /includes/core/ctkWorkflowStep_p.h: -------------------------------------------------------------------------------- 1 | /*========================================================================= 2 | 3 | Library: CTK 4 | 5 | Copyright (c) Kitware Inc. 6 | 7 | Licensed under the Apache License, Version 2.0 (the "License"); 8 | you may not use this file except in compliance with the License. 9 | You may obtain a copy of the License at 10 | 11 | http://www.apache.org/licenses/LICENSE-2.0.txt 12 | 13 | Unless required by applicable law or agreed to in writing, software 14 | distributed under the License is distributed on an "AS IS" BASIS, 15 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | See the License for the specific language governing permissions and 17 | limitations under the License. 18 | 19 | =========================================================================*/ 20 | 21 | #ifndef __ctkWorkflowStep_p_h 22 | #define __ctkWorkflowStep_p_h 23 | 24 | // Qt includes 25 | #include 26 | #include 27 | 28 | class QString; 29 | class QState; 30 | 31 | // CTK includes 32 | #include 33 | #include "ctkWorkflow.h" 34 | #include "ctkWorkflowStep.h" 35 | #include "ctkWorkflowTransitions.h" 36 | #include "ctkCoreExport.h" 37 | 38 | class ctkWorkflow; 39 | 40 | //----------------------------------------------------------------------------- 41 | /** 42 | * \ingroup Core 43 | */ 44 | class CTK_CORE_EXPORT ctkWorkflowStepPrivate: public QObject 45 | { 46 | Q_OBJECT 47 | Q_DECLARE_PUBLIC(ctkWorkflowStep); 48 | 49 | public: 50 | ctkWorkflowStep* q_ptr; 51 | ctkWorkflowStepPrivate(ctkWorkflowStep& object); 52 | ~ctkWorkflowStepPrivate(); 53 | 54 | protected: 55 | ctkWorkflow* Workflow; 56 | 57 | bool WidgetType; 58 | 59 | QString Id; 60 | QString Name; 61 | QString Description; 62 | QString StatusText; 63 | 64 | QPointer ProcessingState; 65 | QPointer ValidationState; 66 | 67 | ctkWorkflowIntrastepTransition* ValidationTransition; 68 | ctkWorkflowIntrastepTransition* ValidationFailedTransition; 69 | 70 | bool HasValidateCommand; 71 | bool HasOnEntryCommand; 72 | bool HasOnExitCommand; 73 | 74 | void invokeValidateCommandInternal(const QString& desiredBranchId)const; 75 | 76 | void validationCompleteInternal(bool validationSuceeded, const QString& branchId)const; 77 | 78 | void invokeOnEntryCommandInternal(const ctkWorkflowStep* comingFrom, const ctkWorkflowInterstepTransition::InterstepTransitionType transitionType)const; 79 | 80 | void onEntryCompleteInternal()const; 81 | 82 | void invokeOnExitCommandInternal(const ctkWorkflowStep* goingTo, const ctkWorkflowInterstepTransition::InterstepTransitionType transitionType)const; 83 | 84 | void onExitCompleteInternal()const; 85 | 86 | 87 | Q_SIGNALS: 88 | void invokeValidateCommand(const QString& desiredBranchId)const; 89 | 90 | void validationComplete(bool validationSuceeded, const QString& branchId)const; 91 | 92 | void invokeOnEntryCommand(const ctkWorkflowStep* comingFrom, const ctkWorkflowInterstepTransition::InterstepTransitionType transitionType)const; 93 | 94 | void onEntryComplete()const; 95 | 96 | void invokeOnExitCommand(const ctkWorkflowStep* goingTo, const ctkWorkflowInterstepTransition::InterstepTransitionType transitionType)const; 97 | 98 | void onExitComplete()const; 99 | 100 | private: 101 | friend class ctkWorkflowPrivate; // for access to invoke...Internal() methods 102 | 103 | }; 104 | 105 | #endif 106 | -------------------------------------------------------------------------------- /includes/imainwindow.h: -------------------------------------------------------------------------------- 1 | #ifndef IMAINWINDOW_H 2 | #define IMAINWINDOW_H 3 | 4 | #include 5 | 6 | class iMainWindow 7 | { 8 | public: 9 | virtual void popMainWindow() = 0; 10 | }; 11 | 12 | Q_DECLARE_INTERFACE(iMainWindow, "interface_mainwindow") 13 | 14 | #endif // IMAINWINDOW_H 15 | -------------------------------------------------------------------------------- /includes/pluginFramework/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Iyme/ctkExample/3e99e30049d0b2055fa3a9625ca7efbff273a94b/includes/pluginFramework/.DS_Store -------------------------------------------------------------------------------- /includes/pluginFramework/ctkApplicationRunnable.cpp: -------------------------------------------------------------------------------- 1 | /*============================================================================= 2 | 3 | Library: CTK 4 | 5 | Copyright (c) German Cancer Research Center, 6 | Division of Medical and Biological Informatics 7 | 8 | Licensed under the Apache License, Version 2.0 (the "License"); 9 | you may not use this file except in compliance with the License. 10 | You may obtain a copy of the License at 11 | 12 | http://www.apache.org/licenses/LICENSE-2.0 13 | 14 | Unless required by applicable law or agreed to in writing, software 15 | distributed under the License is distributed on an "AS IS" BASIS, 16 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | See the License for the specific language governing permissions and 18 | limitations under the License. 19 | 20 | =============================================================================*/ 21 | 22 | #include "ctkApplicationRunnable.h" 23 | 24 | ctkApplicationRunnable::~ctkApplicationRunnable() 25 | { 26 | } 27 | -------------------------------------------------------------------------------- /includes/pluginFramework/ctkApplicationRunnable.h: -------------------------------------------------------------------------------- 1 | /*============================================================================= 2 | 3 | Library: CTK 4 | 5 | Copyright (c) German Cancer Research Center, 6 | Division of Medical and Biological Informatics 7 | 8 | Licensed under the Apache License, Version 2.0 (the "License"); 9 | you may not use this file except in compliance with the License. 10 | You may obtain a copy of the License at 11 | 12 | http://www.apache.org/licenses/LICENSE-2.0 13 | 14 | Unless required by applicable law or agreed to in writing, software 15 | distributed under the License is distributed on an "AS IS" BASIS, 16 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | See the License for the specific language governing permissions and 18 | limitations under the License. 19 | 20 | =============================================================================*/ 21 | 22 | #ifndef CTKAPPLICATIONRUNNABLE_H 23 | #define CTKAPPLICATIONRUNNABLE_H 24 | 25 | #include 26 | 27 | class QVariant; 28 | 29 | /** 30 | * Like a QRunnable, an object which captures a block of code which can 31 | * be passed around and executed as well as stopped. Unlike standard runnables, 32 | * paramaterized runnables allow an arbitrary QVariant to be passed in when the 33 | * block is evaluated. 34 | *

35 | * Clients may implement this interface. 36 | *

37 | */ 38 | struct CTK_PLUGINFW_EXPORT ctkApplicationRunnable 39 | { 40 | 41 | virtual ~ctkApplicationRunnable(); 42 | 43 | /** 44 | * Executes the block of code encapsulated by this runnable in the context of 45 | * the given object and returns the result. The result may be an invalid QVariant. 46 | * 47 | * @param context the context for evaluating the runnable 48 | * @return the result of evaluating the runnable in the given context 49 | * @throws std::exception if there is a problem running this runnable 50 | */ 51 | virtual QVariant run(const QVariant& context) = 0; 52 | 53 | /** 54 | * Forces this runnable to stop. 55 | */ 56 | virtual void stop() = 0; 57 | 58 | }; 59 | 60 | #endif // CTKAPPLICATIONRUNNABLE_H 61 | -------------------------------------------------------------------------------- /includes/pluginFramework/ctkBasicLocation_p.h: -------------------------------------------------------------------------------- 1 | /*============================================================================= 2 | 3 | Library: CTK 4 | 5 | Copyright (c) German Cancer Research Center, 6 | Division of Medical and Biological Informatics 7 | 8 | Licensed under the Apache License, Version 2.0 (the "License"); 9 | you may not use this file except in compliance with the License. 10 | You may obtain a copy of the License at 11 | 12 | http://www.apache.org/licenses/LICENSE-2.0 13 | 14 | Unless required by applicable law or agreed to in writing, software 15 | distributed under the License is distributed on an "AS IS" BASIS, 16 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | See the License for the specific language governing permissions and 18 | limitations under the License. 19 | 20 | =============================================================================*/ 21 | 22 | #ifndef CTKBASICLOCATION_H 23 | #define CTKBASICLOCATION_H 24 | 25 | #include 26 | 27 | #include 28 | #include 29 | #include 30 | #include 31 | 32 | class ctkBasicLocation : public QObject, public ctkLocation 33 | { 34 | Q_OBJECT 35 | Q_INTERFACES(ctkLocation) 36 | 37 | public: 38 | 39 | ctkBasicLocation(const QString& property, const QUrl& defaultValue, 40 | bool isReadOnly, const QString& dataAreaPrefix); 41 | 42 | ~ctkBasicLocation(); 43 | 44 | bool allowsDefault() const; 45 | 46 | QUrl getDefault() const; 47 | 48 | ctkLocation* getParentLocation() const; 49 | 50 | QUrl getUrl() const; 51 | 52 | bool isSet() const; 53 | 54 | bool isReadOnly() const; 55 | 56 | bool set(const QUrl& value, bool lock); 57 | 58 | bool set(const QUrl& value, bool lock, const QString& lockFilePath); 59 | 60 | bool lock(); 61 | 62 | void release(); 63 | 64 | bool isLocked() const; 65 | 66 | ctkLocation* createLocation(ctkLocation* parent, const QUrl& defaultValue, bool readonly); 67 | 68 | QUrl getDataArea(const QString& path) const; 69 | 70 | void setParent(ctkLocation* parent); 71 | 72 | struct Locker; 73 | 74 | private: 75 | 76 | struct MockLocker; 77 | class FileLocker; 78 | 79 | bool m_isReadOnly; 80 | QUrl m_location; 81 | QScopedPointer m_parent; 82 | QUrl m_defaultValue; 83 | QString m_property; 84 | QString m_dataAreaPrefix; 85 | 86 | // locking related fields 87 | QFileInfo m_lockFile; 88 | Locker* m_locker; 89 | 90 | mutable QReadWriteLock m_sync; 91 | 92 | bool isSet_unlocked() const; 93 | 94 | bool set_unlocked(const QUrl& value, bool lock); 95 | bool set_unlocked(const QUrl& value, bool lock, const QString& lockFilePath); 96 | 97 | bool lock_unlocked(const QFileInfo& lock, const QUrl& locationValue); 98 | void setLocker_unlocked(const QFileInfo& lock); 99 | Locker* createLocker_unlocked(const QFileInfo& lock, const QString& lockMode); 100 | bool isLocked_unlocked(const QFileInfo& lock) const; 101 | 102 | }; 103 | 104 | #endif // CTKBASICLOCATION_H 105 | -------------------------------------------------------------------------------- /includes/pluginFramework/ctkDictionary.h: -------------------------------------------------------------------------------- 1 | /*============================================================================= 2 | 3 | Library: CTK 4 | 5 | Copyright (c) German Cancer Research Center, 6 | Division of Medical and Biological Informatics 7 | 8 | Licensed under the Apache License, Version 2.0 (the "License"); 9 | you may not use this file except in compliance with the License. 10 | You may obtain a copy of the License at 11 | 12 | http://www.apache.org/licenses/LICENSE-2.0 13 | 14 | Unless required by applicable law or agreed to in writing, software 15 | distributed under the License is distributed on an "AS IS" BASIS, 16 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | See the License for the specific language governing permissions and 18 | limitations under the License. 19 | 20 | =============================================================================*/ 21 | 22 | 23 | #ifndef CTKDICTIONARY_H 24 | #define CTKDICTIONARY_H 25 | 26 | #include 27 | 28 | #include "ctkPluginFramework_global.h" 29 | 30 | /** 31 | * \ingroup PluginFramework 32 | * 33 | * A typedef for a QString to QVariant hash map. Typically used for service properties. 34 | * 35 | * \note This is equivalent to using ctkProperties. 36 | */ 37 | typedef QHash ctkDictionary; 38 | 39 | #endif // CTKDICTIONARY_H 40 | -------------------------------------------------------------------------------- /includes/pluginFramework/ctkLocationManager_p.h: -------------------------------------------------------------------------------- 1 | /*============================================================================= 2 | 3 | Library: CTK 4 | 5 | Copyright (c) German Cancer Research Center, 6 | Division of Medical and Biological Informatics 7 | 8 | Licensed under the Apache License, Version 2.0 (the "License"); 9 | you may not use this file except in compliance with the License. 10 | You may obtain a copy of the License at 11 | 12 | http://www.apache.org/licenses/LICENSE-2.0 13 | 14 | Unless required by applicable law or agreed to in writing, software 15 | distributed under the License is distributed on an "AS IS" BASIS, 16 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | See the License for the specific language governing permissions and 18 | limitations under the License. 19 | 20 | =============================================================================*/ 21 | 22 | #ifndef CTKLOCATIONMANAGER_H 23 | #define CTKLOCATIONMANAGER_H 24 | 25 | #include 26 | 27 | class ctkBasicLocation; 28 | 29 | /** 30 | * This class is used to manage the various Locations for BlueBerry. 31 | *

32 | * Clients may not extend this class. 33 | *

34 | * @noextend This class is not intended to be subclassed by clients. 35 | */ 36 | class ctkLocationManager 37 | { 38 | 39 | public: 40 | 41 | static const QString READ_ONLY_AREA_SUFFIX; // = ".readOnly"; 42 | 43 | // configuration area file/dir names 44 | static const QString CONFIG_FILE; // = "config.ini"; 45 | static const QString CTK_PROPERTIES; // = "ctk.properties"; 46 | 47 | /** 48 | * Initializes the QFileInfo objects for the ctkLocationManager. 49 | */ 50 | static void initializeLocations(); 51 | 52 | /** 53 | * Returns the user ctkLocation object 54 | * @return the user ctkLocation object 55 | */ 56 | static ctkBasicLocation* getUserLocation(); 57 | 58 | /** 59 | * Returns the configuration ctkLocation object 60 | * @return the configuration ctkLocation object 61 | */ 62 | static ctkBasicLocation* getConfigurationLocation(); 63 | 64 | /** 65 | * Returns the install ctkLocation object 66 | * @return the install ctkLocation object 67 | */ 68 | static ctkBasicLocation* getInstallLocation(); 69 | 70 | /** 71 | * Returns the instance ctkLocation object 72 | * @return the instance ctkLocation object 73 | */ 74 | static ctkBasicLocation* getInstanceLocation(); 75 | 76 | static ctkBasicLocation* getCTKHomeLocation(); 77 | 78 | }; 79 | 80 | #endif // CTKLOCATIONMANAGER_H 81 | -------------------------------------------------------------------------------- /includes/pluginFramework/ctkPluginArchive.cpp: -------------------------------------------------------------------------------- 1 | /*============================================================================= 2 | 3 | Library: CTK 4 | 5 | Copyright (c) German Cancer Research Center, 6 | Division of Medical and Biological Informatics 7 | 8 | Licensed under the Apache License, Version 2.0 (the "License"); 9 | you may not use this file except in compliance with the License. 10 | You may obtain a copy of the License at 11 | 12 | http://www.apache.org/licenses/LICENSE-2.0 13 | 14 | Unless required by applicable law or agreed to in writing, software 15 | distributed under the License is distributed on an "AS IS" BASIS, 16 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | See the License for the specific language governing permissions and 18 | limitations under the License. 19 | 20 | =============================================================================*/ 21 | 22 | #include "ctkPluginArchive_p.h" 23 | 24 | #include "ctkPluginException.h" 25 | #include "ctkPluginStorage_p.h" 26 | 27 | #include 28 | #include 29 | 30 | 31 | const QString ctkPluginArchive::AUTOSTART_SETTING_STOPPED("stopped"); 32 | const QString ctkPluginArchive::AUTOSTART_SETTING_EAGER("eager"); 33 | const QString ctkPluginArchive::AUTOSTART_SETTING_ACTIVATION_POLICY("activation_policy"); 34 | -------------------------------------------------------------------------------- /includes/pluginFramework/ctkPluginContext_p.h: -------------------------------------------------------------------------------- 1 | /*============================================================================= 2 | 3 | Library: CTK 4 | 5 | Copyright (c) German Cancer Research Center, 6 | Division of Medical and Biological Informatics 7 | 8 | Licensed under the Apache License, Version 2.0 (the "License"); 9 | you may not use this file except in compliance with the License. 10 | You may obtain a copy of the License at 11 | 12 | http://www.apache.org/licenses/LICENSE-2.0 13 | 14 | Unless required by applicable law or agreed to in writing, software 15 | distributed under the License is distributed on an "AS IS" BASIS, 16 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | See the License for the specific language governing permissions and 18 | limitations under the License. 19 | 20 | =============================================================================*/ 21 | 22 | #ifndef CTKPLUGINCONTEXTPRIVATE_H 23 | #define CTKPLUGINCONTEXTPRIVATE_H 24 | 25 | class ctkPluginPrivate; 26 | 27 | /** 28 | * \ingroup PluginFramework 29 | */ 30 | class ctkPluginContextPrivate 31 | { 32 | 33 | public: 34 | 35 | ctkPluginPrivate* plugin; 36 | 37 | ctkPluginContextPrivate(ctkPluginPrivate* plugin); 38 | 39 | /** 40 | * Check that the plugin is still valid. 41 | */ 42 | void isPluginContextValid() const; 43 | 44 | void invalidate(); 45 | 46 | }; 47 | 48 | #endif // CTKPLUGINCONTEXTPRIVATE_H 49 | -------------------------------------------------------------------------------- /includes/pluginFramework/ctkPluginDatabaseException.cpp: -------------------------------------------------------------------------------- 1 | /*============================================================================= 2 | 3 | Library: CTK 4 | 5 | Copyright (c) German Cancer Research Center, 6 | Division of Medical and Biological Informatics 7 | 8 | Licensed under the Apache License, Version 2.0 (the "License"); 9 | you may not use this file except in compliance with the License. 10 | You may obtain a copy of the License at 11 | 12 | http://www.apache.org/licenses/LICENSE-2.0 13 | 14 | Unless required by applicable law or agreed to in writing, software 15 | distributed under the License is distributed on an "AS IS" BASIS, 16 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | See the License for the specific language governing permissions and 18 | limitations under the License. 19 | 20 | =============================================================================*/ 21 | 22 | #include "ctkPluginDatabaseException.h" 23 | 24 | #include 25 | 26 | //---------------------------------------------------------------------------- 27 | ctkPluginDatabaseException::ctkPluginDatabaseException(const QString& msg, const Type& type) 28 | : ctkRuntimeException(msg), 29 | type(type) 30 | { 31 | 32 | } 33 | 34 | //---------------------------------------------------------------------------- 35 | ctkPluginDatabaseException::ctkPluginDatabaseException(const QString& msg, const Type& type, 36 | const ctkException& cause) 37 | : ctkRuntimeException(msg, cause), 38 | type(type) 39 | { 40 | 41 | } 42 | 43 | //---------------------------------------------------------------------------- 44 | ctkPluginDatabaseException::ctkPluginDatabaseException(const QString& msg, 45 | const ctkException& cause) 46 | : ctkRuntimeException(msg, cause), 47 | type(UNSPECIFIED) 48 | { 49 | 50 | } 51 | 52 | //---------------------------------------------------------------------------- 53 | ctkPluginDatabaseException::ctkPluginDatabaseException(const ctkPluginDatabaseException& o) 54 | : ctkRuntimeException(o), type(o.type) 55 | { 56 | 57 | } 58 | 59 | //---------------------------------------------------------------------------- 60 | ctkPluginDatabaseException& ctkPluginDatabaseException::operator=(const ctkPluginDatabaseException& o) 61 | { 62 | ctkRuntimeException::operator=(o); 63 | type = o.type; 64 | return *this; 65 | } 66 | 67 | //---------------------------------------------------------------------------- 68 | ctkPluginDatabaseException::~ctkPluginDatabaseException() throw() 69 | { 70 | 71 | } 72 | 73 | //---------------------------------------------------------------------------- 74 | const char* ctkPluginDatabaseException::name() const throw() 75 | { 76 | return "ctkPluginDatabaseException"; 77 | } 78 | 79 | //---------------------------------------------------------------------------- 80 | ctkPluginDatabaseException* ctkPluginDatabaseException::clone() const 81 | { 82 | return new ctkPluginDatabaseException(*this); 83 | } 84 | 85 | //---------------------------------------------------------------------------- 86 | void ctkPluginDatabaseException::rethrow() const 87 | { 88 | throw *this; 89 | } 90 | 91 | //---------------------------------------------------------------------------- 92 | ctkPluginDatabaseException::Type ctkPluginDatabaseException::getType() const 93 | { 94 | return type; 95 | } 96 | -------------------------------------------------------------------------------- /includes/pluginFramework/ctkPluginDatabaseException.h: -------------------------------------------------------------------------------- 1 | /*============================================================================= 2 | 3 | Library: CTK 4 | 5 | Copyright (c) German Cancer Research Center, 6 | Division of Medical and Biological Informatics 7 | 8 | Licensed under the Apache License, Version 2.0 (the "License"); 9 | you may not use this file except in compliance with the License. 10 | You may obtain a copy of the License at 11 | 12 | http://www.apache.org/licenses/LICENSE-2.0 13 | 14 | Unless required by applicable law or agreed to in writing, software 15 | distributed under the License is distributed on an "AS IS" BASIS, 16 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | See the License for the specific language governing permissions and 18 | limitations under the License. 19 | 20 | =============================================================================*/ 21 | 22 | #ifndef CTKPLUGINDATABASEEXCEPTION_H 23 | #define CTKPLUGINDATABASEEXCEPTION_H 24 | 25 | #include "ctkException.h" 26 | 27 | #include 28 | 29 | /** 30 | * \ingroup PluginFramework 31 | */ 32 | class CTK_PLUGINFW_EXPORT ctkPluginDatabaseException : public ctkRuntimeException 33 | { 34 | public: 35 | 36 | enum Type { 37 | UNSPECIFIED, 38 | DB_CONNECTION_INVALID, 39 | DB_NOT_OPEN_ERROR, 40 | DB_NOT_FOUND_ERROR, 41 | DB_CREATE_DIR_ERROR, 42 | DB_WRITE_ERROR, 43 | DB_FILE_INVALID, 44 | DB_SQL_ERROR 45 | }; 46 | 47 | ctkPluginDatabaseException(const QString& msg, const Type& type = UNSPECIFIED); 48 | ctkPluginDatabaseException(const QString& msg, const Type& type, const ctkException& cause); 49 | ctkPluginDatabaseException(const QString& msg, const ctkException& cause); 50 | 51 | ctkPluginDatabaseException(const ctkPluginDatabaseException& o); 52 | ctkPluginDatabaseException& operator=(const ctkPluginDatabaseException& o); 53 | 54 | ~ctkPluginDatabaseException() throw(); 55 | 56 | /** 57 | * @see ctkException::name() 58 | */ 59 | const char* name() const throw(); 60 | 61 | /** 62 | * @see ctkException::clone() 63 | */ 64 | ctkPluginDatabaseException* clone() const; 65 | 66 | /** 67 | * @see ctkException::rethrow() 68 | */ 69 | void rethrow() const; 70 | 71 | Type getType() const; 72 | 73 | private: 74 | 75 | Type type; 76 | 77 | }; 78 | 79 | #endif // CTKPLUGINDATABASEEXCEPTION_H 80 | -------------------------------------------------------------------------------- /includes/pluginFramework/ctkPluginException.cpp: -------------------------------------------------------------------------------- 1 | /*============================================================================= 2 | 3 | Library: CTK 4 | 5 | Copyright (c) German Cancer Research Center, 6 | Division of Medical and Biological Informatics 7 | 8 | Licensed under the Apache License, Version 2.0 (the "License"); 9 | you may not use this file except in compliance with the License. 10 | You may obtain a copy of the License at 11 | 12 | http://www.apache.org/licenses/LICENSE-2.0 13 | 14 | Unless required by applicable law or agreed to in writing, software 15 | distributed under the License is distributed on an "AS IS" BASIS, 16 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | See the License for the specific language governing permissions and 18 | limitations under the License. 19 | 20 | =============================================================================*/ 21 | 22 | #include "ctkPluginException.h" 23 | 24 | #include 25 | 26 | //---------------------------------------------------------------------------- 27 | ctkPluginException::ctkPluginException(const QString& msg, const Type& type) 28 | : ctkRuntimeException(msg), 29 | type(type) 30 | { 31 | 32 | } 33 | 34 | //---------------------------------------------------------------------------- 35 | ctkPluginException::ctkPluginException(const QString& msg, const Type& type, const ctkException& cause) 36 | : ctkRuntimeException(msg, cause), 37 | type(type) 38 | { 39 | 40 | } 41 | 42 | //---------------------------------------------------------------------------- 43 | ctkPluginException::ctkPluginException(const QString& msg, const ctkException& cause) 44 | : ctkRuntimeException(msg, cause), 45 | type(UNSPECIFIED) 46 | { 47 | 48 | } 49 | 50 | //---------------------------------------------------------------------------- 51 | ctkPluginException::ctkPluginException(const ctkPluginException& o) 52 | : ctkRuntimeException(o), type(o.type) 53 | { 54 | 55 | } 56 | 57 | //---------------------------------------------------------------------------- 58 | ctkPluginException& ctkPluginException::operator=(const ctkPluginException& o) 59 | { 60 | ctkRuntimeException::operator=(o); 61 | type = o.type; 62 | return *this; 63 | } 64 | 65 | //---------------------------------------------------------------------------- 66 | ctkPluginException::~ctkPluginException() throw() 67 | { 68 | } 69 | 70 | //---------------------------------------------------------------------------- 71 | const char* ctkPluginException::name() const throw() 72 | { 73 | return "ctkPluginException"; 74 | } 75 | 76 | //---------------------------------------------------------------------------- 77 | ctkPluginException* ctkPluginException::clone() const 78 | { 79 | return new ctkPluginException(*this); 80 | } 81 | 82 | //---------------------------------------------------------------------------- 83 | void ctkPluginException::rethrow() const 84 | { 85 | throw *this; 86 | } 87 | 88 | //---------------------------------------------------------------------------- 89 | ctkPluginException::Type ctkPluginException::getType() const 90 | { 91 | return type; 92 | } 93 | -------------------------------------------------------------------------------- /includes/pluginFramework/ctkPluginFrameworkDebug.cpp: -------------------------------------------------------------------------------- 1 | /*============================================================================= 2 | 3 | Library: CTK 4 | 5 | Copyright (c) German Cancer Research Center, 6 | Division of Medical and Biological Informatics 7 | 8 | Licensed under the Apache License, Version 2.0 (the "License"); 9 | you may not use this file except in compliance with the License. 10 | You may obtain a copy of the License at 11 | 12 | http://www.apache.org/licenses/LICENSE-2.0 13 | 14 | Unless required by applicable law or agreed to in writing, software 15 | distributed under the License is distributed on an "AS IS" BASIS, 16 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | See the License for the specific language governing permissions and 18 | limitations under the License. 19 | 20 | =============================================================================*/ 21 | 22 | 23 | #include "ctkPluginFrameworkDebug_p.h" 24 | 25 | #include "ctkPluginFrameworkDebugOptions_p.h" 26 | #include "ctkPluginFrameworkProperties_p.h" 27 | 28 | static QString CTK_OSGI = "org.commontk.pluginfw"; 29 | 30 | QString ctkPluginFrameworkDebug::OPTION_DEBUG_GENERAL = CTK_OSGI + "/debug"; 31 | QString ctkPluginFrameworkDebug::OPTION_DEBUG_FRAMEWORK = CTK_OSGI + "/debug/framework"; 32 | QString ctkPluginFrameworkDebug::OPTION_DEBUG_ERRORS = CTK_OSGI + "/debug/errors"; 33 | QString ctkPluginFrameworkDebug::OPTION_DEBUG_HOOKS = CTK_OSGI + "/debug/hooks"; 34 | QString ctkPluginFrameworkDebug::OPTION_DEBUG_LAZY_ACTIVATION = CTK_OSGI + "/debug/lazy_activation"; 35 | QString ctkPluginFrameworkDebug::OPTION_DEBUG_LDAP = CTK_OSGI + "/debug/ldap"; 36 | QString ctkPluginFrameworkDebug::OPTION_DEBUG_SERVICE_REFERENCE = CTK_OSGI + "/debug/service_reference"; 37 | QString ctkPluginFrameworkDebug::OPTION_DEBUG_STARTLEVEL = CTK_OSGI + "/debug/startlevel"; 38 | QString ctkPluginFrameworkDebug::OPTION_DEBUG_URL = CTK_OSGI + "/debug/url"; 39 | QString ctkPluginFrameworkDebug::OPTION_DEBUG_RESOLVE = CTK_OSGI + "/debug/resolve"; 40 | 41 | //---------------------------------------------------------------------------- 42 | ctkPluginFrameworkDebug::ctkPluginFrameworkDebug() 43 | { 44 | ctkPluginFrameworkDebugOptions* dbgOptions = ctkPluginFrameworkDebugOptions::getDefault(); 45 | if (dbgOptions != NULL) 46 | { 47 | enabled = dbgOptions->isDebugEnabled(); 48 | errors = dbgOptions->getBooleanOption(OPTION_DEBUG_ERRORS, false); 49 | framework = dbgOptions->getBooleanOption(OPTION_DEBUG_FRAMEWORK, false); 50 | hooks = dbgOptions->getBooleanOption(OPTION_DEBUG_HOOKS, false); 51 | lazy_activation = dbgOptions->getBooleanOption(OPTION_DEBUG_LAZY_ACTIVATION, false); 52 | ldap = dbgOptions->getBooleanOption(OPTION_DEBUG_LDAP, false); 53 | service_reference = dbgOptions->getBooleanOption(OPTION_DEBUG_SERVICE_REFERENCE, false); 54 | startlevel = dbgOptions->getBooleanOption(OPTION_DEBUG_STARTLEVEL, false); 55 | url = dbgOptions->getBooleanOption(OPTION_DEBUG_URL, false); 56 | resolve = dbgOptions->getBooleanOption(OPTION_DEBUG_RESOLVE, false); 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /includes/pluginFramework/ctkPluginFrameworkDebug_p.h: -------------------------------------------------------------------------------- 1 | /*============================================================================= 2 | 3 | Library: CTK 4 | 5 | Copyright (c) German Cancer Research Center, 6 | Division of Medical and Biological Informatics 7 | 8 | Licensed under the Apache License, Version 2.0 (the "License"); 9 | you may not use this file except in compliance with the License. 10 | You may obtain a copy of the License at 11 | 12 | http://www.apache.org/licenses/LICENSE-2.0 13 | 14 | Unless required by applicable law or agreed to in writing, software 15 | distributed under the License is distributed on an "AS IS" BASIS, 16 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | See the License for the specific language governing permissions and 18 | limitations under the License. 19 | 20 | =============================================================================*/ 21 | 22 | 23 | #ifndef CTKPLUGINFRAMEWORKDEBUG_P_H 24 | #define CTKPLUGINFRAMEWORKDEBUG_P_H 25 | 26 | #include "ctkPluginFramework_global.h" 27 | 28 | /** 29 | * Variables that control debugging of the pluginfw code. 30 | */ 31 | class ctkPluginFrameworkDebug 32 | { 33 | 34 | public: 35 | ctkPluginFrameworkDebug(); 36 | 37 | static QString OPTION_DEBUG_GENERAL; 38 | bool enabled; 39 | 40 | /** 41 | * Report error handling events. 42 | */ 43 | static QString OPTION_DEBUG_ERRORS; 44 | bool errors; 45 | 46 | /** 47 | * Report pluginfw create, init, start, stop 48 | */ 49 | static QString OPTION_DEBUG_FRAMEWORK; 50 | bool framework; 51 | 52 | /** 53 | * Report hooks handling 54 | */ 55 | static QString OPTION_DEBUG_HOOKS; 56 | bool hooks; 57 | 58 | /** 59 | * Report triggering of lazy activation 60 | */ 61 | static QString OPTION_DEBUG_LAZY_ACTIVATION; 62 | bool lazy_activation; 63 | 64 | /** 65 | * Report LDAP handling 66 | */ 67 | static QString OPTION_DEBUG_LDAP; 68 | bool ldap; 69 | 70 | /** 71 | * Print information about service reference lookups 72 | * and rejections due to missing permissions 73 | * for calling plug-ins. 74 | */ 75 | static QString OPTION_DEBUG_SERVICE_REFERENCE; 76 | bool service_reference; 77 | 78 | /** 79 | * Report startlevel. 80 | */ 81 | static QString OPTION_DEBUG_STARTLEVEL; 82 | bool startlevel; 83 | 84 | /** 85 | * Report url 86 | */ 87 | static QString OPTION_DEBUG_URL; 88 | bool url; 89 | 90 | /** 91 | * Report plug-in resolve progress 92 | */ 93 | static QString OPTION_DEBUG_RESOLVE; 94 | bool resolve; 95 | 96 | }; 97 | 98 | #endif // CTKPLUGINFRAMEWORKDEBUG_P_H 99 | -------------------------------------------------------------------------------- /includes/pluginFramework/ctkPluginFrameworkExport.h: -------------------------------------------------------------------------------- 1 | 2 | 3 | // .NAME __ctkPluginFrameworkExport - manage Windows system differences 4 | // .SECTION Description 5 | // The __ctkPluginFrameworkExport captures some system differences between Unix 6 | // and Windows operating systems. 7 | 8 | #ifndef __ctkPluginFrameworkExport_h 9 | #define __ctkPluginFrameworkExport_h 10 | 11 | #include "ctkCompilerDetections_p.h" 12 | 13 | #include 14 | 15 | #if defined(Q_OS_WIN) || defined(Q_OS_SYMBIAN) 16 | # if defined(CTKPluginFramework_EXPORTS) 17 | # define CTK_PLUGINFW_EXPORT Q_DECL_EXPORT 18 | # else 19 | # define CTK_PLUGINFW_EXPORT Q_DECL_IMPORT 20 | # endif 21 | #endif 22 | 23 | #if !defined(CTK_PLUGINFW_EXPORT) 24 | //# if defined(CTK_SHARED) 25 | # define CTK_PLUGINFW_EXPORT Q_DECL_EXPORT 26 | //# else 27 | //# define CTK_PLUGINFW_EXPORT 28 | //# endif 29 | #endif 30 | 31 | #endif 32 | 33 | -------------------------------------------------------------------------------- /includes/pluginFramework/ctkPluginFrameworkFactory.cpp: -------------------------------------------------------------------------------- 1 | /*============================================================================= 2 | 3 | Library: CTK 4 | 5 | Copyright (c) German Cancer Research Center, 6 | Division of Medical and Biological Informatics 7 | 8 | Licensed under the Apache License, Version 2.0 (the "License"); 9 | you may not use this file except in compliance with the License. 10 | You may obtain a copy of the License at 11 | 12 | http://www.apache.org/licenses/LICENSE-2.0 13 | 14 | Unless required by applicable law or agreed to in writing, software 15 | distributed under the License is distributed on an "AS IS" BASIS, 16 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | See the License for the specific language governing permissions and 18 | limitations under the License. 19 | 20 | =============================================================================*/ 21 | 22 | #include "ctkPluginFrameworkFactory.h" 23 | 24 | #include "ctkPluginFrameworkContext_p.h" 25 | #include "ctkPluginFrameworkProperties_p.h" 26 | #include "ctkLocationManager_p.h" 27 | 28 | //---------------------------------------------------------------------------- 29 | ctkPluginFrameworkFactory::ctkPluginFrameworkFactory(const ctkProperties& initProps) 30 | : fwCtx(NULL) 31 | { 32 | ctkPluginFrameworkProperties::setProperties(initProps); 33 | ctkPluginFrameworkProperties::initializeProperties(); 34 | 35 | ctkLocationManager::initializeLocations(); 36 | 37 | fwCtx = new ctkPluginFrameworkContext(); 38 | } 39 | 40 | //---------------------------------------------------------------------------- 41 | ctkPluginFrameworkFactory::~ctkPluginFrameworkFactory() 42 | { 43 | fwCtx->uninit(); 44 | delete fwCtx; 45 | } 46 | 47 | //---------------------------------------------------------------------------- 48 | QSharedPointer ctkPluginFrameworkFactory::getFramework() 49 | { 50 | return fwCtx->systemPlugin; 51 | } 52 | -------------------------------------------------------------------------------- /includes/pluginFramework/ctkPluginFrameworkFactory.h: -------------------------------------------------------------------------------- 1 | /*============================================================================= 2 | 3 | Library: CTK 4 | 5 | Copyright (c) German Cancer Research Center, 6 | Division of Medical and Biological Informatics 7 | 8 | Licensed under the Apache License, Version 2.0 (the "License"); 9 | you may not use this file except in compliance with the License. 10 | You may obtain a copy of the License at 11 | 12 | http://www.apache.org/licenses/LICENSE-2.0 13 | 14 | Unless required by applicable law or agreed to in writing, software 15 | distributed under the License is distributed on an "AS IS" BASIS, 16 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | See the License for the specific language governing permissions and 18 | limitations under the License. 19 | 20 | =============================================================================*/ 21 | 22 | #ifndef CTKPLUGINFRAMEWORKFACTORY_H 23 | #define CTKPLUGINFRAMEWORKFACTORY_H 24 | 25 | #include 26 | #include 27 | #include 28 | #include 29 | 30 | #include "ctkPluginFrameworkExport.h" 31 | 32 | #include "ctkPluginFramework_global.h" 33 | 34 | class ctkPluginFramework; 35 | class ctkPluginFrameworkContext; 36 | 37 | /** 38 | * \ingroup PluginFramework 39 | * A factory for creating ctkPluginFramework instances. 40 | */ 41 | class CTK_PLUGINFW_EXPORT ctkPluginFrameworkFactory 42 | { 43 | 44 | public: 45 | 46 | /** 47 | * Create a new %ctkPluginFrameworkFactory instance. 48 | * 49 | *

50 | * The ctkProperties map is used to configure the ctkPluginFramework. The 51 | * plugin framework instance created with #getFramework() must interpret 52 | * the following properties: 53 | * 54 | *

55 | *

  • ctkPluginConstants::FRAMEWORK_STORAGE
  • 56 | *
57 | * 58 | * @param initProps The plugin framework configuration properties. 59 | * The ctkPluginFramework instance created with #getFramework() 60 | * must use some reasonable default configuration if certain 61 | * properties are not provided. 62 | */ 63 | ctkPluginFrameworkFactory(const ctkProperties& initProps = ctkProperties()); 64 | 65 | ~ctkPluginFrameworkFactory(); 66 | 67 | /** 68 | * Create a new ctkPluginFramework instance. 69 | * 70 | * @return A new, configured ctkPluginFramework instance. The plugin 71 | * framework instance must be in the ctkPlugin::INSTALLED state. 72 | */ 73 | QSharedPointer getFramework(); 74 | 75 | private: 76 | 77 | ctkPluginFrameworkContext* fwCtx; 78 | 79 | }; 80 | 81 | 82 | #endif // CTKPLUGINFRAMEWORKFACTORY_H 83 | -------------------------------------------------------------------------------- /includes/pluginFramework/ctkPluginFrameworkProperties.cpp: -------------------------------------------------------------------------------- 1 | /*============================================================================= 2 | 3 | Library: CTK 4 | 5 | Copyright (c) German Cancer Research Center, 6 | Division of Medical and Biological Informatics 7 | 8 | Licensed under the Apache License, Version 2.0 (the "License"); 9 | you may not use this file except in compliance with the License. 10 | You may obtain a copy of the License at 11 | 12 | http://www.apache.org/licenses/LICENSE-2.0 13 | 14 | Unless required by applicable law or agreed to in writing, software 15 | distributed under the License is distributed on an "AS IS" BASIS, 16 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | See the License for the specific language governing permissions and 18 | limitations under the License. 19 | 20 | =============================================================================*/ 21 | 22 | #include "ctkPluginFrameworkProperties_p.h" 23 | 24 | #include "ctkPluginFrameworkLauncher.h" 25 | 26 | #include 27 | #include 28 | 29 | QMutex ctkPluginFrameworkProperties::lock; 30 | ctkProperties ctkPluginFrameworkProperties::properties; 31 | 32 | //---------------------------------------------------------------------------- 33 | ctkProperties& ctkPluginFrameworkProperties::getProperties() 34 | { 35 | return properties; 36 | } 37 | 38 | //---------------------------------------------------------------------------- 39 | QVariant ctkPluginFrameworkProperties::getProperty(const QString& key) 40 | { 41 | return getProperty(key, QVariant()); 42 | } 43 | 44 | //---------------------------------------------------------------------------- 45 | QVariant ctkPluginFrameworkProperties::getProperty(const QString& key, const QVariant& defaultValue) 46 | { 47 | QMutexLocker l(&lock); 48 | ctkProperties::iterator iter = properties.find(key); 49 | if (iter != properties.end()) return iter.value(); 50 | return defaultValue; 51 | } 52 | 53 | //---------------------------------------------------------------------------- 54 | QVariant ctkPluginFrameworkProperties::setProperty(const QString& key, const QVariant& value) 55 | { 56 | QMutexLocker l(&lock); 57 | QVariant oldVal = properties[key]; 58 | properties[key] = value; 59 | return oldVal; 60 | } 61 | 62 | //---------------------------------------------------------------------------- 63 | QVariant ctkPluginFrameworkProperties::clearProperty(const QString& key) 64 | { 65 | QMutexLocker l(&lock); 66 | return properties.take(key); 67 | } 68 | 69 | //---------------------------------------------------------------------------- 70 | void ctkPluginFrameworkProperties::setProperties(const ctkProperties& input) 71 | { 72 | QMutexLocker l(&lock); 73 | properties = input; 74 | } 75 | 76 | //---------------------------------------------------------------------------- 77 | void ctkPluginFrameworkProperties::initializeProperties() 78 | { 79 | // initialize some framework properties that must always be set 80 | 81 | setProperty(ctkPluginFrameworkLauncher::PROP_USER_HOME, QDir::homePath()); 82 | setProperty(ctkPluginFrameworkLauncher::PROP_USER_DIR, QDir::currentPath()); 83 | 84 | if (getProperty(ctkPluginFrameworkLauncher::PROP_INSTALL_AREA).isNull()) 85 | { 86 | setProperty(ctkPluginFrameworkLauncher::PROP_INSTALL_AREA, QCoreApplication::applicationDirPath()); 87 | } 88 | } 89 | -------------------------------------------------------------------------------- /includes/pluginFramework/ctkPluginFrameworkProperties_p.h: -------------------------------------------------------------------------------- 1 | /*============================================================================= 2 | 3 | Library: CTK 4 | 5 | Copyright (c) German Cancer Research Center, 6 | Division of Medical and Biological Informatics 7 | 8 | Licensed under the Apache License, Version 2.0 (the "License"); 9 | you may not use this file except in compliance with the License. 10 | You may obtain a copy of the License at 11 | 12 | http://www.apache.org/licenses/LICENSE-2.0 13 | 14 | Unless required by applicable law or agreed to in writing, software 15 | distributed under the License is distributed on an "AS IS" BASIS, 16 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | See the License for the specific language governing permissions and 18 | limitations under the License. 19 | 20 | =============================================================================*/ 21 | 22 | #ifndef CTKPLUGINFRAMEWORKPROPERTIES_H 23 | #define CTKPLUGINFRAMEWORKPROPERTIES_H 24 | 25 | #include 26 | 27 | #include 28 | #include 29 | 30 | class ctkPluginFrameworkProperties 31 | { 32 | 33 | private: 34 | 35 | static QMutex lock; 36 | 37 | /**@GuardedBy lock*/ 38 | static ctkProperties properties; 39 | 40 | public: 41 | 42 | static ctkProperties& getProperties(); 43 | 44 | static QVariant getProperty(const QString& key); 45 | 46 | static QVariant getProperty(const QString& key, const QVariant& defaultValue); 47 | 48 | static QVariant setProperty(const QString& key, const QVariant& value); 49 | 50 | static QVariant clearProperty(const QString& key); 51 | 52 | static void setProperties(const ctkProperties& input); 53 | 54 | static void initializeProperties(); 55 | 56 | }; 57 | 58 | #endif // CTKPLUGINFRAMEWORKPROPERTIES_H 59 | -------------------------------------------------------------------------------- /includes/pluginFramework/ctkPluginFrameworkUtil_p.h: -------------------------------------------------------------------------------- 1 | /*============================================================================= 2 | 3 | Library: CTK 4 | 5 | Copyright (c) German Cancer Research Center, 6 | Division of Medical and Biological Informatics 7 | 8 | Licensed under the Apache License, Version 2.0 (the "License"); 9 | you may not use this file except in compliance with the License. 10 | You may obtain a copy of the License at 11 | 12 | http://www.apache.org/licenses/LICENSE-2.0 13 | 14 | Unless required by applicable law or agreed to in writing, software 15 | distributed under the License is distributed on an "AS IS" BASIS, 16 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | See the License for the specific language governing permissions and 18 | limitations under the License. 19 | 20 | =============================================================================*/ 21 | 22 | #ifndef CTKPLUGINFRAMEWORKUTIL_P_H 23 | #define CTKPLUGINFRAMEWORKUTIL_P_H 24 | 25 | #include 26 | #include 27 | #include 28 | 29 | class ctkPluginFrameworkContext; 30 | 31 | /** 32 | * \ingroup PluginFramework 33 | */ 34 | class ctkPluginFrameworkUtil 35 | { 36 | public: 37 | 38 | /** 39 | * Parse strings of format: 40 | * 41 | * ENTRY (, ENTRY)* 42 | * ENTRY = key (; key)* (; PARAM)* 43 | * PARAM = attribute '=' value 44 | * PARAM = directive ':=' value 45 | * 46 | * @param a Attribute being parsed 47 | * @param s String to parse 48 | * @param single If true, only allow one key per ENTRY 49 | * @param unique Only allow unique parameters for each ENTRY. 50 | * @param single_entry If true, only allow one ENTRY is allowed. 51 | * @return QMap mapping attributes to values. 52 | * @exception ctkInvalidArgumentException If syntax error in input string. 53 | */ 54 | static QList > parseEntries(const QString& a, const QString& s, 55 | bool single, bool unique, bool single_entry); 56 | 57 | static QString getFrameworkDir(ctkPluginFrameworkContext* ctx); 58 | 59 | /** 60 | * Check for local file storage directory. 61 | * 62 | * @param name local directory name. 63 | * @return A QDir object pointing to the directory. The directory is 64 | * guaranteed to exist. 65 | * @throws ctkRuntimeException if there is no global framework storage 66 | * directory or if the directory could not be created. 67 | */ 68 | static QDir getFileStorage(ctkPluginFrameworkContext* ctx, const QString& name); 69 | 70 | /** 71 | * Check wildcard filter matches the string 72 | */ 73 | static bool filterMatch(const QString& filter, const QString& s); 74 | 75 | private: 76 | 77 | /** 78 | * 79 | */ 80 | static bool patSubstr(const QString& s, int si, const QString& pat, int pi); 81 | 82 | }; 83 | 84 | #include 85 | class ctkPlugin; 86 | 87 | bool pluginIdLessThan(const QSharedPointer& p1, const QSharedPointer& p2); 88 | 89 | #endif // CTKPLUGINFRAMEWORKUTIL_P_H 90 | -------------------------------------------------------------------------------- /includes/pluginFramework/ctkPluginFramework_global.h: -------------------------------------------------------------------------------- 1 | /*============================================================================= 2 | 3 | Library: CTK 4 | 5 | Copyright (c) German Cancer Research Center, 6 | Division of Medical and Biological Informatics 7 | 8 | Licensed under the Apache License, Version 2.0 (the "License"); 9 | you may not use this file except in compliance with the License. 10 | You may obtain a copy of the License at 11 | 12 | http://www.apache.org/licenses/LICENSE-2.0 13 | 14 | Unless required by applicable law or agreed to in writing, software 15 | distributed under the License is distributed on an "AS IS" BASIS, 16 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | See the License for the specific language governing permissions and 18 | limitations under the License. 19 | 20 | =============================================================================*/ 21 | 22 | 23 | #ifndef CTKPLUGINFRAMEWORK_GLOBAL_H 24 | #define CTKPLUGINFRAMEWORK_GLOBAL_H 25 | 26 | #include 27 | #include 28 | #include 29 | 30 | /** 31 | * \ingroup PluginFramework 32 | * @{ 33 | */ 34 | typedef QHash ctkProperties; 35 | typedef ctkProperties ctkDictionary; 36 | 37 | #if QT_VERSION < 0x040700 38 | #include 39 | template 40 | inline uint qHash(const QSharedPointer& ptr) 41 | { 42 | return qHash(ptr.data()); 43 | } 44 | #endif 45 | 46 | //---------------------------------------------------------------------------- 47 | template 48 | QStringList getIIDs() 49 | { 50 | return QStringList(qobject_interface_iid()); 51 | } 52 | 53 | //---------------------------------------------------------------------------- 54 | template 55 | QStringList getIIDs() 56 | { 57 | QStringList ids; 58 | ids << qobject_interface_iid(); 59 | ids << qobject_interface_iid(); 60 | return ids; 61 | } 62 | 63 | //---------------------------------------------------------------------------- 64 | template 65 | QStringList getIIDs() 66 | { 67 | QStringList ids; 68 | ids << qobject_interface_iid(); 69 | ids << qobject_interface_iid(); 70 | ids << qobject_interface_iid(); 71 | return ids; 72 | } 73 | 74 | //---------------------------------------------------------------------------- 75 | template 76 | QStringList getIIDs() 77 | { 78 | QStringList ids; 79 | ids << qobject_interface_iid(); 80 | ids << qobject_interface_iid(); 81 | ids << qobject_interface_iid(); 82 | ids << qobject_interface_iid(); 83 | return ids; 84 | } 85 | 86 | /** @}*/ 87 | 88 | #endif // CTKPLUGINFRAMEWORK_GLOBAL_H 89 | -------------------------------------------------------------------------------- /includes/pluginFramework/ctkPluginLocalization.h: -------------------------------------------------------------------------------- 1 | /*============================================================================= 2 | 3 | Library: CTK 4 | 5 | Copyright (c) German Cancer Research Center, 6 | Division of Medical and Biological Informatics 7 | 8 | Licensed under the Apache License, Version 2.0 (the "License"); 9 | you may not use this file except in compliance with the License. 10 | You may obtain a copy of the License at 11 | 12 | http://www.apache.org/licenses/LICENSE-2.0 13 | 14 | Unless required by applicable law or agreed to in writing, software 15 | distributed under the License is distributed on an "AS IS" BASIS, 16 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | See the License for the specific language governing permissions and 18 | limitations under the License. 19 | 20 | =============================================================================*/ 21 | 22 | 23 | #ifndef CTKPLUGINLOCALIZATION_H 24 | #define CTKPLUGINLOCALIZATION_H 25 | 26 | #include 27 | 28 | #include 29 | #include 30 | #include 31 | 32 | class ctkPlugin; 33 | struct ctkPluginLocalizationData; 34 | 35 | /** 36 | * \ingroup PluginFramework 37 | * 38 | * Translate text into different languages. 39 | * 40 | * Use this class to dynamically translate human-readable text 41 | * in your plugin. You can get an instance of this class 42 | * corresponding to a specific locale via the method 43 | * ctkPlugin::getPluginLocalization(). 44 | * 45 | * @see ctkPlugin::getPluginLocalization() 46 | */ 47 | class CTK_PLUGINFW_EXPORT ctkPluginLocalization 48 | { 49 | public: 50 | 51 | /** 52 | * Creates a default ctkPluginLocalization instance, using 53 | * the default locale. 54 | * 55 | * Note that getLocalized() will always return a null QString 56 | * for a default constructed ctkPluginLocalization object. 57 | * Use ctkPlugin::getPluginLocalization() to create 58 | * a valid instance. 59 | */ 60 | ctkPluginLocalization(); 61 | 62 | ctkPluginLocalization(const ctkPluginLocalization& pl); 63 | ~ctkPluginLocalization(); 64 | 65 | ctkPluginLocalization& operator=(const ctkPluginLocalization& other); 66 | 67 | /** 68 | * Translate str to a specific locale, using the 69 | * specified context. 70 | * 71 | * @return The translation or a null QString, if no translation 72 | * was found. 73 | */ 74 | QString getLocalized(const QString& context, const QString& str) const; 75 | 76 | /** 77 | * Get the locale for which this ctkPluginLocalization 78 | * object was constructed. 79 | * 80 | * @return The locale for this object. 81 | */ 82 | QLocale getLocale() const; 83 | 84 | private: 85 | 86 | friend class ctkPlugin; 87 | 88 | ctkPluginLocalization(const QString& msgFileName, 89 | const QLocale& locale, const QSharedPointer& plugin); 90 | 91 | mutable QSharedDataPointer d; 92 | }; 93 | 94 | #endif // CTKPLUGINLOCALIZATION_H 95 | -------------------------------------------------------------------------------- /includes/pluginFramework/ctkPluginManifest_p.h: -------------------------------------------------------------------------------- 1 | /*============================================================================= 2 | 3 | Library: CTK 4 | 5 | Copyright (c) German Cancer Research Center, 6 | Division of Medical and Biological Informatics 7 | 8 | Licensed under the Apache License, Version 2.0 (the "License"); 9 | you may not use this file except in compliance with the License. 10 | You may obtain a copy of the License at 11 | 12 | http://www.apache.org/licenses/LICENSE-2.0 13 | 14 | Unless required by applicable law or agreed to in writing, software 15 | distributed under the License is distributed on an "AS IS" BASIS, 16 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | See the License for the specific language governing permissions and 18 | limitations under the License. 19 | 20 | =============================================================================*/ 21 | 22 | #ifndef CTKPLUGINMANIFEST_P_H 23 | #define CTKPLUGINMANIFEST_P_H 24 | 25 | #include 26 | #include 27 | 28 | class QIODevice; 29 | 30 | /** 31 | * \ingroup PluginFramework 32 | */ 33 | class ctkPluginManifest 34 | { 35 | 36 | public: 37 | 38 | typedef QHash Attributes; 39 | 40 | ctkPluginManifest(); 41 | ctkPluginManifest(const QByteArray& in); 42 | 43 | void read(const QByteArray& in); 44 | 45 | Attributes getMainAttributes() const; 46 | QString getAttribute(const QString& key) const; 47 | Attributes getAttributes(const QString& section) const; 48 | 49 | QStringList getSections() const; 50 | 51 | private: 52 | 53 | Attributes mainAttributes; 54 | QHash sections; 55 | 56 | }; 57 | 58 | 59 | #endif // CTKPLUGINMANIFEST_P_H 60 | -------------------------------------------------------------------------------- /includes/pluginFramework/ctkPluginTracker_p.h: -------------------------------------------------------------------------------- 1 | /*============================================================================= 2 | 3 | Library: CTK 4 | 5 | Copyright (c) German Cancer Research Center, 6 | Division of Medical and Biological Informatics 7 | 8 | Licensed under the Apache License, Version 2.0 (the "License"); 9 | you may not use this file except in compliance with the License. 10 | You may obtain a copy of the License at 11 | 12 | http://www.apache.org/licenses/LICENSE-2.0 13 | 14 | Unless required by applicable law or agreed to in writing, software 15 | distributed under the License is distributed on an "AS IS" BASIS, 16 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | See the License for the specific language governing permissions and 18 | limitations under the License. 19 | 20 | =============================================================================*/ 21 | 22 | 23 | #ifndef CTKPLUGINTRACKERPRIVATE_H 24 | #define CTKPLUGINTRACKERPRIVATE_H 25 | 26 | #include "ctkPlugin.h" 27 | 28 | #include 29 | #include 30 | 31 | /** 32 | * \ingroup PluginFramework 33 | */ 34 | template 35 | class ctkPluginTrackerPrivate 36 | { 37 | public: 38 | ctkPluginTrackerPrivate(ctkPluginTracker* pt, 39 | ctkPluginContext* context, ctkPlugin::States stateMask, 40 | ctkPluginTrackerCustomizer* customizer); 41 | 42 | ~ctkPluginTrackerPrivate(); 43 | 44 | /** 45 | * Accessor method for the current ctkTrackedPlugin object. This method is only 46 | * intended to be used by the unsynchronized methods which do not modify the 47 | * trackedPlugin field. 48 | * 49 | * @return The current ctkTrackedPlugin object. 50 | */ 51 | QSharedPointer > tracked() const; 52 | 53 | /* set this to true to compile in debug messages */ 54 | static const bool DEBUG_FLAG; // = false; 55 | 56 | /** 57 | * The Bundle Context used by this ctkPluginTracker. 58 | */ 59 | ctkPluginContext* const context; 60 | 61 | /** 62 | * The ctkPluginTrackerCustomizer object for this tracker. 63 | */ 64 | ctkPluginTrackerCustomizer* customizer; 65 | 66 | /** 67 | * Tracked plugins: ctkPlugin object -> customized Object and 68 | * plugin listener slot. 69 | */ 70 | QSharedPointer > trackedPlugin; 71 | 72 | /** 73 | * State mask for plugins being tracked. This field contains the ORed values 74 | * of the plugin states being tracked. 75 | */ 76 | ctkPlugin::States mask; 77 | 78 | mutable QMutex mutex; 79 | 80 | private: 81 | 82 | inline ctkPluginTracker* q_func() 83 | { 84 | return static_cast *>(q_ptr); 85 | } 86 | 87 | inline const ctkPluginTracker* q_func() const 88 | { 89 | return static_cast *>(q_ptr); 90 | } 91 | 92 | friend class ctkPluginTracker; 93 | 94 | ctkPluginTracker * const q_ptr; 95 | }; 96 | 97 | #include "ctkPluginTracker_p.tpp" 98 | 99 | #endif // CTKPLUGINTRACKERPRIVATE_H 100 | -------------------------------------------------------------------------------- /includes/pluginFramework/ctkPluginTracker_p.tpp: -------------------------------------------------------------------------------- 1 | /*============================================================================= 2 | 3 | Library: CTK 4 | 5 | Copyright (c) German Cancer Research Center, 6 | Division of Medical and Biological Informatics 7 | 8 | Licensed under the Apache License, Version 2.0 (the "License"); 9 | you may not use this file except in compliance with the License. 10 | You may obtain a copy of the License at 11 | 12 | http://www.apache.org/licenses/LICENSE-2.0 13 | 14 | Unless required by applicable law or agreed to in writing, software 15 | distributed under the License is distributed on an "AS IS" BASIS, 16 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | See the License for the specific language governing permissions and 18 | limitations under the License. 19 | 20 | =============================================================================*/ 21 | 22 | 23 | #include "ctkTrackedPlugin_p.h" 24 | 25 | //---------------------------------------------------------------------------- 26 | template 27 | const bool ctkPluginTrackerPrivate::DEBUG_FLAG = false; 28 | 29 | //---------------------------------------------------------------------------- 30 | template 31 | ctkPluginTrackerPrivate::ctkPluginTrackerPrivate( 32 | ctkPluginTracker* pt, ctkPluginContext* context, 33 | ctkPlugin::States stateMask, ctkPluginTrackerCustomizer* customizer) 34 | : context(context), customizer(customizer), mask(stateMask), q_ptr(pt) 35 | { 36 | this->customizer = customizer ? customizer : q_func(); 37 | } 38 | 39 | //---------------------------------------------------------------------------- 40 | template 41 | ctkPluginTrackerPrivate::~ctkPluginTrackerPrivate() 42 | { 43 | if (customizer != q_func()) 44 | { 45 | delete customizer; 46 | } 47 | } 48 | 49 | //---------------------------------------------------------------------------- 50 | template 51 | QSharedPointer > ctkPluginTrackerPrivate::tracked() const 52 | { 53 | return trackedPlugin; 54 | } 55 | -------------------------------------------------------------------------------- /includes/pluginFramework/ctkRequirePlugin.cpp: -------------------------------------------------------------------------------- 1 | /*============================================================================= 2 | 3 | Library: CTK 4 | 5 | Copyright (c) German Cancer Research Center, 6 | Division of Medical and Biological Informatics 7 | 8 | Licensed under the Apache License, Version 2.0 (the "License"); 9 | you may not use this file except in compliance with the License. 10 | You may obtain a copy of the License at 11 | 12 | http://www.apache.org/licenses/LICENSE-2.0 13 | 14 | Unless required by applicable law or agreed to in writing, software 15 | distributed under the License is distributed on an "AS IS" BASIS, 16 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | See the License for the specific language governing permissions and 18 | limitations under the License. 19 | 20 | =============================================================================*/ 21 | 22 | #include "ctkPlugin_p.h" 23 | #include "ctkPluginConstants.h" 24 | #include "ctkRequirePlugin_p.h" 25 | 26 | //---------------------------------------------------------------------------- 27 | ctkRequirePlugin::ctkRequirePlugin(ctkPluginPrivate* requestor, 28 | const QString& name, const QString& res, 29 | const QString& range) 30 | : name(name), 31 | resolution(res.isEmpty() ? ctkPluginConstants::RESOLUTION_MANDATORY : res), 32 | pluginRange(range.isEmpty() ? ctkVersionRange::defaultVersionRange() : range) 33 | { 34 | 35 | if (resolution != ctkPluginConstants::RESOLUTION_MANDATORY && 36 | resolution != ctkPluginConstants::RESOLUTION_OPTIONAL ) 37 | { 38 | QString what = QString("Invalid directive : '") 39 | + ctkPluginConstants::RESOLUTION_DIRECTIVE + ":=" + this->resolution 40 | + "' in manifest header '" 41 | + ctkPluginConstants::REQUIRE_PLUGIN + ": " + this->name 42 | + "' of plugin with id " + requestor->id 43 | + " (" + requestor->symbolicName + ")" 44 | + ". The value must be either '" 45 | + ctkPluginConstants::RESOLUTION_MANDATORY + "' or '" 46 | + ctkPluginConstants::RESOLUTION_OPTIONAL + "'."; 47 | throw ctkInvalidArgumentException(what); 48 | } 49 | 50 | 51 | } 52 | 53 | //---------------------------------------------------------------------------- 54 | bool ctkRequirePlugin::overlap(const ctkRequirePlugin& rp) const 55 | { 56 | if (resolution == ctkPluginConstants::RESOLUTION_MANDATORY && 57 | rp.resolution != ctkPluginConstants::RESOLUTION_MANDATORY) 58 | { 59 | return false; 60 | } 61 | return pluginRange.withinRange(rp.pluginRange); 62 | 63 | } 64 | -------------------------------------------------------------------------------- /includes/pluginFramework/ctkRequirePlugin_p.h: -------------------------------------------------------------------------------- 1 | /*============================================================================= 2 | 3 | Library: CTK 4 | 5 | Copyright (c) German Cancer Research Center, 6 | Division of Medical and Biological Informatics 7 | 8 | Licensed under the Apache License, Version 2.0 (the "License"); 9 | you may not use this file except in compliance with the License. 10 | You may obtain a copy of the License at 11 | 12 | http://www.apache.org/licenses/LICENSE-2.0 13 | 14 | Unless required by applicable law or agreed to in writing, software 15 | distributed under the License is distributed on an "AS IS" BASIS, 16 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | See the License for the specific language governing permissions and 18 | limitations under the License. 19 | 20 | =============================================================================*/ 21 | 22 | #ifndef CTKREQUIREPLUGIN_P_H 23 | #define CTKREQUIREPLUGIN_P_H 24 | 25 | #include 26 | 27 | 28 | class ctkPluginPrivate; 29 | 30 | /** 31 | * \ingroup PluginFramework 32 | */ 33 | class ctkRequirePlugin 34 | { 35 | 36 | public: 37 | 38 | const QString name; 39 | const QString resolution; 40 | const ctkVersionRange pluginRange; 41 | 42 | ctkRequirePlugin(ctkPluginPrivate* requestor, 43 | const QString& name, const QString& res, 44 | const QString& range); 45 | 46 | bool overlap(const ctkRequirePlugin& rp) const; 47 | 48 | }; 49 | 50 | 51 | #endif // CTKREQUIREPLUGIN_P_H 52 | -------------------------------------------------------------------------------- /includes/pluginFramework/ctkServiceException.cpp: -------------------------------------------------------------------------------- 1 | /*============================================================================= 2 | 3 | Library: CTK 4 | 5 | Copyright (c) German Cancer Research Center, 6 | Division of Medical and Biological Informatics 7 | 8 | Licensed under the Apache License, Version 2.0 (the "License"); 9 | you may not use this file except in compliance with the License. 10 | You may obtain a copy of the License at 11 | 12 | http://www.apache.org/licenses/LICENSE-2.0 13 | 14 | Unless required by applicable law or agreed to in writing, software 15 | distributed under the License is distributed on an "AS IS" BASIS, 16 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | See the License for the specific language governing permissions and 18 | limitations under the License. 19 | 20 | =============================================================================*/ 21 | 22 | #include "ctkServiceException.h" 23 | 24 | #include 25 | 26 | //---------------------------------------------------------------------------- 27 | ctkServiceException::ctkServiceException(const QString& msg, const Type& type) 28 | : ctkRuntimeException(msg), 29 | type(type) 30 | { 31 | 32 | } 33 | 34 | //---------------------------------------------------------------------------- 35 | ctkServiceException::ctkServiceException(const QString& msg, const Type& type, 36 | const ctkException& cause) 37 | : ctkRuntimeException(msg, cause), 38 | type(type) 39 | { 40 | 41 | } 42 | 43 | //---------------------------------------------------------------------------- 44 | ctkServiceException::ctkServiceException(const QString& msg, const ctkException& cause) 45 | : ctkRuntimeException(msg, cause), 46 | type(UNSPECIFIED) 47 | { 48 | 49 | } 50 | 51 | //---------------------------------------------------------------------------- 52 | ctkServiceException::ctkServiceException(const ctkServiceException& o) 53 | : ctkRuntimeException(o), type(o.type) 54 | { 55 | 56 | } 57 | 58 | //---------------------------------------------------------------------------- 59 | ctkServiceException& ctkServiceException::operator=(const ctkServiceException& o) 60 | { 61 | ctkRuntimeException::operator=(o); 62 | type = o.type; 63 | return *this; 64 | } 65 | 66 | //---------------------------------------------------------------------------- 67 | ctkServiceException::~ctkServiceException() throw() 68 | { 69 | 70 | } 71 | 72 | //---------------------------------------------------------------------------- 73 | const char* ctkServiceException::name() const throw() 74 | { 75 | return "ctkServiceException"; 76 | } 77 | 78 | //---------------------------------------------------------------------------- 79 | ctkServiceException* ctkServiceException::clone() const 80 | { 81 | return new ctkServiceException(*this); 82 | } 83 | 84 | //---------------------------------------------------------------------------- 85 | void ctkServiceException::rethrow() const 86 | { 87 | throw *this; 88 | } 89 | 90 | //---------------------------------------------------------------------------- 91 | ctkServiceException::Type ctkServiceException::getType() const 92 | { 93 | return type; 94 | } 95 | 96 | -------------------------------------------------------------------------------- /includes/pluginFramework/ctkServiceProperties.cpp: -------------------------------------------------------------------------------- 1 | /*============================================================================= 2 | 3 | Library: CTK 4 | 5 | Copyright (c) German Cancer Research Center, 6 | Division of Medical and Biological Informatics 7 | 8 | Licensed under the Apache License, Version 2.0 (the "License"); 9 | you may not use this file except in compliance with the License. 10 | You may obtain a copy of the License at 11 | 12 | http://www.apache.org/licenses/LICENSE-2.0 13 | 14 | Unless required by applicable law or agreed to in writing, software 15 | distributed under the License is distributed on an "AS IS" BASIS, 16 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | See the License for the specific language governing permissions and 18 | limitations under the License. 19 | 20 | =============================================================================*/ 21 | 22 | #include "ctkServiceProperties_p.h" 23 | 24 | #include 25 | 26 | //---------------------------------------------------------------------------- 27 | ctkServiceProperties::ctkServiceProperties(const ctkProperties& props) 28 | { 29 | for(ctkProperties::ConstIterator i = props.begin(), end = props.end(); 30 | i != end; ++i) 31 | { 32 | if (find(i.key()) != -1) 33 | { 34 | QString msg("ctkProperties object contains case variants of the key: "); 35 | msg += i.key(); 36 | throw ctkInvalidArgumentException(msg); 37 | } 38 | ks.append(i.key()); 39 | vs.append(i.value()); 40 | } 41 | } 42 | 43 | //---------------------------------------------------------------------------- 44 | QVariant ctkServiceProperties::value(const QString &key) const 45 | { 46 | int index = find(key); 47 | if (index < 0) return QVariant(); 48 | return vs[index]; 49 | } 50 | 51 | //---------------------------------------------------------------------------- 52 | QVariant ctkServiceProperties::value(int index) const 53 | { 54 | return (index < 0 || index >= vs.size()) ? QVariant() : vs[index]; 55 | } 56 | 57 | //---------------------------------------------------------------------------- 58 | QStringList ctkServiceProperties::keys() const 59 | { 60 | QStringList result; 61 | for(int i = 0; i < ks.size(); ++i) 62 | { 63 | result.append(ks[i]); 64 | } 65 | return result; 66 | } 67 | 68 | //---------------------------------------------------------------------------- 69 | int ctkServiceProperties::find(const QString &key) const 70 | { 71 | for (int i = 0; i < ks.size(); ++i) 72 | { 73 | if (ks[i].compare(key, Qt::CaseInsensitive) == 0) 74 | return i; 75 | } 76 | return -1; 77 | } 78 | 79 | //---------------------------------------------------------------------------- 80 | int ctkServiceProperties::findCaseSensitive(const QString &key) const 81 | { 82 | for (int i = 0; i < ks.size(); ++i) 83 | { 84 | if (ks[i] == key) 85 | return i; 86 | } 87 | return -1; 88 | } 89 | -------------------------------------------------------------------------------- /includes/pluginFramework/ctkServiceProperties_p.h: -------------------------------------------------------------------------------- 1 | /*============================================================================= 2 | 3 | Library: CTK 4 | 5 | Copyright (c) German Cancer Research Center, 6 | Division of Medical and Biological Informatics 7 | 8 | Licensed under the Apache License, Version 2.0 (the "License"); 9 | you may not use this file except in compliance with the License. 10 | You may obtain a copy of the License at 11 | 12 | http://www.apache.org/licenses/LICENSE-2.0 13 | 14 | Unless required by applicable law or agreed to in writing, software 15 | distributed under the License is distributed on an "AS IS" BASIS, 16 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | See the License for the specific language governing permissions and 18 | limitations under the License. 19 | 20 | =============================================================================*/ 21 | 22 | #ifndef CTKSERVICEPROPERTIES_P_H 23 | #define CTKSERVICEPROPERTIES_P_H 24 | 25 | #include 26 | #include 27 | 28 | #include "ctkPluginFramework_global.h" 29 | 30 | class ctkServiceProperties 31 | { 32 | 33 | private: 34 | 35 | QVarLengthArray ks; 36 | QVarLengthArray vs; 37 | 38 | QMap map; 39 | 40 | public: 41 | 42 | ctkServiceProperties(const ctkProperties& props); 43 | 44 | QVariant value(const QString& key) const; 45 | QVariant value(int index) const; 46 | 47 | int find(const QString& key) const; 48 | int findCaseSensitive(const QString& key) const; 49 | 50 | QStringList keys() const; 51 | 52 | }; 53 | 54 | #endif // CTKSERVICEPROPERTIES_P_H 55 | -------------------------------------------------------------------------------- /includes/pluginFramework/ctkServiceRegistration_p.cpp: -------------------------------------------------------------------------------- 1 | /*============================================================================= 2 | 3 | Library: CTK 4 | 5 | Copyright (c) German Cancer Research Center, 6 | Division of Medical and Biological Informatics 7 | 8 | Licensed under the Apache License, Version 2.0 (the "License"); 9 | you may not use this file except in compliance with the License. 10 | You may obtain a copy of the License at 11 | 12 | http://www.apache.org/licenses/LICENSE-2.0 13 | 14 | Unless required by applicable law or agreed to in writing, software 15 | distributed under the License is distributed on an "AS IS" BASIS, 16 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | See the License for the specific language governing permissions and 18 | limitations under the License. 19 | 20 | =============================================================================*/ 21 | 22 | #include "ctkServiceRegistration_p.h" 23 | 24 | //---------------------------------------------------------------------------- 25 | ctkServiceRegistrationPrivate::ctkServiceRegistrationPrivate( 26 | ctkPluginPrivate* plugin, QObject* service, 27 | const ctkDictionary& props) 28 | : ref(1), service(service), plugin(plugin), reference(this), 29 | properties(props), available(true), unregistering(false), 30 | propsLock() 31 | { 32 | 33 | } 34 | 35 | //---------------------------------------------------------------------------- 36 | ctkServiceRegistrationPrivate::~ctkServiceRegistrationPrivate() 37 | { 38 | 39 | } 40 | 41 | //---------------------------------------------------------------------------- 42 | bool ctkServiceRegistrationPrivate::isUsedByPlugin(QSharedPointer p) 43 | { 44 | QHash, int> deps = dependents; 45 | return deps.contains(p); 46 | } 47 | 48 | //---------------------------------------------------------------------------- 49 | QObject* ctkServiceRegistrationPrivate::getService() 50 | { 51 | return service; 52 | } 53 | -------------------------------------------------------------------------------- /includes/pluginFramework/ctkServiceSlotEntry_p.h: -------------------------------------------------------------------------------- 1 | /*============================================================================= 2 | 3 | Library: CTK 4 | 5 | Copyright (c) German Cancer Research Center, 6 | Division of Medical and Biological Informatics 7 | 8 | Licensed under the Apache License, Version 2.0 (the "License"); 9 | you may not use this file except in compliance with the License. 10 | You may obtain a copy of the License at 11 | 12 | http://www.apache.org/licenses/LICENSE-2.0 13 | 14 | Unless required by applicable law or agreed to in writing, software 15 | distributed under the License is distributed on an "AS IS" BASIS, 16 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | See the License for the specific language governing permissions and 18 | limitations under the License. 19 | 20 | =============================================================================*/ 21 | 22 | 23 | #ifndef CTKSERVICESLOTENTRY_P_H 24 | #define CTKSERVICESLOTENTRY_P_H 25 | 26 | 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | 33 | #include "ctkServiceEvent.h" 34 | #include "ctkLDAPExpr_p.h" 35 | 36 | class ctkPlugin; 37 | class ctkServiceSlotEntryData; 38 | 39 | class QObject; 40 | 41 | 42 | /** 43 | * \ingroup PluginFramework 44 | * 45 | * Data structure for saving information about slots registered for 46 | * receiving service lifecycle events. 47 | */ 48 | class ctkServiceSlotEntry 49 | { 50 | 51 | public: 52 | 53 | ctkServiceSlotEntry(QSharedPointer p, QObject* receiver, const char* slot, 54 | const QString& filter = QString()); 55 | 56 | ctkServiceSlotEntry(const ctkServiceSlotEntry& other); 57 | 58 | // default constructor for use in QSet 59 | ctkServiceSlotEntry(); 60 | ~ctkServiceSlotEntry(); 61 | 62 | // assignment operator for use in QSet 63 | ctkServiceSlotEntry& operator=(const ctkServiceSlotEntry& other); 64 | 65 | bool operator==(const ctkServiceSlotEntry& other) const; 66 | 67 | void invokeSlot(const ctkServiceEvent& event); 68 | 69 | void setRemoved(bool removed); 70 | 71 | bool isRemoved() const; 72 | 73 | QSharedPointer getPlugin() const; 74 | 75 | ctkLDAPExpr getLDAPExpr() const; 76 | 77 | QString getFilter() const; 78 | 79 | ctkLDAPExpr::LocalCache& getLocalCache() const; 80 | 81 | private: 82 | 83 | friend uint qHash(const ctkServiceSlotEntry& serviceSlot); 84 | 85 | QExplicitlySharedDataPointer d; 86 | 87 | }; 88 | 89 | /** 90 | * \ingroup PluginFramework 91 | */ 92 | uint qHash(const ctkServiceSlotEntry& serviceSlot); 93 | 94 | #endif // CTKSERVICESLOTENTRY_P_H 95 | -------------------------------------------------------------------------------- /includes/pluginFramework/ctkTrackedPlugin.tpp: -------------------------------------------------------------------------------- 1 | /*============================================================================= 2 | 3 | Library: CTK 4 | 5 | Copyright (c) German Cancer Research Center, 6 | Division of Medical and Biological Informatics 7 | 8 | Licensed under the Apache License, Version 2.0 (the "License"); 9 | you may not use this file except in compliance with the License. 10 | You may obtain a copy of the License at 11 | 12 | http://www.apache.org/licenses/LICENSE-2.0 13 | 14 | Unless required by applicable law or agreed to in writing, software 15 | distributed under the License is distributed on an "AS IS" BASIS, 16 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | See the License for the specific language governing permissions and 18 | limitations under the License. 19 | 20 | =============================================================================*/ 21 | 22 | //---------------------------------------------------------------------------- 23 | template 24 | ctkTrackedPlugin::ctkTrackedPlugin(ctkPluginTracker* pluginTracker, 25 | ctkPluginTrackerCustomizer* customizer) 26 | : pluginTracker(pluginTracker), customizer(customizer) 27 | { 28 | 29 | } 30 | 31 | //---------------------------------------------------------------------------- 32 | template 33 | void ctkTrackedPlugin::pluginChanged(const ctkPluginEvent& event) 34 | { 35 | /* 36 | * Check if we had a delayed call (which could happen when we 37 | * close). 38 | */ 39 | if (this->closed) 40 | { 41 | return; 42 | } 43 | 44 | QSharedPointer plugin = event.getPlugin(); 45 | ctkPlugin::State state = plugin->getState(); 46 | if (pluginTracker->d_func()->DEBUG_FLAG) 47 | { 48 | qDebug() << "ctkTrackedPlugin::pluginChanged[" << state << "]: " << *plugin; 49 | } 50 | 51 | if (pluginTracker->d_func()->mask & state) 52 | { 53 | this->track(plugin, event); 54 | /* 55 | * If the customizer throws an exception, it is safe 56 | * to let it propagate 57 | */ 58 | } 59 | else 60 | { 61 | this->untrack(plugin, event); 62 | /* 63 | * If the customizer throws an exception, it is safe 64 | * to let it propagate 65 | */ 66 | } 67 | } 68 | 69 | //---------------------------------------------------------------------------- 70 | template 71 | T ctkTrackedPlugin::customizerAdding(QSharedPointer item, 72 | const ctkPluginEvent& related) 73 | { 74 | return customizer->addingPlugin(item, related); 75 | } 76 | 77 | //---------------------------------------------------------------------------- 78 | template 79 | void ctkTrackedPlugin::customizerModified(QSharedPointer item, 80 | const ctkPluginEvent& related, 81 | T object) 82 | { 83 | customizer->modifiedPlugin(item, related, object); 84 | } 85 | 86 | //---------------------------------------------------------------------------- 87 | template 88 | void ctkTrackedPlugin::customizerRemoved(QSharedPointer item, 89 | const ctkPluginEvent& related, 90 | T object) 91 | { 92 | customizer->removedPlugin(item, related, object); 93 | } 94 | -------------------------------------------------------------------------------- /includes/pluginFramework/ctkTrackedPluginListener_p.h: -------------------------------------------------------------------------------- 1 | /*============================================================================= 2 | 3 | Library: CTK 4 | 5 | Copyright (c) German Cancer Research Center, 6 | Division of Medical and Biological Informatics 7 | 8 | Licensed under the Apache License, Version 2.0 (the "License"); 9 | you may not use this file except in compliance with the License. 10 | You may obtain a copy of the License at 11 | 12 | http://www.apache.org/licenses/LICENSE-2.0 13 | 14 | Unless required by applicable law or agreed to in writing, software 15 | distributed under the License is distributed on an "AS IS" BASIS, 16 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | See the License for the specific language governing permissions and 18 | limitations under the License. 19 | 20 | =============================================================================*/ 21 | 22 | 23 | #ifndef CTKTRACKEDPLUGINLISTENER_P_H 24 | #define CTKTRACKEDPLUGINLISTENER_P_H 25 | 26 | #include 27 | 28 | #include "ctkPluginEvent.h" 29 | 30 | /** 31 | * \ingroup PluginFramework 32 | */ 33 | class CTK_PLUGINFW_EXPORT ctkTrackedPluginListener : public QObject 34 | { 35 | Q_OBJECT 36 | 37 | public: 38 | ctkTrackedPluginListener(QObject *parent = 0) 39 | : QObject(parent) 40 | {} 41 | 42 | public Q_SLOTS: 43 | 44 | /** 45 | * Slot for the ctkPluginTracker 46 | * class. This method must NOT be synchronized to avoid deadlock 47 | * potential. 48 | * 49 | * @param event ctkPluginEvent object from the framework. 50 | */ 51 | virtual void pluginChanged(const ctkPluginEvent& event) = 0; 52 | 53 | }; 54 | 55 | #endif // CTKTRACKEDPLUGINLISTENER_P_H 56 | -------------------------------------------------------------------------------- /includes/pluginFramework/ctkTrackedServiceListener_p.h: -------------------------------------------------------------------------------- 1 | /*============================================================================= 2 | 3 | Library: CTK 4 | 5 | Copyright (c) German Cancer Research Center, 6 | Division of Medical and Biological Informatics 7 | 8 | Licensed under the Apache License, Version 2.0 (the "License"); 9 | you may not use this file except in compliance with the License. 10 | You may obtain a copy of the License at 11 | 12 | http://www.apache.org/licenses/LICENSE-2.0 13 | 14 | Unless required by applicable law or agreed to in writing, software 15 | distributed under the License is distributed on an "AS IS" BASIS, 16 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | See the License for the specific language governing permissions and 18 | limitations under the License. 19 | 20 | =============================================================================*/ 21 | 22 | 23 | #ifndef CTKTRACKEDSERVICELISTENER_P_H 24 | #define CTKTRACKEDSERVICELISTENER_P_H 25 | 26 | #include 27 | 28 | #include "ctkServiceEvent.h" 29 | 30 | /** 31 | * \ingroup PluginFramework 32 | */ 33 | class CTK_PLUGINFW_EXPORT ctkTrackedServiceListener : public QObject 34 | { 35 | Q_OBJECT 36 | 37 | public: 38 | ctkTrackedServiceListener(QObject *parent = 0) 39 | : QObject(parent) 40 | {} 41 | 42 | public Q_SLOTS: 43 | 44 | /** 45 | * Slot connected to service events for the 46 | * ctkServiceTracker class. This method must NOT be 47 | * synchronized to avoid deadlock potential. 48 | * 49 | * @param event ctkServiceEvent object from the framework. 50 | */ 51 | virtual void serviceChanged(const ctkServiceEvent& event) = 0; 52 | 53 | }; 54 | 55 | #endif // CTKTRACKEDSERVICELISTENER_P_H 56 | -------------------------------------------------------------------------------- /includes/pluginFramework/ctkVersionRange_p.h: -------------------------------------------------------------------------------- 1 | /*============================================================================= 2 | 3 | Library: CTK 4 | 5 | Copyright (c) German Cancer Research Center, 6 | Division of Medical and Biological Informatics 7 | 8 | Licensed under the Apache License, Version 2.0 (the "License"); 9 | you may not use this file except in compliance with the License. 10 | You may obtain a copy of the License at 11 | 12 | http://www.apache.org/licenses/LICENSE-2.0 13 | 14 | Unless required by applicable law or agreed to in writing, software 15 | distributed under the License is distributed on an "AS IS" BASIS, 16 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | See the License for the specific language governing permissions and 18 | limitations under the License. 19 | 20 | =============================================================================*/ 21 | 22 | #ifndef CTKVERSIONRANGE_H 23 | #define CTKVERSIONRANGE_H 24 | 25 | #include "ctkVersion.h" 26 | 27 | 28 | /** 29 | * \ingroup PluginFramework 30 | * 31 | * Class representing CTK version ranges. 32 | */ 33 | class ctkVersionRange 34 | { 35 | 36 | private: 37 | 38 | ctkVersion low; 39 | ctkVersion high; 40 | bool lowIncluded; 41 | bool highIncluded; 42 | 43 | public: 44 | 45 | /** 46 | * The empty version range "[0.0.0,inf)". 47 | */ 48 | static ctkVersionRange defaultVersionRange(); 49 | 50 | /** 51 | * Construct a ctkVersionRange object. 52 | * Format for a range: 53 | * ( "(" | "[" ) LOW_VERSION "," HIGH_VERSION ( ")" | "]" ) 54 | * Format for at least a version: 55 | * VERSION 56 | * 57 | * @param vr Input string. 58 | */ 59 | ctkVersionRange(const QString& vr); 60 | 61 | 62 | /** 63 | * Construct the default ctkVersionRange object. 64 | * 65 | */ 66 | ctkVersionRange(); 67 | 68 | ~ctkVersionRange(); 69 | 70 | 71 | bool isSpecified() const; 72 | 73 | 74 | /** 75 | * Check if specified version is within our range. 76 | * 77 | * @param ver ctkVersion to compare to. 78 | * @return Return true if within range, otherwise false. 79 | */ 80 | bool withinRange(const ctkVersion& ver) const; 81 | 82 | 83 | /** 84 | * Check if objects range is within another ctkVersionRange. 85 | * 86 | * @param range ctkVersionRange to compare to. 87 | * @return Return true if within range, otherwise false. 88 | */ 89 | bool withinRange(const ctkVersionRange& range) const; 90 | 91 | 92 | /** 93 | * Compare object to another ctkVersionRange. VersionRanges are compared on the 94 | * lower bound. 95 | * 96 | * @param obj ctkVersionRange to compare to. 97 | * @return Return 0 if equals, negative if this object is less than obj 98 | * and positive if this object is larger then obj. 99 | * @exception ClassCastException if object is not a ctkVersionRange object. 100 | */ 101 | int compare(const ctkVersionRange& obj) const; 102 | 103 | 104 | /** 105 | * String with version number. If version is not specified return 106 | * an empty string. 107 | * 108 | * @return QString. 109 | */ 110 | QString toString() const; 111 | 112 | 113 | /** 114 | * Check if object is equal to this object. 115 | * 116 | * @param obj Package entry to compare to. 117 | * @return true if equal, otherwise false. 118 | */ 119 | bool operator==(const ctkVersionRange& r) const; 120 | 121 | }; 122 | 123 | 124 | #endif // CTKVERSIONRANGE_H 125 | -------------------------------------------------------------------------------- /includes/pluginFramework/service/application/ctkApplicationDescriptor.cpp: -------------------------------------------------------------------------------- 1 | /*============================================================================= 2 | 3 | Library: CTK 4 | 5 | Copyright (c) German Cancer Research Center, 6 | Division of Medical and Biological Informatics 7 | 8 | Licensed under the Apache License, Version 2.0 (the "License"); 9 | you may not use this file except in compliance with the License. 10 | You may obtain a copy of the License at 11 | 12 | http://www.apache.org/licenses/LICENSE-2.0 13 | 14 | Unless required by applicable law or agreed to in writing, software 15 | distributed under the License is distributed on an "AS IS" BASIS, 16 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | See the License for the specific language governing permissions and 18 | limitations under the License. 19 | 20 | =============================================================================*/ 21 | 22 | #include "ctkApplicationDescriptor.h" 23 | 24 | #include 25 | 26 | const QString ctkApplicationDescriptor::APPLICATION_NAME = "application.name"; 27 | const QString ctkApplicationDescriptor::APPLICATION_ICON = "application.icon"; 28 | const QString ctkApplicationDescriptor::APPLICATION_PID = ctkPluginConstants::SERVICE_PID; 29 | const QString ctkApplicationDescriptor::APPLICATION_VERSION = "application.version"; 30 | const QString ctkApplicationDescriptor::APPLICATION_VENDOR = ctkPluginConstants::SERVICE_VENDOR; 31 | const QString ctkApplicationDescriptor::APPLICATION_VISIBLE = "application.visible"; 32 | const QString ctkApplicationDescriptor::APPLICATION_LAUNCHABLE = "application.launchable"; 33 | const QString ctkApplicationDescriptor::APPLICATION_LOCKED = "application.locked"; 34 | const QString ctkApplicationDescriptor::APPLICATION_DESCRIPTION = "application.description"; 35 | const QString ctkApplicationDescriptor::APPLICATION_DOCUMENTATION = "application.documentation"; 36 | const QString ctkApplicationDescriptor::APPLICATION_COPYRIGHT = "application.copyright"; 37 | const QString ctkApplicationDescriptor::APPLICATION_LICENSE = "application.license"; 38 | const QString ctkApplicationDescriptor::APPLICATION_CONTAINER = "application.container"; 39 | const QString ctkApplicationDescriptor::APPLICATION_LOCATION = "application.location"; 40 | -------------------------------------------------------------------------------- /includes/pluginFramework/service/application/ctkApplicationException.cpp: -------------------------------------------------------------------------------- 1 | /*============================================================================= 2 | 3 | Library: CTK 4 | 5 | Copyright (c) German Cancer Research Center, 6 | Division of Medical and Biological Informatics 7 | 8 | Licensed under the Apache License, Version 2.0 (the "License"); 9 | you may not use this file except in compliance with the License. 10 | You may obtain a copy of the License at 11 | 12 | http://www.apache.org/licenses/LICENSE-2.0 13 | 14 | Unless required by applicable law or agreed to in writing, software 15 | distributed under the License is distributed on an "AS IS" BASIS, 16 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | See the License for the specific language governing permissions and 18 | limitations under the License. 19 | 20 | =============================================================================*/ 21 | 22 | #include "ctkApplicationException.h" 23 | 24 | const int ctkApplicationException::APPLICATION_LOCKED = 0x01; 25 | const int ctkApplicationException::APPLICATION_NOT_LAUNCHABLE = 0x02; 26 | const int ctkApplicationException::APPLICATION_INTERNAL_ERROR = 0x03; 27 | const int ctkApplicationException::APPLICATION_SCHEDULING_FAILED = 0x04; 28 | const int ctkApplicationException::APPLICATION_DUPLICATE_SCHEDULE_ID = 0x05; 29 | const int ctkApplicationException::APPLICATION_EXITVALUE_NOT_AVAILABLE = 0x06; 30 | const int ctkApplicationException::APPLICATION_INVALID_STARTUP_ARGUMENT = 0x07; 31 | 32 | 33 | //---------------------------------------------------------------------------- 34 | ctkApplicationException::ctkApplicationException(int errorCode) 35 | : ctkException("") 36 | , errorCode(errorCode) 37 | { 38 | } 39 | 40 | //---------------------------------------------------------------------------- 41 | ctkApplicationException::ctkApplicationException(int errorCode, const ctkException& cause) 42 | : ctkException("", cause) 43 | , errorCode(errorCode) 44 | { 45 | } 46 | 47 | //---------------------------------------------------------------------------- 48 | ctkApplicationException::ctkApplicationException(int errorCode, const QString& message) 49 | : ctkException(message) 50 | , errorCode(errorCode) 51 | { 52 | } 53 | 54 | //---------------------------------------------------------------------------- 55 | ctkApplicationException::ctkApplicationException(int errorCode, const QString& message, const ctkException& cause) 56 | : ctkException(message, cause) 57 | , errorCode(errorCode) 58 | { 59 | } 60 | 61 | //---------------------------------------------------------------------------- 62 | ctkApplicationException::~ctkApplicationException() throw() 63 | { 64 | 65 | } 66 | 67 | //---------------------------------------------------------------------------- 68 | const char* ctkApplicationException::name() const throw() 69 | { 70 | return "Application Exception"; 71 | } 72 | 73 | //---------------------------------------------------------------------------- 74 | ctkApplicationException* ctkApplicationException::clone() const 75 | { 76 | return new ctkApplicationException(*this); 77 | } 78 | 79 | //---------------------------------------------------------------------------- 80 | void ctkApplicationException::rethrow() const 81 | { 82 | throw *this; 83 | } 84 | 85 | //---------------------------------------------------------------------------- 86 | int ctkApplicationException::GetErrorCode() const 87 | { 88 | return errorCode; 89 | } 90 | -------------------------------------------------------------------------------- /includes/pluginFramework/service/application/ctkApplicationHandle.cpp: -------------------------------------------------------------------------------- 1 | /*============================================================================= 2 | 3 | Library: CTK 4 | 5 | Copyright (c) German Cancer Research Center, 6 | Division of Medical and Biological Informatics 7 | 8 | Licensed under the Apache License, Version 2.0 (the "License"); 9 | you may not use this file except in compliance with the License. 10 | You may obtain a copy of the License at 11 | 12 | http://www.apache.org/licenses/LICENSE-2.0 13 | 14 | Unless required by applicable law or agreed to in writing, software 15 | distributed under the License is distributed on an "AS IS" BASIS, 16 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | See the License for the specific language governing permissions and 18 | limitations under the License. 19 | 20 | =============================================================================*/ 21 | 22 | #include "ctkApplicationHandle.h" 23 | 24 | #include 25 | 26 | const QString ctkApplicationHandle::APPLICATION_PID = ctkPluginConstants::SERVICE_PID; 27 | const QString ctkApplicationHandle::APPLICATION_DESCRIPTOR = "application.descriptor"; 28 | const QString ctkApplicationHandle::APPLICATION_STATE = "application.state"; 29 | const QString ctkApplicationHandle::APPLICATION_SUPPORTS_EXITVALUE = "application.supports.exitvalue"; 30 | 31 | const QString ctkApplicationHandle::RUNNING = "RUNNING"; 32 | const QString ctkApplicationHandle::STOPPING = "STOPPING"; 33 | -------------------------------------------------------------------------------- /includes/pluginFramework/service/application/ctkApplicationLauncher.h: -------------------------------------------------------------------------------- 1 | /*============================================================================= 2 | 3 | Library: CTK 4 | 5 | Copyright (c) German Cancer Research Center, 6 | Division of Medical and Biological Informatics 7 | 8 | Licensed under the Apache License, Version 2.0 (the "License"); 9 | you may not use this file except in compliance with the License. 10 | You may obtain a copy of the License at 11 | 12 | http://www.apache.org/licenses/LICENSE-2.0 13 | 14 | Unless required by applicable law or agreed to in writing, software 15 | distributed under the License is distributed on an "AS IS" BASIS, 16 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | See the License for the specific language governing permissions and 18 | limitations under the License. 19 | 20 | =============================================================================*/ 21 | 22 | #ifndef CTKAPPLICATIONLAUNCHER_H 23 | #define CTKAPPLICATIONLAUNCHER_H 24 | 25 | #include 26 | 27 | struct ctkApplicationRunnable; 28 | 29 | class QVariant; 30 | 31 | /** 32 | * A ctkApplicationLauncher is used to launch ctkApplicationRunnable objects using 33 | * the main thread. 34 | *

35 | * This class is for use by platform-related plug-ins which implement application containers. 36 | * Clients outside of the base platform should not reference or subclass this class. 37 | *

38 | */ 39 | struct ctkApplicationLauncher 40 | { 41 | virtual ~ctkApplicationLauncher() {} 42 | 43 | /** 44 | * Launches the specified runnable using the main thread. 45 | * @param runnable a ParameterizedRunnalbe to run on the main thread. 46 | * @param context the context to launch the runnable with 47 | */ 48 | virtual void launch(ctkApplicationRunnable* app, const QVariant& applicationContext) = 0; 49 | 50 | /** 51 | * Forces the current runnable which is running to be stopped. 52 | * This method will return after the currently running ctkApplicationRunnable 53 | * has completely stopped. 54 | *

55 | * After this method returns this ctkApplicationLauncher will no longer allow 56 | * applications to be launched. 57 | */ 58 | virtual void shutdown() = 0; 59 | 60 | }; 61 | 62 | Q_DECLARE_INTERFACE(ctkApplicationLauncher, "org.commontk.service.application.ApplicationLauncher") 63 | 64 | #endif // CTKAPPLICATIONLAUNCHER_H 65 | -------------------------------------------------------------------------------- /includes/pluginFramework/service/cm/ctkConfiguration.cpp: -------------------------------------------------------------------------------- 1 | /*============================================================================= 2 | 3 | Library: CTK 4 | 5 | Copyright (c) German Cancer Research Center, 6 | Division of Medical and Biological Informatics 7 | 8 | Licensed under the Apache License, Version 2.0 (the "License"); 9 | you may not use this file except in compliance with the License. 10 | You may obtain a copy of the License at 11 | 12 | http://www.apache.org/licenses/LICENSE-2.0 13 | 14 | Unless required by applicable law or agreed to in writing, software 15 | distributed under the License is distributed on an "AS IS" BASIS, 16 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | See the License for the specific language governing permissions and 18 | limitations under the License. 19 | 20 | =============================================================================*/ 21 | 22 | 23 | #include "ctkConfiguration.h" 24 | 25 | //---------------------------------------------------------------------------- 26 | ctkConfiguration::~ctkConfiguration() 27 | { 28 | } 29 | 30 | //---------------------------------------------------------------------------- 31 | bool ctkConfiguration::operator==(const ctkConfiguration& other) const 32 | { 33 | return this->getPid() == other.getPid(); 34 | } 35 | 36 | //---------------------------------------------------------------------------- 37 | uint qHash(ctkConfigurationPtr configuration) 38 | { 39 | return qHash(configuration->getPid()); 40 | } 41 | 42 | //---------------------------------------------------------------------------- 43 | bool operator==(const ctkConfigurationPtr& c1, const ctkConfigurationPtr c2) 44 | { 45 | return (*c1.data()) == (*c2.data()); 46 | } 47 | -------------------------------------------------------------------------------- /includes/pluginFramework/service/cm/ctkConfigurationAdmin.cpp: -------------------------------------------------------------------------------- 1 | /*============================================================================= 2 | 3 | Library: CTK 4 | 5 | Copyright (c) 2010 German Cancer Research Center, 6 | Division of Medical and Biological Informatics 7 | 8 | Licensed under the Apache License, Version 2.0 (the "License"); 9 | you may not use this file except in compliance with the License. 10 | You may obtain a copy of the License at 11 | 12 | http://www.apache.org/licenses/LICENSE-2.0 13 | 14 | Unless required by applicable law or agreed to in writing, software 15 | distributed under the License is distributed on an "AS IS" BASIS, 16 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | See the License for the specific language governing permissions and 18 | limitations under the License. 19 | 20 | =============================================================================*/ 21 | 22 | 23 | #include "ctkConfigurationAdmin.h" 24 | 25 | const QString ctkConfigurationAdmin::SERVICE_FACTORYPID = "service.factoryPid"; 26 | const QString ctkConfigurationAdmin::SERVICE_PLUGINLOCATION = "service.pluginLocation"; 27 | 28 | -------------------------------------------------------------------------------- /includes/pluginFramework/service/cm/ctkConfigurationException.h: -------------------------------------------------------------------------------- 1 | /*============================================================================= 2 | 3 | Library: CTK 4 | 5 | Copyright (c) German Cancer Research Center, 6 | Division of Medical and Biological Informatics 7 | 8 | Licensed under the Apache License, Version 2.0 (the "License"); 9 | you may not use this file except in compliance with the License. 10 | You may obtain a copy of the License at 11 | 12 | http://www.apache.org/licenses/LICENSE-2.0 13 | 14 | Unless required by applicable law or agreed to in writing, software 15 | distributed under the License is distributed on an "AS IS" BASIS, 16 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | See the License for the specific language governing permissions and 18 | limitations under the License. 19 | 20 | =============================================================================*/ 21 | 22 | 23 | #ifndef CTKCONFIGURATIONEXCEPTION_H 24 | #define CTKCONFIGURATIONEXCEPTION_H 25 | 26 | #include "ctkException.h" 27 | 28 | #include 29 | 30 | /** 31 | * \ingroup ConfigAdmin 32 | * 33 | * An exception class to inform the Configuration Admin service 34 | * of problems with configuration data. 35 | */ 36 | class CTK_PLUGINFW_EXPORT ctkConfigurationException : public ctkRuntimeException 37 | { 38 | 39 | public: 40 | 41 | /** 42 | * Create a ctkConfigurationException object. 43 | * 44 | * @param property name of the property that caused the problem, 45 | * null if no specific property was the cause 46 | * @param reason reason for failure 47 | */ 48 | ctkConfigurationException(const QString& property, const QString& reason); 49 | 50 | /** 51 | * Create a ctkConfigurationException object. 52 | * 53 | * @param property name of the property that caused the problem, 54 | * null if no specific property was the cause 55 | * @param reason reason for failure 56 | * @param cause The cause of this exception. 57 | */ 58 | ctkConfigurationException(const QString& property, const QString& reason, 59 | const ctkException& cause); 60 | 61 | ctkConfigurationException(const ctkConfigurationException& o); 62 | ctkConfigurationException& operator=(const ctkConfigurationException& o); 63 | 64 | ~ctkConfigurationException() throw(); 65 | 66 | /** 67 | * @see ctkException::name() 68 | */ 69 | const char* name() const throw(); 70 | 71 | /** 72 | * @see ctkException::clone() 73 | */ 74 | ctkConfigurationException* clone() const; 75 | 76 | /** 77 | * @see ctkException::rethrow() 78 | */ 79 | void rethrow() const; 80 | 81 | /** 82 | * Return the property name that caused the failure or a null QString. 83 | * 84 | * @return name of property or null if no specific property caused the 85 | * problem 86 | */ 87 | QString getProperty() const; 88 | 89 | /** 90 | * Return the reason for this exception. 91 | * 92 | * @return reason of the failure 93 | */ 94 | QString getReason() const; 95 | 96 | private: 97 | 98 | QString property; 99 | QString reason; 100 | }; 101 | 102 | /** 103 | * \ingroup ConfigAdmin 104 | */ 105 | 106 | CTK_PLUGINFW_EXPORT QDebug operator<<(QDebug dbg, const ctkConfigurationException& exc); 107 | 108 | /** @}*/ 109 | 110 | #endif // CTKCONFIGURATIONEXCEPTION_H 111 | -------------------------------------------------------------------------------- /includes/pluginFramework/service/cm/ctkConfigurationListener.h: -------------------------------------------------------------------------------- 1 | /*============================================================================= 2 | 3 | Library: CTK 4 | 5 | Copyright (c) German Cancer Research Center, 6 | Division of Medical and Biological Informatics 7 | 8 | Licensed under the Apache License, Version 2.0 (the "License"); 9 | you may not use this file except in compliance with the License. 10 | You may obtain a copy of the License at 11 | 12 | http://www.apache.org/licenses/LICENSE-2.0 13 | 14 | Unless required by applicable law or agreed to in writing, software 15 | distributed under the License is distributed on an "AS IS" BASIS, 16 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | See the License for the specific language governing permissions and 18 | limitations under the License. 19 | 20 | =============================================================================*/ 21 | 22 | 23 | #ifndef CTKCONFIGURATIONLISTENER_H 24 | #define CTKCONFIGURATIONLISTENER_H 25 | 26 | #include "ctkConfigurationEvent.h" 27 | 28 | /** 29 | * \ingroup ConfigAdmin 30 | * 31 | * Listener for Configuration Events. When a ctkConfigurationEvent 32 | * is fired, it is asynchronously delivered to a 33 | * ctkConfigurationListener. 34 | * 35 | *

36 | * ctkConfigurationListener objects are registered with the 37 | * Framework service registry and are notified with a 38 | * ctkConfigurationEvent object when an event is fired. 39 | *

40 | * ctkConfigurationListener objects can inspect the received 41 | * ctkConfigurationEvent object to determine its type, the pid of 42 | * the ctkConfiguration object with which it is associated, and the 43 | * Configuration Admin service that fired the event. 44 | * 45 | *

46 | * Security Considerations. Plugins wishing to monitor configuration events will 47 | * require ctkServicePermission[ctkConfigurationListener,REGISTER] to 48 | * register a ctkConfigurationListener service. 49 | */ 50 | struct ctkConfigurationListener 51 | { 52 | virtual ~ctkConfigurationListener() {} 53 | 54 | /** 55 | * Receives notification of a ctkConfiguration that has changed. 56 | * 57 | * @param event The ctkConfigurationEvent. 58 | */ 59 | virtual void configurationEvent(const ctkConfigurationEvent& event) = 0; 60 | }; 61 | 62 | Q_DECLARE_INTERFACE(ctkConfigurationListener, "org.commontk.service.cm.ConfigurationListener") 63 | 64 | #endif // CTKCONFIGURATIONLISTENER_H 65 | -------------------------------------------------------------------------------- /includes/pluginFramework/service/cm/ctkConfigurationPlugin.cpp: -------------------------------------------------------------------------------- 1 | /*============================================================================= 2 | 3 | Library: CTK 4 | 5 | Copyright (c) German Cancer Research Center, 6 | Division of Medical and Biological Informatics 7 | 8 | Licensed under the Apache License, Version 2.0 (the "License"); 9 | you may not use this file except in compliance with the License. 10 | You may obtain a copy of the License at 11 | 12 | http://www.apache.org/licenses/LICENSE-2.0 13 | 14 | Unless required by applicable law or agreed to in writing, software 15 | distributed under the License is distributed on an "AS IS" BASIS, 16 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | See the License for the specific language governing permissions and 18 | limitations under the License. 19 | 20 | =============================================================================*/ 21 | 22 | 23 | #include "ctkConfigurationPlugin.h" 24 | 25 | const QString ctkConfigurationPlugin::CM_TARGET = "cm.target"; 26 | const QString ctkConfigurationPlugin::CM_RANKING = "service.cmRanking"; 27 | -------------------------------------------------------------------------------- /includes/pluginFramework/service/datalocation/ctkLocation.cpp: -------------------------------------------------------------------------------- 1 | /*============================================================================= 2 | 3 | Library: CTK 4 | 5 | Copyright (c) German Cancer Research Center, 6 | Division of Medical and Biological Informatics 7 | 8 | Licensed under the Apache License, Version 2.0 (the "License"); 9 | you may not use this file except in compliance with the License. 10 | You may obtain a copy of the License at 11 | 12 | http://www.apache.org/licenses/LICENSE-2.0 13 | 14 | Unless required by applicable law or agreed to in writing, software 15 | distributed under the License is distributed on an "AS IS" BASIS, 16 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | See the License for the specific language governing permissions and 18 | limitations under the License. 19 | 20 | =============================================================================*/ 21 | 22 | #include "ctkLocation.h" 23 | 24 | const QString ctkLocation::INSTANCE_FILTER = QString("(&(objectClass=") + 25 | qobject_interface_iid() + 26 | ")(type=ctk.instance.area))"; 27 | 28 | const QString ctkLocation::INSTALL_FILTER = QString("(&(objectClass=") + 29 | qobject_interface_iid() + 30 | ")(type=ctk.install.area))"; 31 | 32 | const QString ctkLocation::CONFIGURATION_FILTER = QString("(&(objectClass=") + 33 | qobject_interface_iid() + 34 | ")(type=ctk.configuration.area))"; 35 | 36 | const QString ctkLocation::USER_FILTER = QString("(&(objectClass=") + 37 | qobject_interface_iid() + 38 | ")(type=ctk.user.area))"; 39 | 40 | const QString ctkLocation::CTK_HOME_FILTER = QString("(&(objectClass=") + 41 | qobject_interface_iid() + 42 | ")(type=ctk.home.location))"; 43 | -------------------------------------------------------------------------------- /includes/pluginFramework/service/debug/ctkDebugOptions.cpp: -------------------------------------------------------------------------------- 1 | /*============================================================================= 2 | 3 | Library: CTK 4 | 5 | Copyright (c) German Cancer Research Center, 6 | Division of Medical and Biological Informatics 7 | 8 | Licensed under the Apache License, Version 2.0 (the "License"); 9 | you may not use this file except in compliance with the License. 10 | You may obtain a copy of the License at 11 | 12 | http://www.apache.org/licenses/LICENSE-2.0 13 | 14 | Unless required by applicable law or agreed to in writing, software 15 | distributed under the License is distributed on an "AS IS" BASIS, 16 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | See the License for the specific language governing permissions and 18 | limitations under the License. 19 | 20 | =============================================================================*/ 21 | 22 | #include "ctkDebugOptions.h" 23 | 24 | const QString ctkDebugOptions::LISTENER_SYMBOLICNAME = "listener.symbolic.name"; 25 | -------------------------------------------------------------------------------- /includes/pluginFramework/service/debug/ctkDebugOptionsListener.h: -------------------------------------------------------------------------------- 1 | /*============================================================================= 2 | 3 | Library: CTK 4 | 5 | Copyright (c) German Cancer Research Center, 6 | Division of Medical and Biological Informatics 7 | 8 | Licensed under the Apache License, Version 2.0 (the "License"); 9 | you may not use this file except in compliance with the License. 10 | You may obtain a copy of the License at 11 | 12 | http://www.apache.org/licenses/LICENSE-2.0 13 | 14 | Unless required by applicable law or agreed to in writing, software 15 | distributed under the License is distributed on an "AS IS" BASIS, 16 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | See the License for the specific language governing permissions and 18 | limitations under the License. 19 | 20 | =============================================================================*/ 21 | 22 | #ifndef CTKDEBUGOPTIONSLISTENER_H 23 | #define CTKDEBUGOPTIONSLISTENER_H 24 | 25 | #include 26 | 27 | struct ctkDebugOptions; 28 | 29 | /** 30 | * A debug options listener is notified whenever one of its plug-in option-path entries is 31 | * changed. A listener is registered as a service using the ctkDebugOptions#LISTENER_SYMBOLICNAME 32 | * service property to specify the symbolic name of the debug options listener. 33 | *

34 | * The ctkDebugOptionsListener#optionsChanged(const ctkDebugOptions&) method will automatically 35 | * be called upon registration of the debug options listener service. This allows the 36 | * listener to obtain the initial debug options. This initial call to the listener 37 | * will happen even if debug is not enabled at the time of registration 38 | * ctkDebugOptions#isDebugEnabled() will return false in this case). 39 | *

40 | * A debug options listener allows a plug-in to cache trace option values in boolean fields for performance 41 | * and code cleanliness. For example: 42 | *
43 |  * class Activator : ctkPluginActivator, ctkDebugOptionsListener
44 |  * {
45 |  *   static bool DEBUG_FLAG = false;
46 |  *
47 |  *   void start(ctkPluginContext* context)
48 |  *   {
49 |  *     ctkDictionary props;
50 |  *     props.insert(ctkDebugOptions::LISTENER_SYMBOLICNAME, "com.mycompany.mybundle");
51 |  *     context->registerService(this, props);
52 |  *   }
53 |  *
54 |  *   void optionsChanged(const ctkDebugOptions& options)
55 |  *   {
56 |  *     DEBUG_FLAG = options->getBooleanOption("com.mycompany.mybundle/debug", false);
57 |  *   }
58 |  *
59 |  *   void doSomeWork()
60 |  *   {
61 |  *     if (DEBUG_FLAG) BERRY_INFO << "foo";
62 |  *   }
63 |  *   ...
64 |  * }
65 |  * 
66 | */ 67 | struct ctkDebugOptionsListener 68 | { 69 | virtual ~ctkDebugOptionsListener() {} 70 | 71 | /** 72 | * Notifies this listener that an option-path for its plug-in has changed. 73 | * This method is also called initially by the ctkDebugOptions implementation 74 | * when the listener is registered as a service. This allows the listener 75 | * to obtain the initial set of debug options without the need to 76 | * acquire the debug options service. 77 | * @param options a reference to the ctkDebugOptions 78 | */ 79 | virtual void optionsChanged(const ctkDebugOptions& options) = 0; 80 | }; 81 | 82 | Q_DECLARE_INTERFACE(ctkDebugOptionsListener, "org.commontk.service.debug.DebugOptionsListener") 83 | 84 | #endif // CTKDEBUGOPTIONSLISTENER_H 85 | -------------------------------------------------------------------------------- /includes/pluginFramework/service/event/ctkEventConstants.cpp: -------------------------------------------------------------------------------- 1 | /*============================================================================= 2 | 3 | Library: CTK 4 | 5 | Copyright (c) German Cancer Research Center, 6 | Division of Medical and Biological Informatics 7 | 8 | Licensed under the Apache License, Version 2.0 (the "License"); 9 | you may not use this file except in compliance with the License. 10 | You may obtain a copy of the License at 11 | 12 | http://www.apache.org/licenses/LICENSE-2.0 13 | 14 | Unless required by applicable law or agreed to in writing, software 15 | distributed under the License is distributed on an "AS IS" BASIS, 16 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | See the License for the specific language governing permissions and 18 | limitations under the License. 19 | 20 | =============================================================================*/ 21 | 22 | #include "ctkEventConstants.h" 23 | 24 | 25 | const QString ctkEventConstants::EVENT_TOPIC = "event.topics"; 26 | const QString ctkEventConstants::EVENT_FILTER = "event.filter"; 27 | 28 | const QString ctkEventConstants::EVENT_DELIVERY = "event.delivery"; 29 | const QString ctkEventConstants::DELIVERY_ASYNC_ORDERED = "async.ordered"; 30 | const QString ctkEventConstants::DELIVERY_ASYNC_UNORDERED = "async.unordered"; 31 | 32 | const QString ctkEventConstants::PLUGIN_SYMBOLICNAME = "plugin.symbolicName"; 33 | const QString ctkEventConstants::PLUGIN_ID = "plugin.id"; 34 | const QString ctkEventConstants::PLUGIN = "plugin"; 35 | const QString ctkEventConstants::PLUGIN_VERSION = "plugin.version"; 36 | 37 | const QString ctkEventConstants::EVENT = "event"; 38 | const QString ctkEventConstants::EXCEPTION = "exception"; 39 | const QString ctkEventConstants::EXCEPTION_CLASS = "exception.class"; 40 | const QString ctkEventConstants::EXCEPTION_MESSAGE = "exception.message"; 41 | const QString ctkEventConstants::MESSAGE = "message"; 42 | const QString ctkEventConstants::SERVICE = "service"; 43 | const QString ctkEventConstants::SERVICE_ID = "service.id"; 44 | const QString ctkEventConstants::SERVICE_OBJECTCLASS = "service.objectClass"; 45 | const QString ctkEventConstants::SERVICE_PID = "service.pid"; 46 | const QString ctkEventConstants::TIMESTAMP = "timestamp"; 47 | -------------------------------------------------------------------------------- /includes/pluginFramework/service/event/ctkEventHandler.h: -------------------------------------------------------------------------------- 1 | /*============================================================================= 2 | 3 | Library: CTK 4 | 5 | Copyright (c) German Cancer Research Center, 6 | Division of Medical and Biological Informatics 7 | 8 | Licensed under the Apache License, Version 2.0 (the "License"); 9 | you may not use this file except in compliance with the License. 10 | You may obtain a copy of the License at 11 | 12 | http://www.apache.org/licenses/LICENSE-2.0 13 | 14 | Unless required by applicable law or agreed to in writing, software 15 | distributed under the License is distributed on an "AS IS" BASIS, 16 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | See the License for the specific language governing permissions and 18 | limitations under the License. 19 | 20 | =============================================================================*/ 21 | 22 | 23 | #ifndef CTKEVENTHANDLER_H 24 | #define CTKEVENTHANDLER_H 25 | 26 | #include "ctkEvent.h" 27 | 28 | /** 29 | * \ingroup EventAdmin 30 | * 31 | * Listener for Events. 32 | * 33 | *

34 | * ctkEventHandler objects are registered with the Framework service 35 | * registry and are notified with an ctkEvent object when an event 36 | * is sent or posted. 37 | *

38 | * ctkEventHandler objects can inspect the received 39 | * ctkEvent object to determine its topic and properties. 40 | * 41 | *

42 | * ctkEventHandler objects must be registered with a service 43 | * property {@link ctkEventConstants#EVENT_TOPIC} whose value is the list of topics 44 | * in which the event handler is interested. 45 | *

46 | * For example: 47 | * 48 | * \code 49 | * QStringList topics("com/isv/*"); 50 | * ctkDictionary props; 51 | * props.insert(ctkEventConstants::EVENT_TOPIC, topics); 52 | * context->registerService(this, props); 53 | * \endcode 54 | * 55 | * Event Handler services can also be registered with an 56 | * {@link ctkEventConstants#EVENT_FILTER} service property to further filter the 57 | * events. If the syntax of this filter is invalid, then the Event Handler must 58 | * be ignored by the Event Admin service. The Event Admin service should log a 59 | * warning. 60 | *

61 | * Security Considerations. Plugins wishing to monitor ctkEvent 62 | * objects will require ctkServicePermission[ctkEventHandler,REGISTER] 63 | * to register a ctkEventHandler service. The plugin must also have 64 | * ctkTopicPermission[topic,SUBSCRIBE] for the topic specified in 65 | * the event in order to receive the event. 66 | * 67 | * @see ctkEvent 68 | * 69 | * @remarks This class is thread safe. 70 | */ 71 | struct ctkEventHandler 72 | { 73 | virtual ~ctkEventHandler() {} 74 | 75 | /** 76 | * Called by the {@link ctkEventAdmin} service to notify the listener of an 77 | * event. 78 | * 79 | * @param event The event that occurred. 80 | */ 81 | virtual void handleEvent(const ctkEvent& event) = 0; 82 | }; 83 | 84 | Q_DECLARE_INTERFACE(ctkEventHandler, "org.commontk.service.event.EventHandler") 85 | 86 | #endif // CTKEVENTHANDLER_H 87 | -------------------------------------------------------------------------------- /includes/pluginFramework/service/log/ctkLogListener.h: -------------------------------------------------------------------------------- 1 | /*============================================================================= 2 | 3 | Library: CTK 4 | 5 | Copyright (c) 2010 German Cancer Research Center, 6 | Division of Medical and Biological Informatics 7 | 8 | Licensed under the Apache License, Version 2.0 (the "License"); 9 | you may not use this file except in compliance with the License. 10 | You may obtain a copy of the License at 11 | 12 | http://www.apache.org/licenses/LICENSE-2.0 13 | 14 | Unless required by applicable law or agreed to in writing, software 15 | distributed under the License is distributed on an "AS IS" BASIS, 16 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | See the License for the specific language governing permissions and 18 | limitations under the License. 19 | 20 | =============================================================================*/ 21 | 22 | 23 | #ifndef CTKLOGLISTENER_H 24 | #define CTKLOGLISTENER_H 25 | 26 | #include "ctkLogEntry.h" 27 | 28 | /** 29 | * \ingroup LogService 30 | * 31 | * Subscribes to ctkLogEntry objects from the ctkLogReaderService. 32 | * 33 | *

34 | * ctkLogListener objects may be registered with the Framework service 35 | * registry. After the listener is registered, the logged(ctkLogEntryPtr) 36 | * method will be called for each ctkLogEntry object created. 37 | * 38 | *

39 | * Qt slots can also be used to be notified about new ctkLogEntry 40 | * objects. See ctkLogReaderService#connectLogListener(). 41 | * 42 | * @remarks This class is thread safe. 43 | * @see ctkLogReaderService 44 | * @see ctkLogEntry 45 | * @see ctkLogReaderService#connectLogListener() 46 | * @see ctkLogReaderService#disconnectLogListener() 47 | */ 48 | struct ctkLogListener 49 | { 50 | virtual ~ctkLogListener() {} 51 | 52 | /** 53 | * Listener method called for each ctkLogEntry object created. 54 | * 55 | *

56 | * As with all event listeners, this method should return to its caller as 57 | * soon as possible. 58 | * 59 | * @param entry A ctkLogEntry object containing log information. 60 | * @see ctkLogEntry 61 | */ 62 | virtual void logged(ctkLogEntryPtr entry) = 0; 63 | }; 64 | 65 | Q_DECLARE_INTERFACE(ctkLogListener, "org.commontk.service.log.LogListener") 66 | 67 | #endif // CTKLOGLISTENER_H 68 | -------------------------------------------------------------------------------- /includes/pluginFramework/service/log/ctkLogService.cpp: -------------------------------------------------------------------------------- 1 | /*============================================================================= 2 | 3 | Library: CTK 4 | 5 | Copyright (c) German Cancer Research Center, 6 | Division of Medical and Biological Informatics 7 | 8 | Licensed under the Apache License, Version 2.0 (the "License"); 9 | you may not use this file except in compliance with the License. 10 | You may obtain a copy of the License at 11 | 12 | http://www.apache.org/licenses/LICENSE-2.0 13 | 14 | Unless required by applicable law or agreed to in writing, software 15 | distributed under the License is distributed on an "AS IS" BASIS, 16 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | See the License for the specific language governing permissions and 18 | limitations under the License. 19 | 20 | =============================================================================*/ 21 | 22 | 23 | #include "ctkLogService.h" 24 | 25 | const int ctkLogService::LOG_ERROR = 1; 26 | const int ctkLogService::LOG_WARNING = 2; 27 | const int ctkLogService::LOG_INFO = 3; 28 | const int ctkLogService::LOG_DEBUG = 4; 29 | 30 | //---------------------------------------------------------------------------- 31 | ctkLogStreamWithServiceRef::ctkLogStreamWithServiceRef(ctkLogService* logService, const ctkServiceReference& sr, 32 | int level, const std::exception* exc, const char* file, 33 | const char* function, int line) 34 | : ctkLogStream(logService, level, exc, file, function, line), sr(sr) 35 | { 36 | 37 | } 38 | 39 | //---------------------------------------------------------------------------- 40 | ctkLogStreamWithServiceRef::ctkLogStreamWithServiceRef(const ctkLogStreamWithServiceRef &logStreamWithRef) 41 | : ctkLogStream(logStreamWithRef), sr(logStreamWithRef.sr) 42 | { 43 | 44 | } 45 | 46 | //---------------------------------------------------------------------------- 47 | ctkLogStreamWithServiceRef::~ctkLogStreamWithServiceRef() 48 | { 49 | if (!logged) 50 | { 51 | logService->log(sr, level, msg, exc, file, function, line); 52 | logged = true; 53 | } 54 | } 55 | 56 | //---------------------------------------------------------------------------- 57 | ctkNullLogStream::ctkNullLogStream() : ctkLogStream(0, 0) 58 | {} 59 | 60 | //---------------------------------------------------------------------------- 61 | ctkNullLogStream::~ctkNullLogStream() 62 | { 63 | logged = true; 64 | } 65 | -------------------------------------------------------------------------------- /includes/pluginFramework/service/log/ctkLogStream.cpp: -------------------------------------------------------------------------------- 1 | /*============================================================================= 2 | 3 | Library: CTK 4 | 5 | Copyright (c) German Cancer Research Center, 6 | Division of Medical and Biological Informatics 7 | 8 | Licensed under the Apache License, Version 2.0 (the "License"); 9 | you may not use this file except in compliance with the License. 10 | You may obtain a copy of the License at 11 | 12 | http://www.apache.org/licenses/LICENSE-2.0 13 | 14 | Unless required by applicable law or agreed to in writing, software 15 | distributed under the License is distributed on an "AS IS" BASIS, 16 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | See the License for the specific language governing permissions and 18 | limitations under the License. 19 | 20 | =============================================================================*/ 21 | 22 | 23 | #include "ctkLogStream.h" 24 | #include "ctkLogService.h" 25 | 26 | //---------------------------------------------------------------------------- 27 | ctkLogStream::ctkLogStream(ctkLogService* logService, int level, const std::exception* exc, 28 | const char* file, const char* function, int line) 29 | : logged(false), logService(logService), level(level), exc(exc), 30 | file(file), function(function), line(line) 31 | { 32 | ts.setString(&msg); 33 | } 34 | 35 | //---------------------------------------------------------------------------- 36 | ctkLogStream::ctkLogStream(const ctkLogStream& logStream) 37 | : msg(logStream.msg), logged(false), 38 | logService(logStream.logService), level(logStream.level), 39 | exc(logStream.exc), file(logStream.file), function(logStream.function), 40 | line(logStream.line) 41 | { 42 | ts.setString(&msg); 43 | } 44 | 45 | //---------------------------------------------------------------------------- 46 | ctkLogStream::~ctkLogStream() 47 | { 48 | if (!logged && logService) 49 | { 50 | logService->log(level, msg, exc, file, function, line); 51 | } 52 | } 53 | 54 | -------------------------------------------------------------------------------- /includes/pluginFramework/service/log/ctkLogStream.h: -------------------------------------------------------------------------------- 1 | /*============================================================================= 2 | 3 | Library: CTK 4 | 5 | Copyright (c) German Cancer Research Center, 6 | Division of Medical and Biological Informatics 7 | 8 | Licensed under the Apache License, Version 2.0 (the "License"); 9 | you may not use this file except in compliance with the License. 10 | You may obtain a copy of the License at 11 | 12 | http://www.apache.org/licenses/LICENSE-2.0 13 | 14 | Unless required by applicable law or agreed to in writing, software 15 | distributed under the License is distributed on an "AS IS" BASIS, 16 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | See the License for the specific language governing permissions and 18 | limitations under the License. 19 | 20 | =============================================================================*/ 21 | 22 | 23 | #ifndef CTKLOGSTREAM_H 24 | #define CTKLOGSTREAM_H 25 | 26 | #include 27 | 28 | #include 29 | 30 | struct ctkLogService; 31 | 32 | /** 33 | * \ingroup LogService 34 | */ 35 | class CTK_PLUGINFW_EXPORT ctkLogStream 36 | { 37 | public: 38 | 39 | ctkLogStream(ctkLogService* logService, int level, const std::exception* exc = 0, 40 | const char* file = 0, const char* function = 0, int line = -1); 41 | ctkLogStream(const ctkLogStream& logStream); 42 | 43 | virtual ~ctkLogStream(); 44 | 45 | template 46 | ctkLogStream& operator <<(const T& t) 47 | { 48 | ts << t; 49 | return *this; 50 | } 51 | 52 | ctkLogStream& operator <<(const char* c) 53 | { 54 | ts << c; 55 | return *this; 56 | } 57 | 58 | ctkLogStream& operator <<(bool b) 59 | { 60 | ts << (b ? "true" : "false"); 61 | return *this; 62 | } 63 | 64 | protected: 65 | 66 | QString msg; 67 | QTextStream ts; 68 | bool logged; 69 | 70 | ctkLogService* logService; 71 | int level; 72 | const std::exception* exc; 73 | 74 | const char* file; 75 | const char* function; 76 | const int line; 77 | }; 78 | 79 | #endif // CTKLOGSTREAM_H 80 | -------------------------------------------------------------------------------- /includes/pluginFramework/service/metatype/ctkAttributeDefinition.cpp: -------------------------------------------------------------------------------- 1 | /*============================================================================= 2 | 3 | Library: CTK 4 | 5 | Copyright (c) German Cancer Research Center, 6 | Division of Medical and Biological Informatics 7 | 8 | Licensed under the Apache License, Version 2.0 (the "License"); 9 | you may not use this file except in compliance with the License. 10 | You may obtain a copy of the License at 11 | 12 | http://www.apache.org/licenses/LICENSE-2.0 13 | 14 | Unless required by applicable law or agreed to in writing, software 15 | distributed under the License is distributed on an "AS IS" BASIS, 16 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | See the License for the specific language governing permissions and 18 | limitations under the License. 19 | 20 | =============================================================================*/ 21 | 22 | #include "ctkAttributeDefinition.h" 23 | 24 | const int ctkAttributeDefinition::PASSWORD = qRegisterMetaType("PASSWORD"); 25 | 26 | -------------------------------------------------------------------------------- /includes/pluginFramework/service/metatype/ctkMetaTypeInformation.h: -------------------------------------------------------------------------------- 1 | /*============================================================================= 2 | 3 | Library: CTK 4 | 5 | Copyright (c) German Cancer Research Center, 6 | Division of Medical and Biological Informatics 7 | 8 | Licensed under the Apache License, Version 2.0 (the "License"); 9 | you may not use this file except in compliance with the License. 10 | You may obtain a copy of the License at 11 | 12 | http://www.apache.org/licenses/LICENSE-2.0 13 | 14 | Unless required by applicable law or agreed to in writing, software 15 | distributed under the License is distributed on an "AS IS" BASIS, 16 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | See the License for the specific language governing permissions and 18 | limitations under the License. 19 | 20 | =============================================================================*/ 21 | 22 | 23 | #ifndef CTKMETATYPEINFORMATION_H 24 | #define CTKMETATYPEINFORMATION_H 25 | 26 | #include "ctkMetaTypeProvider.h" 27 | 28 | #include 29 | 30 | class ctkPlugin; 31 | 32 | /** 33 | * \ingroup Metatype 34 | * 35 | * A MetaType Information object is created by the ctkMetaTypeService to return 36 | * meta type information for a specific plugin. 37 | */ 38 | struct ctkMetaTypeInformation : public ctkMetaTypeProvider 39 | { 40 | /** 41 | * Return the PIDs (for ManagedServices) for which ctkObjectClassDefinition 42 | * information is available. 43 | * 44 | * @return List of PIDs. 45 | */ 46 | virtual QStringList getPids() const = 0; 47 | 48 | /** 49 | * Return the Factory PIDs (for ManagedServiceFactories) for which 50 | * ctkObjectClassDefinition information is available. 51 | * 52 | * @return List of Factory PIDs. 53 | */ 54 | virtual QStringList getFactoryPids() const = 0; 55 | 56 | /** 57 | * Return the plugin for which this object provides meta type information. 58 | * 59 | * @return Plugin for which this object provides meta type information. 60 | */ 61 | virtual QSharedPointer getPlugin() const = 0; 62 | }; 63 | 64 | /** 65 | * \ingroup Metatype 66 | */ 67 | typedef QSharedPointer ctkMetaTypeInformationPtr; 68 | 69 | #endif // CTKMETATYPEINFORMATION_H 70 | -------------------------------------------------------------------------------- /includes/pluginFramework/service/metatype/ctkMetaTypeProvider.cpp: -------------------------------------------------------------------------------- 1 | /*============================================================================= 2 | 3 | Library: CTK 4 | 5 | Copyright (c) German Cancer Research Center, 6 | Division of Medical and Biological Informatics 7 | 8 | Licensed under the Apache License, Version 2.0 (the "License"); 9 | you may not use this file except in compliance with the License. 10 | You may obtain a copy of the License at 11 | 12 | http://www.apache.org/licenses/LICENSE-2.0 13 | 14 | Unless required by applicable law or agreed to in writing, software 15 | distributed under the License is distributed on an "AS IS" BASIS, 16 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | See the License for the specific language governing permissions and 18 | limitations under the License. 19 | 20 | =============================================================================*/ 21 | 22 | #include "ctkMetaTypeProvider.h" 23 | 24 | const QString ctkMetaTypeProvider::METATYPE_PID = "metatype.pid"; 25 | const QString ctkMetaTypeProvider::METATYPE_FACTORY_PID = "metatype.factory.pid"; 26 | 27 | -------------------------------------------------------------------------------- /includes/pluginFramework/service/metatype/ctkMetaTypeProvider.h: -------------------------------------------------------------------------------- 1 | /*============================================================================= 2 | 3 | Library: CTK 4 | 5 | Copyright (c) German Cancer Research Center, 6 | Division of Medical and Biological Informatics 7 | 8 | Licensed under the Apache License, Version 2.0 (the "License"); 9 | you may not use this file except in compliance with the License. 10 | You may obtain a copy of the License at 11 | 12 | http://www.apache.org/licenses/LICENSE-2.0 13 | 14 | Unless required by applicable law or agreed to in writing, software 15 | distributed under the License is distributed on an "AS IS" BASIS, 16 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | See the License for the specific language governing permissions and 18 | limitations under the License. 19 | 20 | =============================================================================*/ 21 | 22 | 23 | #ifndef CTKMETATYPEPROVIDER_H 24 | #define CTKMETATYPEPROVIDER_H 25 | 26 | #include "ctkObjectClassDefinition.h" 27 | #include 28 | 29 | #include 30 | 31 | /** 32 | * \ingroup Metatype 33 | * 34 | * Provides access to metatypes. This interface can be implemented on a Managed 35 | * Service or Managed Service Factory as well as registered as a service. When 36 | * registered as a service, it must be registered with a 37 | * {@link #METATYPE_FACTORY_PID} or {@link #METATYPE_PID} service property (or 38 | * both). Any PID mentioned in either of these factories must be a valid argument 39 | * to the {@link #getObjectClassDefinition(const QString&, const QLocale&)} method. 40 | */ 41 | struct CTK_PLUGINFW_EXPORT ctkMetaTypeProvider 42 | { 43 | 44 | /** 45 | * Service property to signal that this service has 46 | * {@link ctkObjectClassDefinition} objects for the given PIDs. The type of 47 | * this service property is QString. 48 | */ 49 | static const QString METATYPE_PID; // = "metatype.pid" 50 | 51 | /** 52 | * Service property to signal that this service has 53 | * {@link ctkObjectClassDefinition} objects for the given factory PIDs. The 54 | * type of this service property is QString. 55 | */ 56 | static const QString METATYPE_FACTORY_PID; // = "metatype.factory.pid" 57 | 58 | virtual ~ctkMetaTypeProvider() {} 59 | 60 | /** 61 | * Returns an object class definition for the specified id localized to the 62 | * specified locale. If no locale is specified, the default locale is used, 63 | * according to the default constructor of QLocale. 64 | * 65 | * @param id The ID of the requested object class. This can be a pid or 66 | * factory pid returned by getPids or getFactoryPids. 67 | * @param locale The locale of the definition 68 | * @return A ctkObjectClassDefinition object. 69 | */ 70 | virtual ctkObjectClassDefinitionPtr getObjectClassDefinition( 71 | const QString& id, const QLocale& locale = QLocale()) = 0; 72 | 73 | /** 74 | * Return a list of available locales. 75 | * 76 | * @return A list of QLocale objects. 77 | */ 78 | virtual QList getLocales() const = 0; 79 | 80 | }; 81 | 82 | Q_DECLARE_INTERFACE(ctkMetaTypeProvider, "org.commontk.service.metatype.MetaTypeProvider") 83 | 84 | #endif // CTKMETATYPEPROVIDER_H 85 | -------------------------------------------------------------------------------- /includes/pluginFramework/service/metatype/ctkMetaTypeService.cpp: -------------------------------------------------------------------------------- 1 | /*============================================================================= 2 | 3 | Library: CTK 4 | 5 | Copyright (c) German Cancer Research Center, 6 | Division of Medical and Biological Informatics 7 | 8 | Licensed under the Apache License, Version 2.0 (the "License"); 9 | you may not use this file except in compliance with the License. 10 | You may obtain a copy of the License at 11 | 12 | http://www.apache.org/licenses/LICENSE-2.0 13 | 14 | Unless required by applicable law or agreed to in writing, software 15 | distributed under the License is distributed on an "AS IS" BASIS, 16 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | See the License for the specific language governing permissions and 18 | limitations under the License. 19 | 20 | =============================================================================*/ 21 | 22 | #include "ctkMetaTypeService.h" 23 | 24 | const QString ctkMetaTypeService::METATYPE_DOCUMENTS_LOCATION = "CTK-INF/metatype"; 25 | 26 | -------------------------------------------------------------------------------- /includes/pluginFramework/service/metatype/ctkMetaTypeService.h: -------------------------------------------------------------------------------- 1 | /*============================================================================= 2 | 3 | Library: CTK 4 | 5 | Copyright (c) German Cancer Research Center, 6 | Division of Medical and Biological Informatics 7 | 8 | Licensed under the Apache License, Version 2.0 (the "License"); 9 | you may not use this file except in compliance with the License. 10 | You may obtain a copy of the License at 11 | 12 | http://www.apache.org/licenses/LICENSE-2.0 13 | 14 | Unless required by applicable law or agreed to in writing, software 15 | distributed under the License is distributed on an "AS IS" BASIS, 16 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | See the License for the specific language governing permissions and 18 | limitations under the License. 19 | 20 | =============================================================================*/ 21 | 22 | 23 | #ifndef CTKMETATYPESERVICE_H 24 | #define CTKMETATYPESERVICE_H 25 | 26 | #include "ctkMetaTypeInformation.h" 27 | 28 | /** 29 | * \ingroup Metatype 30 | * 31 | * The MetaType Service can be used to obtain meta type information for a 32 | * plugin. The MetaType Service will examine the specified plugin for meta type 33 | * documents to create the returned ctkMetaTypeInformation object. 34 | * 35 | *

36 | * If the specified plugin does not contain any meta type documents, then a 37 | * ctkMetaTypeInformation object will be returned that wraps any 38 | * ctkManagedService or ctkManagedServiceFactory 39 | * services registered by the specified plugin that implement 40 | * ctkMetaTypeProvider. Thus the MetaType Service can be used to 41 | * retrieve meta type information for plugins which contain meta type 42 | * documents or which provide their own ctkMetaTypeProvider objects. 43 | */ 44 | struct CTK_PLUGINFW_EXPORT ctkMetaTypeService 45 | { 46 | virtual ~ctkMetaTypeService() {} 47 | 48 | /** 49 | * Return the MetaType information for the specified plugin. 50 | * 51 | * @param plugin The plugin for which meta type information is requested. 52 | * @return A ctkMetaTypeInformation object for the specified plugin. 53 | */ 54 | virtual ctkMetaTypeInformationPtr getMetaTypeInformation(const QSharedPointer& plugin) = 0; 55 | 56 | /** 57 | * Location of meta type documents. The MetaType Service will process each 58 | * entry in the meta type documents directory. 59 | */ 60 | static const QString METATYPE_DOCUMENTS_LOCATION; // = "CTK-INF/metatype" 61 | }; 62 | 63 | Q_DECLARE_INTERFACE(ctkMetaTypeService, "org.commontk.service.metatype.MetaTypeServce") 64 | 65 | #endif // CTKMETATYPESERVICE_H 66 | -------------------------------------------------------------------------------- /libs/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Iyme/ctkExample/3e99e30049d0b2055fa3a9625ca7efbff273a94b/libs/.DS_Store -------------------------------------------------------------------------------- /libs/libCTKCore.0.1.0.dylib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Iyme/ctkExample/3e99e30049d0b2055fa3a9625ca7efbff273a94b/libs/libCTKCore.0.1.0.dylib -------------------------------------------------------------------------------- /libs/libCTKCore.0.1.dylib: -------------------------------------------------------------------------------- 1 | libCTKCore.0.1.0.dylib -------------------------------------------------------------------------------- /libs/libCTKCore.dylib: -------------------------------------------------------------------------------- 1 | libCTKCore.0.1.dylib -------------------------------------------------------------------------------- /libs/libCTKPluginFramework.0.1.0.dylib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Iyme/ctkExample/3e99e30049d0b2055fa3a9625ca7efbff273a94b/libs/libCTKPluginFramework.0.1.0.dylib -------------------------------------------------------------------------------- /libs/libCTKPluginFramework.0.1.dylib: -------------------------------------------------------------------------------- 1 | libCTKPluginFramework.0.1.0.dylib -------------------------------------------------------------------------------- /libs/libCTKPluginFramework.dylib: -------------------------------------------------------------------------------- 1 | libCTKPluginFramework.0.1.dylib -------------------------------------------------------------------------------- /libs/liborg_commontk_eventadmin.dylib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Iyme/ctkExample/3e99e30049d0b2055fa3a9625ca7efbff273a94b/libs/liborg_commontk_eventadmin.dylib --------------------------------------------------------------------------------