diff --git a/Applications/CoreApp/CMakeLists.txt b/Applications/CoreApp/CMakeLists.txt index 8044c1c25d..28a216b791 100644 --- a/Applications/CoreApp/CMakeLists.txt +++ b/Applications/CoreApp/CMakeLists.txt @@ -1,66 +1,68 @@ FIND_PACKAGE(BlueBerry REQUIRED) +INCLUDE(${QT_USE_FILE}) + INCLUDE_DIRECTORIES( ${BLUEBERRY_PLUGIN_SOURCE_DIRS} - ${org.blueberry.osgi_BIN_DIR} # needed for generated berryConfig.h + ${org_blueberry_osgi_INCLUDE_DIRS} ${Poco_INCLUDE_DIRS} + ${mbilog_INCLUDE_DIRS} ) -LINK_DIRECTORIES(${Poco_LIBRARY_DIRS} - ${BLUEBERRY_PLUGINS_OUTPUT_DIR}/org.blueberry.osgi/bin - ) + +LINK_DIRECTORIES(${Poco_LIBRARY_DIRS}) IF(MITK_SHOW_CONSOLE_WINDOW) ADD_EXECUTABLE(CoreApp MACOSX_BUNDLE CoreApp.cpp) ELSE(MITK_SHOW_CONSOLE_WINDOW) ADD_EXECUTABLE(CoreApp MACOSX_BUNDLE WIN32 CoreApp.cpp) ENDIF(MITK_SHOW_CONSOLE_WINDOW) IF (WIN32) FIND_PACKAGE(Qt4) TARGET_LINK_LIBRARIES(CoreApp ${QT_QTCORE_LIBRARY} ${QT_QTMAIN_LIBRARY}) ENDIF(WIN32) TARGET_LINK_LIBRARIES(CoreApp optimized PocoFoundation debug PocoFoundationd optimized PocoUtil debug PocoUtild - optimized org_blueberry_osgi debug org_blueberry_osgi${BLUEBERRY_DEBUG_POSTFIX}) + org_blueberry_osgi) -SET_TARGET_PROPERTIES(CoreApp PROPERTIES INSTALL_RPATH "${CMAKE_INSTALL_RPATH};${CMAKE_INSTALL_RPATH}/BlueBerry/org.blueberry.osgi/bin") +SET_TARGET_PROPERTIES(CoreApp PROPERTIES INSTALL_RPATH "${CMAKE_INSTALL_RPATH};${CMAKE_INSTALL_RPATH}/plugins") # subproject support ADD_DEPENDENCIES(MITK-CoreUI CoreApp) IF(MITK_ENABLE_GUI_TESTING) ADD_DEPENDENCIES(MITK-CoreUI solstice) ENDIF() SET(_plugin_deps ${BLUEBERRY_ENABLED_PLUGINS} ${MITK_CORE_ENABLED_PLUGINS} - ${MITK_CORE_ENABLED_TEST_PLUGINS} ) IF(_plugin_deps) # Make sure all enabled plug-ins are up to date ADD_DEPENDENCIES(CoreApp ${_plugin_deps}) ENDIF() SET(BLUEBERRY_PLUGIN_CACHE_DIR "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/plugin_cache") CONFIGURE_FILE(CoreApp.ini ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/CoreApp.ini) IF(WIN32) FOREACH(COREAPP_BUILD_TYPE debug release) mitkFunctionCreateWindowsBatchScript(startCoreApp.bat.in ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/startCoreApp_${COREAPP_BUILD_TYPE}.bat ${COREAPP_BUILD_TYPE}) ENDFOREACH() ENDIF(WIN32) MITK_INSTALL_TARGETS(EXECUTABLES CoreApp GLOB_PLUGINS ) +mitkFunctionInstallProvisioningFiles(${BLUEBERRY_PLUGIN_PROVISIONING_FILE} ${MITK_COREAPP_PROVISIONING_FILE}) IF(UNIX AND MITK_INSTALL_RPATH_RELATIVE AND NOT APPLE) INSTALL(PROGRAMS "${MITK_SOURCE_DIR}/CMake/RunInstalledApp.sh" DESTINATION "." RENAME CoreApp.sh) ENDIF() SET(MITK_CPACK_PACKAGE_EXECUTABLES ${MITK_CPACK_PACKAGE_EXECUTABLES} "CoreApp;MITK - CoreApp Application" CACHE INTERNAL "Collecting windows shortcuts to executables") diff --git a/Applications/CoreApp/CoreApp.cpp b/Applications/CoreApp/CoreApp.cpp index b2cda40088..d04ffc65c3 100644 --- a/Applications/CoreApp/CoreApp.cpp +++ b/Applications/CoreApp/CoreApp.cpp @@ -1,41 +1,86 @@ /*========================================================================= Program: Medical Imaging & Interaction Toolkit Language: C++ Date: $Date$ Version: $Revision$ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/ for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #include #include +#include +#include + +class QSafeApplication : public QApplication +{ + +public: + + QSafeApplication(int& argc, char** argv) + : QApplication(argc, argv) + {} + + /** + * Reimplement notify to catch unhandled exceptions and open an error message. + * + * @param receiver + * @param event + * @return + */ + bool notify(QObject* receiver, QEvent* event) + { + QString msg; + try + { + return QApplication::notify(receiver, event); + } catch (Poco::Exception& e) + { + msg = QString::fromStdString(e.displayText()); + } catch (std::exception& e) + { + msg = e.what(); + } catch (...) + { + msg = "Unknown exception"; + } + + QString + text( + "An error occurred. You should save all data and quit the program to prevent possible data loss.\nSee the error log for details.\n\n"); + text += msg; + QMessageBox::critical(0, "Error", text); + return false; + } + +}; + int main(int argc, char** argv) { + QSafeApplication safeApp(argc, argv); + safeApp.setApplicationName("CoreApp"); + safeApp.setOrganizationName("DKFZ"); + // These paths replace the .ini file and are tailored for installation // packages created with CPack. If a .ini file is presented, it will // overwrite the settings in MapConfiguration Poco::Path basePath(argv[0]); basePath.setFileName(""); - Poco::Path BlueBerryPath(basePath); - BlueBerryPath.pushDirectory("BlueBerry"); - - Poco::Path corePath(basePath); - corePath.pushDirectory("CoreBundles"); - - std::string pluginDirs = BlueBerryPath.toString() + ";" + corePath.toString(); + Poco::Path provFile(basePath); + provFile.setFileName("CoreApp.provisioning"); Poco::Util::MapConfiguration* coreConfig(new Poco::Util::MapConfiguration()); - coreConfig->setString(berry::Platform::ARG_PLUGIN_DIRS, pluginDirs); + coreConfig->setString(berry::Platform::ARG_PROVISIONING, provFile.toString()); coreConfig->setString(berry::Platform::ARG_APPLICATION, "org.mitk.qt.application"); return berry::Starter::Run(argc, argv, coreConfig); } diff --git a/Applications/CoreApp/CoreApp.ini b/Applications/CoreApp/CoreApp.ini index 1a39ed4fb4..ee36908a94 100644 --- a/Applications/CoreApp/CoreApp.ini +++ b/Applications/CoreApp/CoreApp.ini @@ -1,2 +1,2 @@ BlueBerry.home=@BLUEBERRY_BINARY_DIR@ -BlueBerry.plugin_dirs=@BLUEBERRY_PLUGINS_OUTPUT_DIR@;@MITK_CORE_PLUGIN_OUTPUT_DIRS@ +BlueBerry.provisioning=@MITK_COREAPP_PROVISIONING_FILE@ diff --git a/Applications/CoreApp/startCoreApp.bat.in b/Applications/CoreApp/startCoreApp.bat.in index d5f10e309a..67f373f6c8 100644 --- a/Applications/CoreApp/startCoreApp.bat.in +++ b/Applications/CoreApp/startCoreApp.bat.in @@ -1,2 +1,2 @@ -PATH=@VTK_LIBRARY_DIRS@\@COREAPP_BUILD_TYPE@;@ITK_LIBRARY_DIRS@\@COREAPP_BUILD_TYPE@;@GDCM_BIN_DIR@;@QT_LIBRARY_DIR@\..\bin;@BLUEBERRY_PLUGINS_OUTPUT_DIR@\org.blueberry.osgi\bin\@COREAPP_BUILD_TYPE@ +PATH=@MITK_RUNTIME_PATH@;%PATH% @COREAPP_BUILD_TYPE@\CoreApp.exe diff --git a/Applications/ExtApp/CMakeLists.txt b/Applications/ExtApp/CMakeLists.txt index 6eced226e2..cb642d3637 100644 --- a/Applications/ExtApp/CMakeLists.txt +++ b/Applications/ExtApp/CMakeLists.txt @@ -1,60 +1,66 @@ FIND_PACKAGE(BlueBerry REQUIRED) # TODO: this can be removed after resolving factory issues, it's only necessary for the registration call in main() MITK_USE_MODULE(MitkExt) +INCLUDE(${QT_USE_FILE}) + INCLUDE_DIRECTORIES( ${BLUEBERRY_PLUGIN_SOURCE_DIRS} - ${org.blueberry.osgi_BIN_DIR} # needed for generated berryConfig.h + ${org_blueberry_osgi_INCLUDE_DIRS} ${Poco_INCLUDE_DIRS} ${ALL_INCLUDE_DIRECTORIES} ) -LINK_DIRECTORIES(${Poco_LIBRARY_DIRS} - ${BLUEBERRY_PLUGINS_OUTPUT_DIR}/org.blueberry.osgi/bin - ) + +LINK_DIRECTORIES(${Poco_LIBRARY_DIRS}) IF(MITK_SHOW_CONSOLE_WINDOW) ADD_EXECUTABLE(ExtApp MACOSX_BUNDLE ExtApp.cpp) ELSE(MITK_SHOW_CONSOLE_WINDOW) ADD_EXECUTABLE(ExtApp MACOSX_BUNDLE WIN32 ExtApp.cpp) ENDIF(MITK_SHOW_CONSOLE_WINDOW) IF (WIN32) FIND_PACKAGE(Qt4) TARGET_LINK_LIBRARIES(ExtApp ${QT_QTCORE_LIBRARY} ${QT_QTMAIN_LIBRARY}) ENDIF(WIN32) TARGET_LINK_LIBRARIES(ExtApp optimized PocoFoundation debug PocoFoundationd optimized PocoUtil debug PocoUtild - optimized org_blueberry_osgi debug org_blueberry_osgi${BLUEBERRY_DEBUG_POSTFIX} + org_blueberry_osgi ${ALL_LIBRARIES}) -SET_TARGET_PROPERTIES(ExtApp PROPERTIES INSTALL_RPATH "${CMAKE_INSTALL_RPATH};${CMAKE_INSTALL_RPATH}/BlueBerry/org.blueberry.osgi/bin") +SET_TARGET_PROPERTIES(ExtApp PROPERTIES INSTALL_RPATH "${CMAKE_INSTALL_RPATH};${CMAKE_INSTALL_RPATH}/plugins") -SET(_plugin_deps ${BLUEBERRY_ENABLED_PLUGINS} ${MITK_CORE_ENABLED_PLUGINS} ${MITK_MODULES_ENABLED_PLUGINS}) +SET(_plugin_deps + ${BLUEBERRY_ENABLED_PLUGINS} + ${MITK_EXT_ENABLED_PLUGINS} + ${MITK_MODULES_ENABLED_PLUGINS} + ) IF(_plugin_deps) # Make sure all enabled plug-ins are up to date ADD_DEPENDENCIES(ExtApp ${_plugin_deps}) ENDIF() SET(BLUEBERRY_PLUGIN_CACHE_DIR "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/plugin_cache") CONFIGURE_FILE(ExtApp.ini ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/ExtApp.ini) IF(WIN32) FOREACH(EXTAPP_BUILD_TYPE debug release) mitkFunctionCreateWindowsBatchScript(startExtApp.bat.in ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/startExtApp_${EXTAPP_BUILD_TYPE}.bat ${EXTAPP_BUILD_TYPE}) ENDFOREACH() ENDIF(WIN32) MITK_INSTALL_TARGETS(EXECUTABLES ExtApp GLOB_PLUGINS ) +mitkFunctionInstallProvisioningFiles(${BLUEBERRY_PLUGIN_PROVISIONING_FILE} ${MITK_EXTAPP_PROVISIONING_FILE}) IF(UNIX AND MITK_INSTALL_RPATH_RELATIVE AND NOT APPLE) INSTALL(PROGRAMS "${MITK_SOURCE_DIR}/CMake/RunInstalledApp.sh" DESTINATION "." RENAME ExtApp.sh) ENDIF() SET(MITK_CPACK_PACKAGE_EXECUTABLES ${MITK_CPACK_PACKAGE_EXECUTABLES} "ExtApp;MITK - ExtApp Application" CACHE INTERNAL "Collecting windows shortcuts to executables") diff --git a/Applications/ExtApp/ExtApp.cpp b/Applications/ExtApp/ExtApp.cpp index eaeff11f51..b6d0eb8440 100644 --- a/Applications/ExtApp/ExtApp.cpp +++ b/Applications/ExtApp/ExtApp.cpp @@ -1,47 +1,97 @@ /*========================================================================= Program: Medical Imaging & Interaction Toolkit Language: C++ Date: $Date$ Version: $Revision$ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/ for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #include #include #include +#include +#include + +class QtSafeApplication : public QApplication +{ + +public: + + QtSafeApplication(int& argc, char** argv) : QApplication(argc, argv) + {} + + /** + * Reimplement notify to catch unhandled exceptions and open an error message. + * + * @param receiver + * @param event + * @return + */ + bool notify(QObject* receiver, QEvent* event) + { + QString msg; + try + { + return QApplication::notify(receiver, event); + } + catch (Poco::Exception& e) + { + msg = QString::fromStdString(e.displayText()); + } + catch (std::exception& e) + { + msg = e.what(); + } + catch (...) + { + msg = "Unknown exception"; + } + + QString text("An error occurred. You should save all data and quit the program to " + "prevent possible data loss.\nSee the error log for details.\n\n"); + text += msg; + + QMessageBox::critical(0, "Error", text); + return false; + } + +}; + int main(int argc, char** argv) { - + // Create a QApplication instance first + QtSafeApplication qSafeApp(argc, argv); + qSafeApp.setApplicationName("ExtApp"); + qSafeApp.setOrganizationName("DKFZ"); + RegisterCoreExtObjectFactory(); // These paths replace the .ini file and are tailored for installation // packages created with CPack. If a .ini file is presented, it will // overwrite the settings in MapConfiguration Poco::Path basePath(argv[0]); basePath.setFileName(""); - Poco::Path BlueBerryPath(basePath); - BlueBerryPath.pushDirectory("BlueBerry"); - - Poco::Path corePath(basePath); - corePath.pushDirectory("CoreBundles"); + Poco::Path provFile(basePath); + provFile.setFileName("ExtApp.provisioning"); Poco::Path extPath(basePath); extPath.pushDirectory("ExtBundles"); - std::string pluginDirs = BlueBerryPath.toString() + ";" + corePath.toString() + ";" + extPath.toString(); + std::string pluginDirs = extPath.toString(); Poco::Util::MapConfiguration* extConfig(new Poco::Util::MapConfiguration()); extConfig->setString(berry::Platform::ARG_PLUGIN_DIRS, pluginDirs); + extConfig->setString(berry::Platform::ARG_PROVISIONING, provFile.toString()); extConfig->setString(berry::Platform::ARG_APPLICATION, "org.mitk.qt.extapplication"); return berry::Starter::Run(argc, argv, extConfig); } diff --git a/Applications/ExtApp/ExtApp.ini b/Applications/ExtApp/ExtApp.ini index 4294aae6aa..911309235a 100644 --- a/Applications/ExtApp/ExtApp.ini +++ b/Applications/ExtApp/ExtApp.ini @@ -1,2 +1,3 @@ BlueBerry.home=@BLUEBERRY_BINARY_DIR@ -BlueBerry.plugin_dirs=@BLUEBERRY_PLUGINS_OUTPUT_DIR@;@MITK_CORE_PLUGIN_OUTPUT_DIRS@;@MITK_MODULES_PLUGIN_OUTPUT_DIRS@ +BlueBerry.plugin_dirs=@MITK_MODULES_PLUGIN_OUTPUT_DIRS@ +BlueBerry.provisioning=@MITK_EXTAPP_PROVISIONING_FILE@ diff --git a/Applications/ExtApp/startExtApp.bat.in b/Applications/ExtApp/startExtApp.bat.in index 1675d15f23..3cb5835ce4 100644 --- a/Applications/ExtApp/startExtApp.bat.in +++ b/Applications/ExtApp/startExtApp.bat.in @@ -1,2 +1,2 @@ -PATH=@VTK_LIBRARY_DIRS@\@EXTAPP_BUILD_TYPE@;@ITK_LIBRARY_DIRS@\@EXTAPP_BUILD_TYPE@;@GDCM_BIN_DIR@;@QT_LIBRARY_DIR@\..\bin;@BLUEBERRY_PLUGINS_OUTPUT_DIR@\org.blueberry.osgi\bin\@EXTAPP_BUILD_TYPE@ +PATH=@MITK_RUNTIME_PATH@;%PATH% @EXTAPP_BUILD_TYPE@\ExtApp.exe diff --git a/BlueBerry/BlueBerryConfig.cmake.in b/BlueBerry/BlueBerryConfig.cmake.in index b803e348eb..01fe03bdf8 100644 --- a/BlueBerry/BlueBerryConfig.cmake.in +++ b/BlueBerry/BlueBerryConfig.cmake.in @@ -1,35 +1,55 @@ SET(BLUEBERRY_PLUGINS_SOURCE_DIR "@BLUEBERRY_PLUGINS_SOURCE_DIR@") SET(BLUEBERRY_PLUGINS_BINARY_DIR "@BLUEBERRY_PLUGINS_BINARY_DIR@") SET(BLUEBERRY_PLUGIN_SOURCE_DIRS "@BLUEBERRY_PLUGINS_SOURCE_DIR@") SET(BLUEBERRY_PLUGINS_OUTPUT_DIR "@BLUEBERRY_PLUGINS_OUTPUT_DIR@") SET(BLUEBERRY_SOURCE_DIR "@BLUEBERRY_SOURCE_DIR@") SET(BlueBerry_SOURCE_DIR "@BLUEBERRY_SOURCE_DIR@") SET(BLUEBERRY_BINARY_DIR "@BLUEBERRY_BINARY_DIR@") +INCLUDE("@BB_PLUGIN_USE_FILE@") + +IF(NOT BB_PLUGIN_EXPORTS_FILE_INCLUDED AND NOT CMAKE_PROJECT_NAME STREQUAL "MITK") + INCLUDE("@BB_PLUGIN_EXPORTS_FILE@") + SET(BB_PLUGIN_EXPORTS_FILE_INCLUDED 1) +ENDIF() + SET(BLUEBERRY_DEBUG_POSTFIX @BLUEBERRY_DEBUG_POSTFIX@) SET(BLUEBERRY_USE_QT_HELP @BLUEBERRY_USE_QT_HELP@) SET(QT_HELPGENERATOR_EXECUTABLE "@QT_HELPGENERATOR_EXECUTABLE@") SET(QT_COLLECTIONGENERATOR_EXECUTABLE "@QT_COLLECTIONGENERATOR_EXECUTABLE@") SET(QT_ASSISTANT_EXECUTABLE "@QT_ASSISTANT_EXECUTABLE@") -SET(BLUEBERRY_DOXYGEN_TAGFILE_NAME @BLUEBERRY_DOXYGEN_TAGFILE_NAME@) +SET(CTK_DIR "@CTK_DIR@") +FIND_PACKAGE(CTK REQUIRED) + +SET(BLUEBERRY_PLUGIN_TARGETS @my_plugin_targets@) +SET(BLUEBERRY_ENABLED_PLUGINS @my_plugin_targets@) +SET(CTK_PLUGIN_LIBRARIES ${CTK_PLUGIN_LIBRARIES} @my_plugin_targets@) -INCLUDE("@BLUEBERRY_BINARY_DIR@/BlueBerryBundleList.cmake") +SET(BLUEBERRY_PLUGIN_PROVISIONING_FILE "@BLUEBERRY_PROVISIONING_FILE@") + +SET(BLUEBERRY_DOXYGEN_TAGFILE_NAME @BLUEBERRY_DOXYGEN_TAGFILE_NAME@) SET(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "@BLUEBERRY_SOURCE_DIR@/CMake") FIND_PACKAGE(Poco REQUIRED) +SET(mbilog_DIR "@mbilog_DIR@") +FIND_PACKAGE(mbilog REQUIRED) + INCLUDE(MacroParseArguments) INCLUDE(MacroConvertSchema) INCLUDE(MacroOrganizeSources) INCLUDE(berryPluginHelpers) INCLUDE(MacroCollectPlugins) INCLUDE(MacroParseManifest) INCLUDE(MacroCreatePlugin) INCLUDE(MacroCreateQtHelp) INCLUDE(MacroInstallPlugin) +INCLUDE(MacroInstallCTKPlugin) INCLUDE(MacroInstallThirdPartyPlugins) +INCLUDE(FunctionInstallThirdPartyCTKPlugins) +INCLUDE(FunctionCreateProvisioningFile) diff --git a/BlueBerry/Build/BundleGenerator/CMakeLists.txt b/BlueBerry/Build/BundleGenerator/CMakeLists.txt index 385257b940..221ca83f1c 100644 --- a/BlueBerry/Build/BundleGenerator/CMakeLists.txt +++ b/BlueBerry/Build/BundleGenerator/CMakeLists.txt @@ -1,302 +1,302 @@ PROJECT(BlueBerryPluginGenerator) CMAKE_MINIMUM_REQUIRED(VERSION 2.6) MARK_AS_ADVANCED( CMAKE_BACKWARDS_COMPATIBILITY CMAKE_INSTALL_PREFIX CMAKE_BUILD_TYPE) FIND_FILE(PLUGIN_TEMPLATE BundleTemplate ${PROJECT_SOURCE_DIR}/../../CMake DOC "Path to the plugin templates") IF(BUNDLE_DEFAULTS_FILE) IF(EXISTS "${BUNDLE_DEFAULTS_FILE}") INCLUDE(${BUNDLE_DEFAULTS_FILE}) ELSE(EXISTS "${BUNDLE_DEFAULTS_FILE}") MESSAGE(SEND_ERROR "cannot find supplied defaults file: ${BUNDLE_DEFAULTS_FILE}") ENDIF(EXISTS "${BUNDLE_DEFAULTS_FILE}") ELSE(BUNDLE_DEFAULTS_FILE) INCLUDE(${PLUGIN_TEMPLATE}/BundleDefaults.cmake) ENDIF(BUNDLE_DEFAULTS_FILE) SET(PLUGIN_ID "${DEFAULT_PLUGIN_ID}" CACHE STRING "unique plugin id (i.e. your.domain.pluginid) (required)") SET(PLUGIN_NAME "" CACHE STRING "a human-readable description of your plugin (required)") SET(CUSTOM_PROJECT_NAME "" CACHE STRING "Your project name (optional)") OPTION(GUI_SUPPORT "enable this if your plugin contributes to the UI" ON) STRING(REPLACE " " "" CUSTOM_PROJECT_NAME_NOWS "${CUSTOM_PROJECT_NAME}") SET(CUSTOM_PROJECT_NAME "${CUSTOM_PROJECT_NAME_NOWS}" CACHE STRING "Your project name (optional)" FORCE) IF(PLUGIN_ID AND PLUGIN_NAME) SET(PLUGIN_VERSION "${DEFAULT_PLUGIN_VERSION}" CACHE STRING "plugin version (required)") SET(PLUGIN_VENDOR "${DEFAULT_PLUGIN_VENDOR}" CACHE STRING "plugin vendor (optional)") SET(ACTIVATOR_CLASS "" CACHE STRING "class name for your plugin activator (optional)") IF(GUI_SUPPORT) STRING(REGEX REPLACE "[^a-zA-Z_]" "" _view_baseid "${PLUGIN_NAME}") STRING(TOLOWER ${_view_baseid} _lview_baseid) SET(_default_view_class_name "${DEFAULT_VIEW_CLASS_BEGIN}${_view_baseid}View") SET(VIEW_NAME "${PLUGIN_NAME}" CACHE STRING "a human-readable name of your view (required)") SET(VIEW_CLASS "${_default_view_class_name}" CACHE STRING "class name of the view") IF(VIEW_CLASS) STRING(TOUPPER ${VIEW_CLASS} UVIEW_CLASS) ENDIF(VIEW_CLASS) SET(VIEW_BASE_CLASS ${DEFAULT_VIEW_BASE_CLASS} CACHE STRING "base class of your new view class (required)") SET(VIEW_BASE_CLASS_H ${DEFAULT_VIEW_BASE_CLASS_H} CACHE STRING "base class header (required)") SET(VIEW_ID "${DEFAULT_VIEW_BASEID}${_lview_baseid}" CACHE STRING "unique view id (i.e. your.domain.viewid) (required)") #SET(EDITOR_CLASS "" CACHE STRING "") #SET(EDITOR_TYPE "" CACHE STRING "") ENDIF(GUI_SUPPORT) #SET(GENERATE_SERVICE "" CACHE STRING "") #SET(GENERATE_SERVICE_CLASS "" CACHE STRING "") SET(_required_bundles ${DEFAULT_REQUIRED_BUNDLES}) IF(GUI_SUPPORT) SET(_required_bundles ${DEFAULT_REQUIRED_BUNDLES_FOR_GUI}) ENDIF(GUI_SUPPORT) SET(REQUIRED_PLUGINS ${_required_bundles} CACHE STRING "a semicolon-separated list of required plugins (optional)") IF(ACTIVATOR_CLASS) SET(FULLY_QUALIFIED_ACTIVATOR "${BUNDLE_NAMESPACE}::${ACTIVATOR_CLASS}") STRING(TOUPPER ${ACTIVATOR_CLASS} UACTIVATOR_CLASS) IF(GUI_SUPPORT) SET(ACTIVATOR_BASE_CLASS "berry::AbstractUIPlugin") SET(ACTIVATOR_BASE_CLASS_H "berryAbstractUIPlugin.h") ELSE() SET(ACTIVATOR_BASE_CLASS "berry::Plugin") SET(ACTIVATOR_BASE_CLASS_H "berryPlugin.h") ENDIF() ELSE(ACTIVATOR_CLASS) SET(FULLY_QUALIFIED_ACTIVATOR "") ENDIF(ACTIVATOR_CLASS) SET(PROJECT_DIR "${CMAKE_CURRENT_BINARY_DIR}/${CUSTOM_PROJECT_NAME}") IF(CUSTOM_PROJECT_NAME) SET(PLUGIN_DIR "${PROJECT_DIR}/Bundles/${PLUGIN_ID}") ELSE(CUSTOM_PROJECT_NAME) SET(PLUGIN_DIR "${PROJECT_DIR}/${PLUGIN_ID}") ENDIF(CUSTOM_PROJECT_NAME) IF(NOT EXISTS "${PLUGIN_TEMPLATE}/META-INF/MANIFEST_TEMPLATE.MF") MESSAGE(FATAL_ERROR "Could not find ${PLUGIN_TEMPLATE}/META-INF/MANIFEST_TEMPLATE.MF!") ENDIF(NOT EXISTS "${PLUGIN_TEMPLATE}/META-INF/MANIFEST_TEMPLATE.MF") # ====================== PROJECT FILES =============================== IF(CUSTOM_PROJECT_NAME AND EXISTS "${PLUGIN_TEMPLATE}/project/CMakeListsTemplate.txt") SET(CUSTOM_PROJECT_EXECUTABLE ${CUSTOM_PROJECT_NAME} CACHE STRING "the name of your project's executable") IF(GUI_SUPPORT) SET(FIND_PACKAGE_QT4 "FIND_PACKAGE(Qt4 REQUIRED)") ENDIF(GUI_SUPPORT) SET(BLUEBERRY_BINARY_DIR "@BLUEBERRY_BINARY_DIR@") SET(BLUEBERRY_PLUGINS_OUTPUT_DIR "@BLUEBERRY_PLUGINS_OUTPUT_DIR@") SET(PLUGIN_CACHE_DIR "@PLUGIN_CACHE_DIR@") SET(PLUGIN_BINARY_DIRS "@PLUGIN_BINARY_DIRS@") SET(MITK_PLUGIN_BINARY_DIRS "@MITK_PLUGIN_BINARY_DIRS@") - SET(BATCH_FILE_PATH "@MITK_LIBRARY_DIRS@\\@APP_BUILD_TYPE@;@MITK_VTK_LIBRARY_DIRS@\\@APP_BUILD_TYPE@;@MITK_ITK_LIBRARY_DIRS@\\@APP_BUILD_TYPE@;@GDCM_BIN_DIR@;@QT_LIBRARY_DIR@\\..\\bin;@BLUEBERRY_PLUGINS_OUTPUT_DIR@\\org.blueberry.osgi\\bin\\@APP_BUILD_TYPE@") - SET(BATCH_FILE_VS_PATH "@MITK_LIBRARY_DIRS@\\@APP_BUILD_TYPE@;@MITK_VTK_LIBRARY_DIRS@\\@APP_BUILD_TYPE@;@MITK_ITK_LIBRARY_DIRS@\\@APP_BUILD_TYPE@;@GDCM_BIN_DIR@;@QT_LIBRARY_DIR@\\..\\bin;@BLUEBERRY_PLUGINS_OUTPUT_DIR@\\org.blueberry.osgi\\bin\\@APP_BUILD_TYPE@") + SET(BATCH_FILE_PATH "@MITK_RUNTIME_PATH@;@CMAKE_RUNTIME_OUTPUT_DIRECTORY@/@VS_BUILD_TYPE@") + SET(BATCH_FILE_VS_PATH ${BATCH_FILE_PATH}) SET(BATCH_FILE_EXEC_CMD "@APP_BUILD_TYPE@\\${CUSTOM_PROJECT_EXECUTABLE}.exe") SET(BATCH_FILE_VS_EXEC_CMD "\@PROJECT_BINARY_DIR\@/${CUSTOM_PROJECT_NAME}.sln") CONFIGURE_FILE("${PLUGIN_TEMPLATE}/project/CMakeListsTemplate.txt" "${PROJECT_DIR}/CMakeLists.txt" @ONLY) CONFIGURE_FILE("${PLUGIN_TEMPLATE}/project/Bundles/CMakeListsTemplate.txt" "${PROJECT_DIR}/Bundles/CMakeLists.txt" @ONLY) CONFIGURE_FILE("${PLUGIN_TEMPLATE}/project/AppTemplate.cpp" "${PROJECT_DIR}/${CUSTOM_PROJECT_EXECUTABLE}.cpp" @ONLY) CONFIGURE_FILE("${PLUGIN_TEMPLATE}/project/AppTemplate.ini" "${PROJECT_DIR}/${CUSTOM_PROJECT_EXECUTABLE}.ini" COPYONLY) CONFIGURE_FILE("${PLUGIN_TEMPLATE}/project/startAppTemplate.bat" "${PROJECT_DIR}/start${CUSTOM_PROJECT_EXECUTABLE}.bat.in" @ONLY) CONFIGURE_FILE("${PLUGIN_TEMPLATE}/project/startVS2008Template.bat" "${PROJECT_DIR}/startVS2008.bat.in" @ONLY) ENDIF() # ====================== END PROJECT FILES =========================== STRING(REPLACE . _ NormalizedPluginID ${PLUGIN_ID}) STRING(TOUPPER ${NormalizedPluginID} UNormalizedPluginID) # ----- START cut plugin_ID from last '.' till end ------------ SET(LAST_PART_PLUGIN_ID ${PLUGIN_ID}) STRING(REGEX MATCH "\\.[^\\.]*$" LAST_PART_PLUGIN_ID ${LAST_PART_PLUGIN_ID}) STRING(LENGTH ${LAST_PART_PLUGIN_ID} LengthStr) MATH(EXPR LengthStr "${LengthStr}-1") STRING(SUBSTRING ${LAST_PART_PLUGIN_ID} 1 ${LengthStr} LAST_PART_PLUGIN_ID) MATH(EXPR LengthStr "${LengthStr}-1") STRING(SUBSTRING ${LAST_PART_PLUGIN_ID} 0 1 LAST_PART_PLUGIN_ID_FIRST_LETTER) STRING(TOUPPER ${LAST_PART_PLUGIN_ID_FIRST_LETTER} LAST_PART_PLUGIN_ID_FIRST_LETTER) STRING(SUBSTRING ${LAST_PART_PLUGIN_ID} 1 ${LengthStr} LAST_PART_PLUGIN_ID_REST) SET(LAST_PART_PLUGIN_ID ${LAST_PART_PLUGIN_ID_FIRST_LETTER}${LAST_PART_PLUGIN_ID_REST}) STRING(TOUPPER ${LAST_PART_PLUGIN_ID} ULAST_PART_PLUGIN_ID) # ------ END -------------------------------------------------- # --------------------- META-INF/MANIFEST_TEMPLATE.MF --------------------- SET(REQUIRED_PLUGINS_MF "${REQUIRED_PLUGINS}") STRING(REPLACE ";" "," REQUIRED_PLUGINS_MF "${REQUIRED_PLUGINS_MF}" ) CONFIGURE_FILE(${PLUGIN_TEMPLATE}/META-INF/MANIFEST_TEMPLATE.MF ${PLUGIN_DIR}/META-INF/MANIFEST.MF @ONLY) # ----------------- documentation/doxygen/modulesTemplate.dox ------------ IF(DOXYGEN_INGROUP) SET(DOXYGEN_INGROUP_CMD "\\ingroup ${DOXYGEN_INGROUP}") ENDIF(DOXYGEN_INGROUP) CONFIGURE_FILE(${PLUGIN_TEMPLATE}/documentation/doxygen/modulesTemplate.dox ${PLUGIN_DIR}/documentation/doxygen/modules.dox @ONLY) # ----------------- documentation/Manual/Manual.dox ------------ CONFIGURE_FILE(${PLUGIN_TEMPLATE}/documentation/Manual/Manual.dox ${PLUGIN_DIR}/documentation/Manual/Manual.dox @ONLY) CONFIGURE_FILE(${PLUGIN_TEMPLATE}/documentation/Manual/icon.png ${PLUGIN_DIR}/documentation/Manual/icon.png @ONLY) # ----------------- resources directory --------------------------------- IF(GUI_SUPPORT) FILE(MAKE_DIRECTORY ${PLUGIN_DIR}/resources) IF(EXISTS ${PLUGIN_TEMPLATE}/resources/qtresources.qrc) CONFIGURE_FILE(${PLUGIN_TEMPLATE}/resources/qtresources.qrc ${PLUGIN_DIR}/resources/${VIEW_CLASS}.qrc @ONLY) ENDIF(EXISTS ${PLUGIN_TEMPLATE}/resources/qtresources.qrc) IF(EXISTS ${PLUGIN_TEMPLATE}/resources/icon.xpm) CONFIGURE_FILE(${PLUGIN_TEMPLATE}/resources/icon.xpm ${PLUGIN_DIR}/resources/icon.xpm @ONLY) ENDIF(EXISTS ${PLUGIN_TEMPLATE}/resources/icon.xpm) ENDIF() # -------------------- BundleDllTemplate.h ------------------------------- IF(EXISTS ${PLUGIN_TEMPLATE}/src/BundleDllTemplate.h) IF(BUNDLE_NAMESPACE) STRING(TOUPPER ${BUNDLE_NAMESPACE} UBUNDLE_NAMESPACE) ENDIF(BUNDLE_NAMESPACE) IF(UBUNDLE_NAMESPACE) SET(DLL_DEFINE "${UBUNDLE_NAMESPACE}_${ULAST_PART_PLUGIN_ID}_EXPORT") ELSE(UBUNDLE_NAMESPACE) SET(DLL_DEFINE "${ULAST_PART_PLUGIN_ID}_EXPORT") ENDIF(UBUNDLE_NAMESPACE) SET(Dll_HEADER ${BUNDLE_NAMESPACE}${LAST_PART_PLUGIN_ID}Dll.h) CONFIGURE_FILE(${PLUGIN_TEMPLATE}/src/BundleDllTemplate.h ${PLUGIN_DIR}/src/${Dll_HEADER} @ONLY) ENDIF(EXISTS ${PLUGIN_TEMPLATE}/src/BundleDllTemplate.h) # --------------------- src/internal/ViewTemplateControls.ui ---------------------------- IF (GUI_SUPPORT) IF(EXISTS ${PLUGIN_TEMPLATE}/src/internal/ControlsTemplate.ui) SET(VIEW_CONTROLS "${VIEW_CLASS}Controls") SET(VIEW_CONTROLS_UI "${VIEW_CONTROLS}.ui") SET(VIEW_CONTROLS_FILE "ui_${VIEW_CONTROLS}.h") SET(VIEW_CONTROLS_CLASS "${VIEW_CONTROLS}") CONFIGURE_FILE(${PLUGIN_TEMPLATE}/src/internal/ControlsTemplate.ui ${PLUGIN_DIR}/src/internal/${VIEW_CONTROLS_UI} @ONLY) ENDIF(EXISTS ${PLUGIN_TEMPLATE}/src/internal/ControlsTemplate.ui) ENDIF() # --------------------- src/internal/ViewTemplate[.h,.cpp] ---------------------------- IF(VIEW_CLASS) SET(VIEW_CLASS_H "${BUNDLE_NAMESPACE}${VIEW_CLASS}.h") SET(VIEW_CLASS_CPP "${BUNDLE_NAMESPACE}${VIEW_CLASS}.cpp") IF(BUNDLE_NAMESPACE) SET(BEGIN_NAMESPACE "namespace ${BUNDLE_NAMESPACE} {") SET(END_NAMESPACE "} //namespace ${BUNDLE_NAMESPACE}") ENDIF(BUNDLE_NAMESPACE) CONFIGURE_FILE(${PLUGIN_TEMPLATE}/src/internal/ViewTemplate.h ${PLUGIN_DIR}/src/internal/${VIEW_CLASS_H} @ONLY) CONFIGURE_FILE(${PLUGIN_TEMPLATE}/src/internal/ViewTemplate.cpp ${PLUGIN_DIR}/src/internal/${VIEW_CLASS_CPP} @ONLY) ENDIF(VIEW_CLASS) # ---------------------- pluginTemplate.xml --------------------------------- IF(VIEW_CLASS) SET(XP_VIEW " " ) ENDIF(VIEW_CLASS) CONFIGURE_FILE(${PLUGIN_TEMPLATE}/pluginTemplate.xml ${PLUGIN_DIR}/plugin.xml @ONLY) # ----------------------- ActivatorTemplate[.h,.cpp] ------------------------ IF(ACTIVATOR_CLASS) SET(ACTIVATOR_CLASS_H "${BUNDLE_NAMESPACE}${ACTIVATOR_CLASS}.h") SET(ACTIVATOR_CLASS_CPP "${BUNDLE_NAMESPACE}${ACTIVATOR_CLASS}.cpp") IF(BUNDLE_NAMESPACE) SET(BEGIN_NAMESPACE "namespace ${BUNDLE_NAMESPACE} {") SET(END_NAMESPACE "} //namespace ${BUNDLE_NAMESPACE}") ENDIF(BUNDLE_NAMESPACE) CONFIGURE_FILE(${PLUGIN_TEMPLATE}/src/internal/ActivatorTemplate.h ${PLUGIN_DIR}/src/internal/${ACTIVATOR_CLASS_H} @ONLY) CONFIGURE_FILE(${PLUGIN_TEMPLATE}/src/internal/ActivatorTemplate.cpp ${PLUGIN_DIR}/src/internal/${ACTIVATOR_CLASS_CPP} @ONLY) ENDIF() # ----------------------- manifestTemplate.cpp ---------------------------- IF(VIEW_CLASS) SET(SET_MANIFEST_SRC "SET(CPP_FILES manifest.cpp)") SET(MANIFEST_VIEW_ENTRY "#include \"src/internal/${VIEW_CLASS_H}\" POCO_BEGIN_NAMED_MANIFEST(berryIViewPart, berry::IViewPart) POCO_EXPORT_CLASS(${BUNDLE_NAMESPACE}::${VIEW_CLASS}) POCO_END_MANIFEST") ENDIF(VIEW_CLASS) IF(ACTIVATOR_CLASS) SET(SET_MANIFEST_SRC "SET(CPP_FILES manifest.cpp)") SET(MANIFEST_ACTIVATOR_ENTRY "#include \"src/internal/${ACTIVATOR_CLASS_H}\" POCO_BEGIN_MANIFEST(berry::IBundleActivator) POCO_EXPORT_CLASS(${BUNDLE_NAMESPACE}::${ACTIVATOR_CLASS}) POCO_END_MANIFEST") ENDIF() IF(VIEW_CLASS OR ACTIVATOR_CLASS) CONFIGURE_FILE(${PLUGIN_TEMPLATE}/manifestTemplate.cpp ${PLUGIN_DIR}/manifest.cpp @ONLY) ENDIF() # ---------------------- CMakeListsTemplate.txt ----------------------------- SET(CREATE_PLUGIN_MACRO "${DEFAULT_CREATE_PLUGIN_MACRO}") IF(GUI_SUPPORT) SET(CREATE_PLUGIN_MACRO "${DEFAULT_CREATE_GUI_PLUGIN_MACRO}") ENDIF(GUI_SUPPORT) CONFIGURE_FILE(${PLUGIN_TEMPLATE}/CMakeListsTemplate.txt ${PLUGIN_DIR}/CMakeLists.txt @ONLY) # ---------------------- filesTemplate.cmake ------------------------------ SET(PLUGIN_SOURCES "") SET(PLUGIN_INTERNAL_SOURCES "") IF(VIEW_CLASS) SET(PLUGIN_INTERNAL_SOURCES "${PLUGIN_INTERNAL_SOURCES}${VIEW_CLASS_CPP}\n") ENDIF(VIEW_CLASS) IF(ACTIVATOR_CLASS) SET(PLUGIN_INTERNAL_SOURCES "${PLUGIN_INTERNAL_SOURCES}${ACTIVATOR_CLASS_CPP}\n") ENDIF(ACTIVATOR_CLASS) IF(GUI_SUPPORT AND EXISTS ${PLUGIN_TEMPLATE}/src/internal/ControlsTemplate.ui) SET(PLUGIN_RESOURCE_FILES "resources/icon.xpm") SET(PLUGIN_RES_FILES "resources/${VIEW_CLASS}.qrc") SET(PLUGIN_UI_FILES "src/internal/${VIEW_CONTROLS_UI}") SET(PLUGIN_MOC_H_FILES "src/internal/${VIEW_CLASS}.h") ENDIF() CONFIGURE_FILE(${PLUGIN_TEMPLATE}/filesTemplate.cmake ${PLUGIN_DIR}/files.cmake @ONLY) ENDIF(PLUGIN_ID AND PLUGIN_NAME) diff --git a/BlueBerry/Bundles/BundleList.cmake.in b/BlueBerry/Bundles/BundleList.cmake.in deleted file mode 100755 index 5da4b28d4b..0000000000 --- a/BlueBerry/Bundles/BundleList.cmake.in +++ /dev/null @@ -1 +0,0 @@ -@BLUEBERRY_BUNDLE_VARIABLES@ \ No newline at end of file diff --git a/BlueBerry/Bundles/CMakeLists.txt b/BlueBerry/Bundles/CMakeLists.txt deleted file mode 100755 index 7e6e6fc6bf..0000000000 --- a/BlueBerry/Bundles/CMakeLists.txt +++ /dev/null @@ -1,23 +0,0 @@ - -SET(_default_plugins - org.blueberry.osgi - org.blueberry.solstice.common - org.blueberry.core.runtime - org.blueberry.core.expressions - org.blueberry.core.commands - org.blueberry.ui - org.blueberry.ui.qt -) - -MACRO_COLLECT_PLUGINS(OUTPUT_DIR ${BLUEBERRY_PLUGINS_OUTPUT_DIR} - CACHE_PLUGIN_TARGETS BLUEBERRY_ENABLED_PLUGINS - BUNDLE_LIST_PATH "${BLUEBERRY_BINARY_DIR}/BlueBerryBundleList.cmake" - CMAKE_CACHE_PREFIX "BLUEBERRY" - PLUGIN_DEFAULT_ON ${_default_plugins} - ${BLUEBERRY_BUILD_ALL_PLUGINS_OPTION}) - -add_dependencies(BlueBerry ${BLUEBERRY_ENABLED_PLUGINS}) -foreach(plugin ${BLUEBERRY_ENABLED_PLUGINS}) - string(REPLACE "." "_" plugin_target ${plugin}) - set_property(TARGET ${plugin_target} PROPERTY LABELS BlueBerry) -endforeach() diff --git a/BlueBerry/Bundles/org.blueberry.compat/CMakeLists.txt b/BlueBerry/Bundles/org.blueberry.compat/CMakeLists.txt new file mode 100644 index 0000000000..efc1680685 --- /dev/null +++ b/BlueBerry/Bundles/org.blueberry.compat/CMakeLists.txt @@ -0,0 +1,3 @@ +PROJECT(org_blueberry_compat) + +MACRO_CREATE_CTK_PLUGIN(EXPORT_DIRECTIVE org_blueberry_compat_EXPORT) diff --git a/BlueBerry/Bundles/org.blueberry.compat/berryCTKPluginListener.cpp b/BlueBerry/Bundles/org.blueberry.compat/berryCTKPluginListener.cpp new file mode 100644 index 0000000000..f7d839eb98 --- /dev/null +++ b/BlueBerry/Bundles/org.blueberry.compat/berryCTKPluginListener.cpp @@ -0,0 +1,162 @@ +/*========================================================================= + + Program: BlueBerry Platform + Language: C++ + Date: $Date$ + Version: $Revision$ + + Copyright (c) German Cancer Research Center, Division of Medical and + Biological Informatics. All rights reserved. + See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. + + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the above copyright notices for more information. + + =========================================================================*/ + + +#include "berryCTKPluginListener_p.h" + +#include + +const QString berry::CTKPluginListener::PLUGIN_MANIFEST = "plugin.xml"; + +namespace berry { + +CTKPluginListener::CTKPluginListener(IExtensionPointService::Pointer registry) + : registry(registry) +{ +} + +void CTKPluginListener::processPlugins(const QList >& plugins) +{ + // sort the plugins according to their dependencies + const QList > sortedPlugins = sortPlugins(plugins); + + foreach (QSharedPointer plugin, sortedPlugins) + { + if (isPluginResolved(plugin)) + addPlugin(plugin); + else + removePlugin(plugin); + } +} + +QList > +CTKPluginListener::sortPlugins(const QList >& plugins) +{ + QList > sortedPlugins(plugins); + + QHash mapPluginIdToDeps; + foreach(QSharedPointer plugin, sortedPlugins) + { + QString requirePlugin = plugin->getHeaders()[ctkPluginConstants::REQUIRE_PLUGIN]; + QStringList requiredList = requirePlugin.split(QRegExp("\\s*,\\s*"), QString::SkipEmptyParts); + + QStringList requiredSymbolicNames; + foreach(QString require, requiredList) + { + requiredSymbolicNames.append(require.split(';').front()); + } + mapPluginIdToDeps[plugin->getPluginId()] = requiredSymbolicNames; + } + + QStringList symbolicNames; + for (int i = 0; i < sortedPlugins.size();) + { + QStringList currDeps = mapPluginIdToDeps[sortedPlugins.at(i)->getPluginId()]; + bool moved = false; + foreach(QString currDep, currDeps) + { + if (!symbolicNames.contains(currDep)) + { + sortedPlugins.move(i, sortedPlugins.size()-1); + moved = true; + break; + } + } + if (!moved) + { + symbolicNames.append(sortedPlugins.at(i)->getSymbolicName()); + ++i; + } + } + + return sortedPlugins; +} + +void CTKPluginListener::pluginChanged(const ctkPluginEvent& event) +{ + /* Only should listen for RESOLVED and UNRESOLVED events. + * + * When a plugin is updated the Framework will publish an UNRESOLVED and + * then a RESOLVED event which should cause the plugin to be removed + * and then added back into the registry. + * + * When a plugin is uninstalled the Framework should publish an UNRESOLVED + * event and then an UNINSTALLED event so the plugin will have been removed + * by the UNRESOLVED event before the UNINSTALLED event is published. + */ + QSharedPointer plugin = event.getPlugin(); + switch (event.getType()) + { + case ctkPluginEvent::RESOLVED : + addPlugin(plugin); + break; + case ctkPluginEvent::UNRESOLVED : + removePlugin(plugin); + break; + } +} + +bool CTKPluginListener::isPluginResolved(QSharedPointer plugin) +{ + return (plugin->getState() & (ctkPlugin::RESOLVED | ctkPlugin::ACTIVE | ctkPlugin::STARTING | ctkPlugin::STOPPING)) != 0; +} + +void CTKPluginListener::removePlugin(QSharedPointer plugin) +{ + // The BlueBerry extension point registry does not support the removal of contributions + //registry->remove(plugin->getPluginId(), timestamp); +} + +QString CTKPluginListener::getExtensionPath(QSharedPointer plugin) +{ + // bail out if system plugin + if (plugin->getPluginId() == 0) + return QString(); + // bail out if the plugin does not have a symbolic name + if (plugin->getSymbolicName().isEmpty()) + return QString(); + + return PLUGIN_MANIFEST; +} + +void CTKPluginListener::addPlugin(QSharedPointer plugin) +{ + // if the given plugin already exists in the registry then return. + // note that this does not work for update cases. + std::string contributor = plugin->getSymbolicName().toStdString(); + if (registry->HasContributionFrom(contributor)) + { + return; + } + + QString pluginManifest = getExtensionPath(plugin); + if (pluginManifest.isEmpty()) + return; + + QByteArray ba = plugin->getResource(pluginManifest); + if (ba.isEmpty()) + return; + + std::string strContent(ba.data()); + std::stringbuf strBuf(strContent, std::ios_base::in); + std::istream is(&strBuf); + + registry->AddContribution(is, contributor); +} + +} + diff --git a/BlueBerry/Bundles/org.blueberry.compat/berryCTKPluginListener_p.h b/BlueBerry/Bundles/org.blueberry.compat/berryCTKPluginListener_p.h new file mode 100644 index 0000000000..a5e7bf666b --- /dev/null +++ b/BlueBerry/Bundles/org.blueberry.compat/berryCTKPluginListener_p.h @@ -0,0 +1,78 @@ +/*========================================================================= + + Program: BlueBerry Platform + Language: C++ + Date: $Date$ + Version: $Revision$ + + Copyright (c) German Cancer Research Center, Division of Medical and + Biological Informatics. All rights reserved. + See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. + + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the above copyright notices for more information. + + =========================================================================*/ + + +#ifndef BERRYCTKPLUGINLISTENER_P_H +#define BERRYCTKPLUGINLISTENER_P_H + +#include +#include + +#include + +#include + +class ctkPlugin; + +namespace berry { + +/** + * A listener for CTK plugin events. When plugins come and go we look to see + * if there are any extensions or extension points and update the legacy BlueBerry registry accordingly. + * Using a Synchronous listener here is important. If the + * plugin activator code tries to access the registry to get its extension + * points, we need to ensure that they are in the registry before the + * plugin start is called. By listening sync we are able to ensure that + * happens. + */ +class CTKPluginListener : public QObject { + + Q_OBJECT + +private: + + static const QString PLUGIN_MANIFEST; // = "plugin.xml" + + IExtensionPointService::Pointer registry; + +public: + + CTKPluginListener(IExtensionPointService::Pointer registry); + + void processPlugins(const QList >& plugins); + +public slots: + + void pluginChanged(const ctkPluginEvent& event); + +private: + + bool isPluginResolved(QSharedPointer plugin); + + void removePlugin(QSharedPointer plugin); + + static QString getExtensionPath(QSharedPointer plugin); + + void addPlugin(QSharedPointer plugin); + + QList > sortPlugins(const QList >& plugins); + +}; + +} + +#endif // BERRYCTKPLUGINLISTENER_P_H diff --git a/BlueBerry/Bundles/org.blueberry.compat/berryPluginActivator.cpp b/BlueBerry/Bundles/org.blueberry.compat/berryPluginActivator.cpp new file mode 100644 index 0000000000..20f7ea2696 --- /dev/null +++ b/BlueBerry/Bundles/org.blueberry.compat/berryPluginActivator.cpp @@ -0,0 +1,71 @@ +/*========================================================================= + + Program: BlueBerry Platform + Language: C++ + Date: $Date$ + Version: $Revision$ + + Copyright (c) German Cancer Research Center, Division of Medical and + Biological Informatics. All rights reserved. + See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. + + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the above copyright notices for more information. + + =========================================================================*/ + + +#include "berryPluginActivator_p.h" + +#include "berryCTKPluginListener_p.h" + +#include + +#include + +namespace berry { + +org_blueberry_compat_Activator::org_blueberry_compat_Activator() + : pluginListener(0) +{ +} + +org_blueberry_compat_Activator::~org_blueberry_compat_Activator() +{ + delete pluginListener; +} + +void org_blueberry_compat_Activator::start(ctkPluginContext* context) +{ + ctkServiceReference xpRef = context->getServiceReference(); + Q_ASSERT(xpRef); + + IExtensionPointService::Pointer xpService(context->getService(xpRef)); + Q_ASSERT(xpService); + + delete pluginListener; + + // register a listener to catch new plugin installations/resolutions. + pluginListener = new CTKPluginListener(xpService); + context->connectPluginListener(pluginListener, SLOT(pluginChanged(ctkPluginEvent)), Qt::DirectConnection); + + // populate the registry with all the currently installed plugins. + // There is a small window here while processPlugins is being + // called where the pluginListener may receive a ctkPluginEvent + // to add/remove a plugin from the registry. This is ok since + // the registry is a synchronized object and will not add the + // same bundle twice. + pluginListener->processPlugins(context->getPlugins()); +} + +void org_blueberry_compat_Activator::stop(ctkPluginContext* context) +{ + Q_UNUSED(context) +} + +} + +Q_EXPORT_PLUGIN2(org_blueberry_compat, berry::org_blueberry_compat_Activator) + + diff --git a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryQtIconImageDescriptor.h b/BlueBerry/Bundles/org.blueberry.compat/berryPluginActivator_p.h old mode 100755 new mode 100644 similarity index 53% copy from BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryQtIconImageDescriptor.h copy to BlueBerry/Bundles/org.blueberry.compat/berryPluginActivator_p.h index 9afe1a7db5..da3a595765 --- a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryQtIconImageDescriptor.h +++ b/BlueBerry/Bundles/org.blueberry.compat/berryPluginActivator_p.h @@ -1,49 +1,52 @@ /*========================================================================= Program: BlueBerry Platform Language: C++ Date: $Date$ Version: $Revision$ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ -#ifndef BERRYQTICONIMAGEDESCRIPTOR_H_ -#define BERRYQTICONIMAGEDESCRIPTOR_H_ +#ifndef BERRYCOMPATIBILITYACTIVATOR_P_H +#define BERRYCOMPATIBILITYACTIVATOR_P_H -#include - -class QIcon; +#include namespace berry { -class QtIconImageDescriptor : public ImageDescriptor -{ - -private: +class CTKPluginListener; - QIcon* icon; +class org_blueberry_compat_Activator : + public QObject, public ctkPluginActivator +{ + Q_OBJECT + Q_INTERFACES(ctkPluginActivator) public: - QtIconImageDescriptor(void* img); + org_blueberry_compat_Activator(); + ~org_blueberry_compat_Activator(); + + void start(ctkPluginContext* context); + void stop(ctkPluginContext* context); - virtual void* CreateImage(bool returnMissingImageOnError = true); +private: - virtual void DestroyImage(void* img); + CTKPluginListener* pluginListener; - virtual bool operator==(const Object* o) const; +}; // org_blueberry_compat_Activator -}; +typedef org_blueberry_compat_Activator PluginActivator; } -#endif /* BERRYQTICONIMAGEDESCRIPTOR_H_ */ +#endif // BERRYCOMPATIBILITYACTIVATOR_P_H diff --git a/BlueBerry/Bundles/org.blueberry.compat/files.cmake b/BlueBerry/Bundles/org.blueberry.compat/files.cmake new file mode 100644 index 0000000000..28e4d4be9d --- /dev/null +++ b/BlueBerry/Bundles/org.blueberry.compat/files.cmake @@ -0,0 +1,9 @@ +SET(MOC_H_FILES + berryPluginActivator_p.h + berryCTKPluginListener_p.h +) + +SET(CPP_FILES + berryPluginActivator.cpp + berryCTKPluginListener.cpp +) diff --git a/BlueBerry/Bundles/org.blueberry.compat/manifest_headers.cmake b/BlueBerry/Bundles/org.blueberry.compat/manifest_headers.cmake new file mode 100644 index 0000000000..402cbaf718 --- /dev/null +++ b/BlueBerry/Bundles/org.blueberry.compat/manifest_headers.cmake @@ -0,0 +1,6 @@ +set(Plugin-Name "BlueBerry Legacy Compatibility Plugin") +set(Plugin-Version "1.0.0") +set(Plugin-Vendor "DKFZ, Medical and Biological Informatics") +set(Plugin-ContactAddress "http://www.mitk.org") +SET(Require-Plugin "org.blueberry.osgi") +SET(Plugin-ActivationPolicy "eager") diff --git a/BlueBerry/Bundles/org.blueberry.core.commands/CMakeLists.txt b/BlueBerry/Bundles/org.blueberry.core.commands/CMakeLists.txt index 1c4a0b018f..cd0a81bc25 100644 --- a/BlueBerry/Bundles/org.blueberry.core.commands/CMakeLists.txt +++ b/BlueBerry/Bundles/org.blueberry.core.commands/CMakeLists.txt @@ -1,4 +1,4 @@ +PROJECT(org_blueberry_core_commands) -MACRO_CREATE_PLUGIN() - -TARGET_LINK_LIBRARIES(${PLUGIN_TARGET} optimized PocoUtil debug PocoUtild optimized PocoXML debug PocoXMLd) +MACRO_CREATE_CTK_PLUGIN(EXPORT_DIRECTIVE BERRY_COMMANDS + EXPORTED_INCLUDE_SUFFIXES src src/common src/util) diff --git a/BlueBerry/Bundles/org.blueberry.core.commands/META-INF/MANIFEST.MF b/BlueBerry/Bundles/org.blueberry.core.commands/META-INF/MANIFEST.MF deleted file mode 100644 index 19e15abc2c..0000000000 --- a/BlueBerry/Bundles/org.blueberry.core.commands/META-INF/MANIFEST.MF +++ /dev/null @@ -1,6 +0,0 @@ -Manifest-Version: 1.0 -Bundle-Name: BlueBerry Core Commands Plugin -Bundle-SymbolicName: org.blueberry.core.commands -Bundle-Version: 1.0.0 -Require-Bundle: org.blueberry.osgi -Bundle-Vendor: DKFZ, Medical and Biological Informatics \ No newline at end of file diff --git a/BlueBerry/Bundles/org.blueberry.core.commands/files.cmake b/BlueBerry/Bundles/org.blueberry.core.commands/files.cmake index 28922a6a3a..e5dbbb2654 100644 --- a/BlueBerry/Bundles/org.blueberry.core.commands/files.cmake +++ b/BlueBerry/Bundles/org.blueberry.core.commands/files.cmake @@ -1,54 +1,59 @@ +SET(MOC_H_FILES + src/internal/berryPluginActivator.h +) + SET(SRC_CPP_FILES berryAbstractHandler.cpp berryCommand.cpp berryCommandCategory.cpp berryCommandCategoryEvent.cpp berryCommandEvent.cpp berryCommandManager.cpp berryCommandManagerEvent.cpp berryExecutionEvent.cpp berryHandlerEvent.cpp berryICommandCategoryListener.cpp berryICommandListener.cpp berryICommandManagerListener.cpp berryIExecutionListener.cpp berryIExecutionListenerWithChecks.cpp berryIHandlerListener.cpp berryINamedHandleStateIds.cpp berryIParameterTypeListener.cpp berryIStateListener.cpp berryNamedHandleObjectWithState.cpp berryParameterization.cpp berryParameterizedCommand.cpp berryParameterType.cpp berryParameterTypeEvent.cpp berryState.cpp util/berryCommandTracing.cpp ) SET(COMMON_CPP_FILES berryAbstractBitSetEvent.cpp berryAbstractHandleObjectEvent.cpp berryAbstractNamedHandleEvent.cpp berryCommandExceptions.cpp berryHandleObject.cpp berryHandleObjectManager.cpp berryNamedHandleObject.cpp ) SET(INTERNAL_CPP_FILES berryCommandUtils.cpp + berryPluginActivator.cpp ) foreach(file ${SRC_CPP_FILES}) SET(CPP_FILES ${CPP_FILES} src/${file}) endforeach(file ${SRC_CPP_FILES}) foreach(file ${COMMON_CPP_FILES}) SET(CPP_FILES ${CPP_FILES} src/common/${file}) endforeach(file ${COMMON_CPP_FILES}) foreach(file ${INTERNAL_CPP_FILES}) SET(CPP_FILES ${CPP_FILES} src/internal/${file}) -endforeach(file ${INTERNAL_CPP_FILES}) \ No newline at end of file +endforeach(file ${INTERNAL_CPP_FILES}) diff --git a/BlueBerry/Bundles/org.blueberry.core.commands/includes.cmake b/BlueBerry/Bundles/org.blueberry.core.commands/includes.cmake deleted file mode 100755 index 0fcbe8af9b..0000000000 --- a/BlueBerry/Bundles/org.blueberry.core.commands/includes.cmake +++ /dev/null @@ -1,3 +0,0 @@ -SET(ADDITIONAL_INCLUDE_DIRECTORIES - src/common -) \ No newline at end of file diff --git a/BlueBerry/Bundles/org.blueberry.core.commands/manifest_headers.cmake b/BlueBerry/Bundles/org.blueberry.core.commands/manifest_headers.cmake new file mode 100644 index 0000000000..d3a2b24973 --- /dev/null +++ b/BlueBerry/Bundles/org.blueberry.core.commands/manifest_headers.cmake @@ -0,0 +1,6 @@ +set(Plugin-Name "BlueBerry Core Commands Plugin") +set(Plugin-Version "1.0.0") +set(Plugin-Vendor "DKFZ, Medical and Biological Informatics") +set(Plugin-ContactAddress "http://www.mitk.org") +set(Require-Plugin "org.blueberry.osgi") + diff --git a/BlueBerry/Bundles/org.blueberry.core.commands/src/berryAbstractHandler.h b/BlueBerry/Bundles/org.blueberry.core.commands/src/berryAbstractHandler.h index c115a85424..40dcb91692 100644 --- a/BlueBerry/Bundles/org.blueberry.core.commands/src/berryAbstractHandler.h +++ b/BlueBerry/Bundles/org.blueberry.core.commands/src/berryAbstractHandler.h @@ -1,173 +1,173 @@ /*========================================================================= Program: BlueBerry Platform Language: C++ Date: $Date$ Version: $Revision$ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #ifndef BERRYABSTRACTHANDLER_H_ #define BERRYABSTRACTHANDLER_H_ #include "berryIHandler.h" -#include "berryCommandsDll.h" +#include namespace berry { /** *

* This class is a partial implementation of IHandler. This * abstract implementation provides support for handler listeners. You should * subclass from this class unless you want to implement your own listener * support. Subclasses should call * {@link AbstractHandler#fireHandlerChanged(HandlerEvent)}when the handler * changes. Subclasses can also override {@link AbstractHandler#isEnabled()} and * {@link AbstractHandler#isHandled()}. *

* * @since 3.1 */ class BERRY_COMMANDS AbstractHandler : public IHandler { // ,public EventManager { public: berryObjectMacro(AbstractHandler) private: /** * Track this base class enabled state. * * @since 3.4 */ bool baseEnabled; public: AbstractHandler(); /** * @see IHandler#addHandlerListener(IHandlerListener) */ // void AddHandlerListener(final IHandlerListener handlerListener) { // addListenerObject(handlerListener); // } /** * The default implementation does nothing. Subclasses who attach listeners * to other objects are encouraged to detach them in this method. * * @see org.blueberry.core.commands.IHandler#dispose() */ ~AbstractHandler() { // Do nothing. } /** * Whether this handler is capable of executing at this time. Subclasses may * override this method. If clients override this method they should also * consider overriding {@link #setEnabled(Object)} so they can be notified * about framework execution contexts. * * @return true * @see #setEnabled(Object) * @see #setBaseEnabled(boolean) */ bool IsEnabled(); /** * Whether this handler is capable of handling delegated responsibilities at * this time. Subclasses may override this method. * * @return true */ bool IsHandled(); /** * @see IHandler#removeHandlerListener(IHandlerListener) */ // void RemoveHandlerListener(final IHandlerListener handlerListener) { // removeListenerObject(handlerListener); // } protected: /** * Fires an event to all registered listeners describing changes to this * instance. *

* Subclasses may extend the definition of this method (i.e., if a different * type of listener can be attached to a subclass). This is used primarily * for support of AbstractHandler in * org.blueberry.ui.workbench, and clients should be wary of * overriding this behaviour. If this method is overridden, then the first * line of the method should be "super.fireHandlerChanged(handlerEvent);". *

* * @param handlerEvent * the event describing changes to this instance. Must not be * null. */ // void FireHandlerChanged(final HandlerEvent handlerEvent) { // if (handlerEvent == null) { // throw new NullPointerException(); // } // // final Object[] listeners = getListeners(); // for (int i = 0; i < listeners.length; i++) { // final IHandlerListener listener = (IHandlerListener) listeners[i]; // listener.handlerChanged(handlerEvent); // } // } /** * Allow the default {@link #isEnabled()} to answer our enabled state. It * will fire a HandlerEvent if necessary. If clients use this method they * should also consider overriding {@link #setEnabled(Object)} so they can * be notified about framework execution contexts. * * @param state * the enabled state * @since 3.4 */ void SetBaseEnabled(bool state); /** *

* Returns true iff there is one or more IHandlerListeners attached to this * AbstractHandler. *

*

* Subclasses may extend the definition of this method (i.e., if a different * type of listener can be attached to a subclass). This is used primarily * for support of AbstractHandler in * org.blueberry.ui.workbench, and clients should be wary of * overriding this behaviour. If this method is overridden, then the return * value should include "super.hasListeners() ||". *

* * @return true iff there is one or more IHandlerListeners attached to this * AbstractHandler */ // bool HasListeners() { // return isListenerAttached(); // } }; } #endif /*BERRYABSTRACTHANDLER_H_*/ diff --git a/BlueBerry/Bundles/org.blueberry.core.commands/src/berryCommandEvent.h b/BlueBerry/Bundles/org.blueberry.core.commands/src/berryCommandEvent.h index 549a674e2f..614bb4de22 100755 --- a/BlueBerry/Bundles/org.blueberry.core.commands/src/berryCommandEvent.h +++ b/BlueBerry/Bundles/org.blueberry.core.commands/src/berryCommandEvent.h @@ -1,183 +1,183 @@ /*========================================================================= Program: BlueBerry Platform Language: C++ Date: $Date$ Version: $Revision$ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #ifndef BERRYCOMMANDEVENT_H_ #define BERRYCOMMANDEVENT_H_ #include "common/berryAbstractNamedHandleEvent.h" -#include "berryCommandsDll.h" +#include namespace berry { class Command; /** * An instance of this class describes changes to an instance of * Command. *

* This class is not intended to be extended by clients. *

* * @see ICommandListener#CommandChanged(CommandEvent::Pointer) */ class BERRY_COMMANDS CommandEvent : public AbstractNamedHandleEvent { public: berryObjectMacro(CommandEvent) /** * Creates a new instance of this class. * * @param command * the instance of the interface that changed. * @param categoryChanged * true, iff the category property changed. * @param definedChanged * true, iff the defined property changed. * @param descriptionChanged * true, iff the description property changed. * @param handledChanged * true, iff the handled property changed. * @param nameChanged * true, iff the name property changed. * @param parametersChanged * true if the parameters have changed; * false otherwise. * @param returnTypeChanged * true iff the return type property changed; * false otherwise. * @param helpContextIdChanged * true iff the help context identifier changed; * false otherwise. * @param enabledChanged * true iff the comand enablement changed; * false otherwise. * @since 3.3 */ CommandEvent(const SmartPointer command, bool categoryChanged, bool definedChanged, bool descriptionChanged, bool handledChanged, bool nameChanged, bool parametersChanged, bool returnTypeChanged = false, bool helpContextIdChanged = false, bool enabledChanged = false); /** * Returns the instance of the interface that changed. * * @return the instance of the interface that changed. Guaranteed not to be * null. */ SmartPointer GetCommand() const; /** * Returns whether or not the category property changed. * * @return true, iff the category property changed. */ bool IsCategoryChanged() const; /** * Returns whether or not the handled property changed. * * @return true, iff the handled property changed. */ bool IsHandledChanged() const; /** * Returns whether or not the help context identifier changed. * * @return true, iff the help context identifier changed. * @since 3.2 */ bool IsHelpContextIdChanged() const; /** * Returns whether or not the parameters have changed. * * @return true, iff the parameters property changed. */ bool IsParametersChanged() const; /** * Returns whether or not the return type property changed. * * @return true, iff the return type property changed. * @since 3.2 */ bool IsReturnTypeChanged() const; /** * Return whether the enable property changed. * * @return true iff the comand enablement changed * @since 3.3 */ bool IsEnabledChanged() const; private: /** * The bit used to represent whether the command has changed its category. */ static const int CHANGED_CATEGORY; // = LAST_USED_BIT << 1; /** * The bit used to represent whether the command has changed its handler. */ static const int CHANGED_HANDLED; // = LAST_USED_BIT << 2; /** * The bit used to represent whether the command has changed its parameters. */ static const int CHANGED_PARAMETERS; // = LAST_USED_BIT << 3; /** * The bit used to represent whether the command has changed its return * type. * * @since 3.2 */ static const int CHANGED_RETURN_TYPE; // = LAST_USED_BIT << 4; /** * The bit used to represent whether the command has changed its help * context identifier. * * @since 3.2 */ static const int CHANGED_HELP_CONTEXT_ID; // = LAST_USED_BIT << 5; /** * The bit used to represent whether this commands active handler has * changed its enablement state. * * @since 3.3 */ static const int CHANGED_ENABLED; // = LAST_USED_BIT << 6; /** * The command that has changed; this value is never null. */ const SmartPointer command; }; } #endif /* BERRYCOMMANDEVENT_H_ */ diff --git a/BlueBerry/Bundles/org.blueberry.core.commands/src/berryCommandManagerEvent.h b/BlueBerry/Bundles/org.blueberry.core.commands/src/berryCommandManagerEvent.h index 112ee9efe2..1f619e8f45 100755 --- a/BlueBerry/Bundles/org.blueberry.core.commands/src/berryCommandManagerEvent.h +++ b/BlueBerry/Bundles/org.blueberry.core.commands/src/berryCommandManagerEvent.h @@ -1,257 +1,257 @@ /*========================================================================= Program: BlueBerry Platform Language: C++ Date: $Date$ Version: $Revision$ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #ifndef BERRYCOMMANDMANAGEREVENT_H_ #define BERRYCOMMANDMANAGEREVENT_H_ -#include "berryCommandsDll.h" +#include #include #include namespace berry { class CommandManager; /** *

* An event indicating that the set of defined command identifiers has changed. *

* * @since 3.1 * @see ICommandManagerListener#commandManagerChanged(CommandManagerEvent) */ class BERRY_COMMANDS CommandManagerEvent: public Object { public: berryObjectMacro(CommandManagerEvent) /** * Creates a new CommandManagerEvent instance to describe * changes to commands and/or categories. * * @param commandManager * the instance of the interface that changed; must not be * null. * @param commandId * The command identifier that was added or removed; must not be * null if commandIdChanged is true. * @param commandIdAdded * Whether the command identifier became defined (otherwise, it * became undefined). * @param commandIdChanged * Whether the list of defined command identifiers has changed. * @param categoryId * The category identifier that was added or removed; must not be * null if categoryIdChanged is true. * @param categoryIdAdded * Whether the category identifier became defined (otherwise, it * became undefined). * @param categoryIdChanged * Whether the list of defined category identifiers has changed. */ CommandManagerEvent (CommandManager& commandManager, const std::string& commandId, const bool commandIdAdded, const bool commandIdChanged, const std::string& categoryId, const bool categoryIdAdded, const bool categoryIdChanged); /** * Creates a new CommandManagerEvent instance to describe * changes to command parameter types. * * @param commandManager * the instance of the interface that changed; must not be * null. * @param parameterTypeId * The command parameter type identifier that was added or * removed; must not be null if * parameterTypeIdChanged is true. * @param parameterTypeIdAdded * Whether the parameter type identifier became defined * (otherwise, it became undefined). * @param parameterTypeIdChanged * Whether the list of defined parameter type identifiers has * changed. * * @since 3.2 */ CommandManagerEvent(CommandManager& commandManager, const std::string& parameterTypeId, const bool parameterTypeIdAdded, const bool parameterTypeIdChanged); /** * Returns the category identifier that was added or removed. * * @return The category identifier that was added or removed; may be * null. */ std::string GetCategoryId() const; /** * Returns the command identifier that was added or removed. * * @return The command identifier that was added or removed; may be * null. */ std::string GetCommandId() const; /** * Returns the instance of the interface that changed. * * @return the instance of the interface that changed. Guaranteed not to be * null. */ CommandManager& GetCommandManager() const; /** * Returns the command parameter type identifier that was added or removed. * * @return The command parameter type identifier that was added or removed; * may be null. * * @since 3.2 */ std::string GetParameterTypeId() const; /** * Returns whether the list of defined category identifiers has changed. * * @return true if the list of category identifiers has * changed; false otherwise. */ bool IsCategoryChanged() const; /** * Returns whether the category identifier became defined. Otherwise, the * category identifier became undefined. * * @return true if the category identifier became defined; * false if the category identifier became undefined. */ bool IsCategoryDefined() const; /** * Returns whether the list of defined command identifiers has changed. * * @return true if the list of command identifiers has * changed; false otherwise. */ bool IsCommandChanged() const; /** * Returns whether the command identifier became defined. Otherwise, the * command identifier became undefined. * * @return true if the command identifier became defined; * false if the command identifier became undefined. */ bool IsCommandDefined() const; /** * Returns whether the list of defined command parameter type identifiers * has changed. * * @return true if the list of command parameter type * identifiers has changed; false otherwise. * * @since 3.2 */ bool IsParameterTypeChanged() const; /** * Returns whether the command parameter type identifier became defined. * Otherwise, the command parameter type identifier became undefined. * * @return true if the command parameter type identifier * became defined; false if the command parameter * type identifier became undefined. * * @since 3.2 */ bool IsParameterTypeDefined() const; private: /** * The bit used to represent whether the given category has become defined. * If this bit is not set and there is no category id, then no category has * become defined nor undefined. If this bit is not set and there is a * category id, then the category has become undefined. */ static const int CHANGED_CATEGORY_DEFINED; // = 1; /** * The bit used to represent whether the given command has become defined. * If this bit is not set and there is no command id, then no command has * become defined nor undefined. If this bit is not set and there is a * command id, then the command has become undefined. */ static const int CHANGED_COMMAND_DEFINED; // = 1 << 1; /** * The bit used to represent whether the given command parameter type has * become defined. If this bit is not set and there is no parameter type id, * then no parameter type has become defined nor undefined. If this bit is * not set and there is a parameter type id, then the parameter type has * become undefined. * * @since 3.2 */ static const int CHANGED_PARAMETER_TYPE_DEFINED; // = 1 << 2; /** * The category identifier that was added or removed from the list of * defined category identifiers. This value is null if the * list of defined category identifiers did not change. */ const std::string categoryId; /** * A collection of bits representing whether certain values have changed. A * bit is set (i.e., 1) if the corresponding property has * changed. */ int changedValues; /** * The command identifier that was added or removed from the list of defined * command identifiers. This value is null if the list of * defined command identifiers did not change. */ const std::string commandId; /** * The command parameter type identifier that was added or removed from the * list of defined parameter type identifiers. This value is * null if the list of defined parameter type identifiers did * not change. */ const std::string parameterTypeId; /** * The command manager that has changed. */ CommandManager& commandManager; }; } #endif /* BERRYCOMMANDMANAGEREVENT_H_ */ diff --git a/BlueBerry/Bundles/org.blueberry.core.commands/src/berryCommandsDll.h b/BlueBerry/Bundles/org.blueberry.core.commands/src/berryCommandsDll.h deleted file mode 100644 index 69636e15ee..0000000000 --- a/BlueBerry/Bundles/org.blueberry.core.commands/src/berryCommandsDll.h +++ /dev/null @@ -1,43 +0,0 @@ -/*========================================================================= - -Program: BlueBerry Platform -Language: C++ -Date: $Date$ -Version: $Revision$ - -Copyright (c) German Cancer Research Center, Division of Medical and -Biological Informatics. All rights reserved. -See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. - -This software is distributed WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. See the above copyright notices for more information. - -=========================================================================*/ - -#ifndef BERRYCOMMANDSDLL_H_ -#define BERRYCOMMANDSDLL_H_ - - -// -// The following block is the standard way of creating macros which make exporting -// from a DLL simpler. All files within this DLL are compiled with the MITK_EXPORTS -// symbol defined on the command line. this symbol should not be defined on any project -// that uses this DLL. This way any other project whose source files include this file see -// MITK_API functions as being imported from a DLL, wheras this DLL sees symbols -// defined with this macro as being exported. -// -#if defined(_WIN32) && !defined(BERRY_STATIC) - #if defined(org_blueberry_core_commands_EXPORTS) - #define BERRY_COMMANDS __declspec(dllexport) - #else - #define BERRY_COMMANDS __declspec(dllimport) - #endif -#endif - - -#if !defined(BERRY_COMMANDS) - #define BERRY_COMMANDS -#endif - -#endif /*BERRYCOMMANDSDLL_H_*/ diff --git a/BlueBerry/Bundles/org.blueberry.core.commands/src/berryHandlerEvent.h b/BlueBerry/Bundles/org.blueberry.core.commands/src/berryHandlerEvent.h index 072c4b0a6d..e4b0332087 100755 --- a/BlueBerry/Bundles/org.blueberry.core.commands/src/berryHandlerEvent.h +++ b/BlueBerry/Bundles/org.blueberry.core.commands/src/berryHandlerEvent.h @@ -1,105 +1,105 @@ /*========================================================================= Program: BlueBerry Platform Language: C++ Date: $Date$ Version: $Revision$ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #ifndef BERRYHANDLEREVENT_H_ #define BERRYHANDLEREVENT_H_ #include "common/berryAbstractBitSetEvent.h" -#include "berryCommandsDll.h" +#include namespace berry { struct IHandler; /** * An instance of this class describes changes to an instance of * IHandler. *

* This class is not intended to be extended by clients. *

* * @see IHandlerListener#HandlerChanged(HandlerEvent) */ class BERRY_COMMANDS HandlerEvent : public AbstractBitSetEvent { public: berryObjectMacro(HandlerEvent) /** * Creates a new instance of this class. * * @param handler * the instance of the interface that changed; must not be * null. * @param enabledChanged * Whether the enabled state of the handler has changed. * @param handledChanged * Whether the handled state of the handler has changed. */ HandlerEvent(const SmartPointer handler, bool enabledChanged, bool handledChanged); /** * Returns the instance of the interface that changed. * * @return the instance of the interface that changed. Guaranteed not to be * null. */ SmartPointer GetHandler() const; /** * Returns whether or not the enabled property changed. * * @return true, iff the enabled property changed. */ bool IsEnabledChanged() const; /** * Returns whether or not the handled property changed. * * @return true, iff the handled property changed. */ bool IsHandledChanged() const ; private: /** * The bit used to represent whether the handler has changed its enabled * state. */ static const int CHANGED_ENABLED; // = 1; /** * The bit used to represent whether the handler has changed its handled * state. */ static const int CHANGED_HANDLED; // = 1 << 1; /** * The handler that changed; this value is never null. */ const SmartPointer handler; }; } #endif /* BERRYHANDLEREVENT_H_ */ diff --git a/BlueBerry/Bundles/org.blueberry.core.commands/src/berryICommandManagerListener.h b/BlueBerry/Bundles/org.blueberry.core.commands/src/berryICommandManagerListener.h index cfe3ee0648..91870bec13 100755 --- a/BlueBerry/Bundles/org.blueberry.core.commands/src/berryICommandManagerListener.h +++ b/BlueBerry/Bundles/org.blueberry.core.commands/src/berryICommandManagerListener.h @@ -1,74 +1,74 @@ /*========================================================================= Program: BlueBerry Platform Language: C++ Date: $Date$ Version: $Revision$ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #ifndef BERRYICOMMANDMANAGERLISTENER_H_ #define BERRYICOMMANDMANAGERLISTENER_H_ -#include "berryCommandsDll.h" +#include #include #include namespace berry { class CommandManagerEvent; /** * An instance of this interface can be used by clients to receive notification * of changes to one or more instances of ICommandManager. *

* This interface may be implemented by clients. *

* * @since 3.1 * @see CommandManager#addCommandManagerListener(ICommandManagerListener) * @see CommandManager#removeCommandManagerListener(ICommandManagerListener) */ struct BERRY_COMMANDS ICommandManagerListener: public virtual Object { berryInterfaceMacro(ICommandManagerListener, berry) struct Events { typedef Message1 > Event; Event commandManagerChanged; void AddListener(ICommandManagerListener::Pointer listener); void RemoveListener(ICommandManagerListener::Pointer listener); private: typedef MessageDelegate1 > Delegate; } ; /** * Notifies that one or more properties of an instance of * ICommandManager have changed. Specific details are * described in the CommandManagerEvent. * * @param commandManagerEvent * the commandManager event. Guaranteed not to be * null. */ virtual void CommandManagerChanged(const SmartPointer commandManagerEvent) = 0; }; } #endif /* BERRYICOMMANDMANAGERLISTENER_H_ */ diff --git a/BlueBerry/Bundles/org.blueberry.core.commands/src/berryIExecutionListener.h b/BlueBerry/Bundles/org.blueberry.core.commands/src/berryIExecutionListener.h index 1dd98bcf22..f7bd7d0248 100755 --- a/BlueBerry/Bundles/org.blueberry.core.commands/src/berryIExecutionListener.h +++ b/BlueBerry/Bundles/org.blueberry.core.commands/src/berryIExecutionListener.h @@ -1,120 +1,120 @@ /*========================================================================= Program: BlueBerry Platform Language: C++ Date: $Date$ Version: $Revision$ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #ifndef BERRYIEXECUTIONLISTENER_H_ #define BERRYIEXECUTIONLISTENER_H_ #include #include #include -#include "berryCommandsDll.h" +#include #include "common/berryCommandExceptions.h" namespace berry { class ExecutionEvent; /** *

* A listener to the execution of commands. This listener will be notified if a * command is about to execute, and when that execution completes. It is not * possible for the listener to prevent the execution, only to respond to it in * some way. *

* * @since 3.1 */ struct BERRY_COMMANDS IExecutionListener : public virtual Object { berryInterfaceMacro(IExecutionListener, berry) struct Events { Message2 notHandled; Message2 postExecuteFailure; Message2 postExecuteSuccess; Message2 > preExecute; virtual ~Events(); virtual void AddListener(IExecutionListener::Pointer listener); virtual void RemoveListener(IExecutionListener::Pointer listener); virtual bool HasListeners() const; virtual bool IsEmpty() const; typedef MessageDelegate2 NotHandledDelegate; typedef MessageDelegate2 PostExecuteFailureDelegate; typedef MessageDelegate2 PostExecuteSuccessDelegate; typedef MessageDelegate2 > PreExecuteDelegate; }; virtual ~IExecutionListener(); /** * Notifies the listener that an attempt was made to execute a command with * no handler. * * @param commandId * The identifier of command that is not handled; never * null * @param exception * The exception that occurred; never null. */ virtual void NotHandled(const std::string& commandId, const NotHandledException* exception) = 0; /** * Notifies the listener that a command has failed to complete execution. * * @param commandId * The identifier of the command that has executed; never * null. * @param exception * The exception that occurred; never null. */ virtual void PostExecuteFailure(const std::string& commandId, const ExecutionException* exception) = 0; /** * Notifies the listener that a command has completed execution * successfully. * * @param commandId * The identifier of the command that has executed; never * null. * @param returnValue * The return value from the command; may be null. */ virtual void PostExecuteSuccess(const std::string& commandId, const Object::Pointer returnValue) = 0; /** * Notifies the listener that a command is about to execute. * * @param commandId * The identifier of the command that is about to execute, never * null. * @param event * The event that will be passed to the execute * method; never null. */ virtual void PreExecute(const std::string& commandId, const SmartPointer event) = 0; }; } #endif /* BERRYIEXECUTIONLISTENER_H_ */ diff --git a/BlueBerry/Bundles/org.blueberry.core.commands/src/berryIHandler.h b/BlueBerry/Bundles/org.blueberry.core.commands/src/berryIHandler.h index 8d3f94003c..d5d310d89e 100644 --- a/BlueBerry/Bundles/org.blueberry.core.commands/src/berryIHandler.h +++ b/BlueBerry/Bundles/org.blueberry.core.commands/src/berryIHandler.h @@ -1,124 +1,124 @@ /*========================================================================= Program: BlueBerry Platform Language: C++ Date: $Date$ Version: $Revision$ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #ifndef BERRYIHANDLER_H_ #define BERRYIHANDLER_H_ #include #include -#include "berryCommandsDll.h" +#include namespace berry { struct IHandlerListener; class ExecutionEvent; /** * A handler is the pluggable piece of a command that handles execution. Each * command can have zero or more handlers associated with it (in general), of * which only one will be active at any given moment in time. When the command * is asked to execute, it will simply pass that request on to its active * handler, if any. * * @see AbstractHandler * @since 3.1 */ struct BERRY_COMMANDS IHandler : public Object { berryInterfaceMacro(IHandler, berry) /** * Registers an instance of IHandlerListener to listen for * changes to properties of this instance. * * @param handlerListener * the instance to register. Must not be null. If * an attempt is made to register an instance which is already * registered with this instance, no operation is performed. */ virtual void AddHandlerListener(SmartPointer handlerListener) = 0; /** * Disposes of this handler. This can be used as an opportunity to unhook listeners * from other objects. */ virtual ~IHandler() {} /** * Executes with the map of parameter values by name. * * @param event * An event containing all the information about the current * state of the application; must not be null. * @return the result of the execution. Reserved for future use, must be * null. * @throws ExecutionException * if an exception occurred during execution. */ virtual Object::Pointer Execute(const SmartPointer event) = 0; /** * Called by the framework to allow the handler to update its enabled state. * * @param evaluationContext * the state to evaluate against. May be null * which indicates that the handler can query whatever model that * is necessary. This context must not be cached. */ virtual void SetEnabled(Object::ConstPointer evaluationContext) = 0; /** * Returns whether this handler is capable of executing at this moment in * time. If the enabled state is other than true clients should also * consider implementing IHandler2 so they can be notified about framework * execution contexts. * * @return true if the command is enabled; false * otherwise. * @see IHandler2#setEnabled(Object) */ virtual bool IsEnabled() const = 0; /** * Returns whether this handler is really capable of handling delegation. In * the case of a handler that is a composition of other handlers, this reply * is intended to indicate whether the handler is truly capable of receiving * delegated responsibilities at this time. * * @return true if the handler is handled; false * otherwise. */ virtual bool IsHandled() const = 0; /** * Unregisters an instance of IHandlerListener listening for * changes to properties of this instance. * * @param handlerListener * the instance to unregister. Must not be null. * If an attempt is made to unregister an instance which is not * already registered with this instance, no operation is * performed. */ virtual void RemoveHandlerListener(SmartPointer handlerListener) = 0; }; } #endif /*BERRYIHANDLER_H_*/ diff --git a/BlueBerry/Bundles/org.blueberry.core.commands/src/berryIHandlerListener.h b/BlueBerry/Bundles/org.blueberry.core.commands/src/berryIHandlerListener.h index 7fce5800e5..3825f3888b 100755 --- a/BlueBerry/Bundles/org.blueberry.core.commands/src/berryIHandlerListener.h +++ b/BlueBerry/Bundles/org.blueberry.core.commands/src/berryIHandlerListener.h @@ -1,73 +1,73 @@ /*========================================================================= Program: BlueBerry Platform Language: C++ Date: $Date$ Version: $Revision$ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #ifndef BERRYIHANDLERLISTENER_H_ #define BERRYIHANDLERLISTENER_H_ #include #include #include -#include "berryCommandsDll.h" +#include namespace berry { class HandlerEvent; /** * An instance of this interface can be used by clients to receive notification * of changes to one or more instances of IHandler. *

* This interface may be implemented by clients. *

* * @since 3.1 * @see IHandler#addHandlerListener(IHandlerListener) * @see IHandler#removeHandlerListener(IHandlerListener) */ struct BERRY_COMMANDS IHandlerListener : public virtual Object { berryInterfaceMacro(IHandlerListener, berry) struct Events { typedef Message1 > Event; Event handlerChanged; void AddListener(IHandlerListener::Pointer listener); void RemoveListener(IHandlerListener::Pointer listener); private: typedef MessageDelegate1 > Delegate; }; /** * Notifies that one or more properties of an instance of * IHandler have changed. Specific details are described in * the HandlerEvent. * * @param handlerEvent * the handler event. Guaranteed not to be null. */ virtual void HandlerChanged(SmartPointer handlerEvent) = 0; }; } #endif /* BERRYIHANDLERLISTENER_H_ */ diff --git a/BlueBerry/Bundles/org.blueberry.core.commands/src/berryIObjectWithState.h b/BlueBerry/Bundles/org.blueberry.core.commands/src/berryIObjectWithState.h index 393ae5ab30..da0eaf743f 100644 --- a/BlueBerry/Bundles/org.blueberry.core.commands/src/berryIObjectWithState.h +++ b/BlueBerry/Bundles/org.blueberry.core.commands/src/berryIObjectWithState.h @@ -1,87 +1,87 @@ /*========================================================================= Program: BlueBerry Platform Language: C++ Date: $Date$ Version: $Revision$ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #ifndef BERRYIOBJECTWITHSTATE_H_ #define BERRYIOBJECTWITHSTATE_H_ -#include "berryCommandsDll.h" +#include #include "berryState.h" #include namespace berry { /** *

* An object that holds zero or more state objects. This state information can * be shared between different instances of IObjectWithState. *

*

* Clients may implement, but must not extend this interface. *

* * @see AbstractHandlerWithState * @since 3.2 */ struct BERRY_COMMANDS IObjectWithState : public virtual Object { berryInterfaceMacro(IObjectWithState, berry) /** * Adds state to this object. * * @param id * The identifier indicating the type of state being added; must * not be null. * @param state * The new state to add to this object; must not be * null. */ virtual void AddState(const std::string& id, const State::Pointer state) = 0; /** * Gets the state with the given id. * * @param stateId * The identifier of the state to retrieve; must not be * null. * @return The state; may be null if there is no state with * the given id. */ virtual State::Pointer GetState(const std::string& stateId) const = 0; /** * Gets the identifiers for all of the state associated with this object. * * @return All of the state identifiers; may be empty, but never * null. */ virtual std::vector GetStateIds() const = 0; /** * Removes state from this object. * * @param stateId * The id of the state to remove from this object; must not be * null. */ virtual void RemoveState(const std::string& stateId) = 0; }; } #endif /*BERRYIOBJECTWITHSTATE_H_*/ diff --git a/BlueBerry/Bundles/org.blueberry.core.commands/src/berryIParameter.h b/BlueBerry/Bundles/org.blueberry.core.commands/src/berryIParameter.h index c96d9e2817..3926f08d40 100644 --- a/BlueBerry/Bundles/org.blueberry.core.commands/src/berryIParameter.h +++ b/BlueBerry/Bundles/org.blueberry.core.commands/src/berryIParameter.h @@ -1,80 +1,80 @@ /*========================================================================= Program: BlueBerry Platform Language: C++ Date: $Date$ Version: $Revision$ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #ifndef BERRYIPARAMETER_H_ #define BERRYIPARAMETER_H_ #include #include -#include "berryCommandsDll.h" +#include #include namespace berry { /** *

* A parameter for a command. A parameter identifies a type of information that * the command might accept. For example, a "Show View" command might accept the * id of a view for display. This parameter also identifies possible values, for * display in the user interface. *

* * @since 3.1 */ struct BERRY_COMMANDS IParameter : public virtual Object { berryInterfaceMacro(IParameter, berry); typedef std::map ParameterValues; /** * Returns the identifier for this parameter. * * @return The identifier; never null. */ virtual std::string GetId() const = 0; /** * Returns the human-readable name for this parameter. * * @return The parameter name; never null. */ virtual std::string GetName() const = 0; /** * Returns the values associated with this parameter. * * @return The values associated with this parameter. This must not be * null. * @throws ParameterValuesException * If the values can't be retrieved for some reason. */ virtual ParameterValues GetValues() const = 0; /** * Returns whether parameter is optional. Otherwise, it is required. * * @return true if the parameter is optional; * false if it is required. */ virtual bool IsOptional() const = 0; }; } #endif /*BERRYIPARAMETER_H_*/ diff --git a/BlueBerry/Bundles/org.blueberry.core.commands/src/berryIParameterTypeListener.h b/BlueBerry/Bundles/org.blueberry.core.commands/src/berryIParameterTypeListener.h index b74451ddd7..79e9f043fa 100755 --- a/BlueBerry/Bundles/org.blueberry.core.commands/src/berryIParameterTypeListener.h +++ b/BlueBerry/Bundles/org.blueberry.core.commands/src/berryIParameterTypeListener.h @@ -1,73 +1,73 @@ /*========================================================================= Program: BlueBerry Platform Language: C++ Date: $Date$ Version: $Revision$ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #ifndef BERRYIPARAMETERTYPELISTENER_H_ #define BERRYIPARAMETERTYPELISTENER_H_ #include #include #include -#include "berryCommandsDll.h" +#include namespace berry { class ParameterTypeEvent; /** * An instance of this interface can be used by clients to receive notification * of changes to one or more instances of {@link ParameterType}. *

* This interface may be implemented by clients. *

* * @see ParameterType#AddListener(IParameterTypeListener::Pointer) * @see ParameterType#RemoveListener(IParameterTypeListener::Pointer) */ struct BERRY_COMMANDS IParameterTypeListener : public virtual Object { berryInterfaceMacro(IParameterTypeListener, berry) struct Events { typedef Message1 > Event; Event parameterTypeChanged; void AddListener(IParameterTypeListener::Pointer listener); void RemoveListener(IParameterTypeListener::Pointer listener); typedef MessageDelegate1 > Delegate; }; /** * Notifies that one or more properties of an instance of * {@link ParameterType} have changed. Specific details are described in the * {@link ParameterTypeEvent}. * * @param parameterTypeEvent * the event. Guaranteed not to be null. */ virtual void ParameterTypeChanged(const SmartPointer parameterTypeEvent) = 0; }; } #endif /* BERRYIPARAMETERTYPELISTENER_H_ */ diff --git a/BlueBerry/Bundles/org.blueberry.core.commands/src/berryIParameterValueConverter.h b/BlueBerry/Bundles/org.blueberry.core.commands/src/berryIParameterValueConverter.h index ca031a0bf1..4ef896c48c 100755 --- a/BlueBerry/Bundles/org.blueberry.core.commands/src/berryIParameterValueConverter.h +++ b/BlueBerry/Bundles/org.blueberry.core.commands/src/berryIParameterValueConverter.h @@ -1,110 +1,110 @@ /*========================================================================= Program: BlueBerry Platform Language: C++ Date: $Date$ Version: $Revision$ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #ifndef BERRYABSTRACTPARAMETERVALUECONVERTER_H_ #define BERRYABSTRACTPARAMETERVALUECONVERTER_H_ #include #include #include "common/berryCommandExceptions.h" -#include "berryCommandsDll.h" +#include namespace berry { /** *

* Supports conversion between objects and strings for command parameter values. * Extenders must produce strings that identify objects (of a specific command * parameter type) as well as consume the strings to locate and return the * objects they identify. *

*

* This class offers multiple handlers of a command a consistent way of * converting string parameter values into the objects that the handlers would * prefer to deal with. This class also gives clients a way to serialize * object parameters as strings so that entire parameterized commands can be * serialized, stored and later deserialized and executed. *

*

* This class will typically be extended so the subclass can be referenced from * the converter attribute of the * commandParameterType elemement of the * org.eclipse.ui.commands extension-point. Objects implementing * this interface may also be passed directly to * {@link ParameterType#Define(IParameterValueConverter::Pointer)} by * clients. *

* * @see ParameterType#Define(IParameterValueConverter::Pointer) * @see ParameterizedCommand#Serialize() */ struct BERRY_COMMANDS IParameterValueConverter : public virtual Object { berryInterfaceMacro(IParameterValueConverter, berry) /** * Returns whether the provided value is compatible with this parameter * value converter. An object is compatible with a converter if the object is an * instance of the class defined in the type attribute of * the commandParameterType element. * * @param value * an object to check for compatibility with this parameter type; * may be null. * @return true if the value is compatible with this converter, * false otherwise */ virtual bool IsCompatible(const Object::ConstPointer value) const = 0; /** * Converts a string encoded command parameter value into the parameter * value object. * * @param parameterValue * a command parameter value string describing an object; may be * null * @return the object described by the command parameter value string; may * be null * @throws ParameterValueConversionException * if an object cannot be produced from the * parameterValue string */ virtual Object::Pointer ConvertToObject(const std::string& parameterValue) throw(ParameterValueConversionException) = 0; /** * Converts a command parameter value object into a string that encodes a * reference to the object or serialization of the object. * * @param parameterValue * an object to convert into an identifying string; may be * null * @return a string describing the provided object; may be null * @throws ParameterValueConversionException * if a string reference or serialization cannot be provided for * the parameterValue */ virtual std::string ConvertToString(const Object::Pointer parameterValue) throw(ParameterValueConversionException) = 0; }; } #endif /* BERRYABSTRACTPARAMETERVALUECONVERTER_H_ */ diff --git a/BlueBerry/Bundles/org.blueberry.core.commands/src/berryIStateListener.h b/BlueBerry/Bundles/org.blueberry.core.commands/src/berryIStateListener.h index 27342c1391..3b8ca36582 100755 --- a/BlueBerry/Bundles/org.blueberry.core.commands/src/berryIStateListener.h +++ b/BlueBerry/Bundles/org.blueberry.core.commands/src/berryIStateListener.h @@ -1,73 +1,73 @@ /*========================================================================= Program: BlueBerry Platform Language: C++ Date: $Date$ Version: $Revision$ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #ifndef BERRYISTATELISTENER_H_ #define BERRYISTATELISTENER_H_ #include "berryObject.h" #include "berryMacros.h" -#include "berryCommandsDll.h" +#include namespace berry { class State; /** *

* A listener to changes in some state. *

*

* Clients may implement, but must not extend this interface. *

* * @since 3.2 */ struct BERRY_COMMANDS IStateListener : public virtual Object { berryInterfaceMacro(IStateListener, berry) struct Events { typedef Message2, Object::Pointer> StateEvent; StateEvent stateChanged; void AddListener(IStateListener::Pointer listener); void RemoveListener(IStateListener::Pointer listener); private: typedef MessageDelegate2, Object::Pointer> Delegate; }; /** * Handles a change to the value in some state. * * @param state * The state that has changed; never null. The * value for this state has been updated to the new value. * @param oldValue * The old value; may be anything. */ virtual void HandleStateChange(SmartPointer state, Object::Pointer oldValue) = 0; }; } #endif /* BERRYISTATELISTENER_H_ */ diff --git a/BlueBerry/Bundles/org.blueberry.core.commands/src/berryITypedParameter.h b/BlueBerry/Bundles/org.blueberry.core.commands/src/berryITypedParameter.h index fa48defe96..fc7234bda6 100755 --- a/BlueBerry/Bundles/org.blueberry.core.commands/src/berryITypedParameter.h +++ b/BlueBerry/Bundles/org.blueberry.core.commands/src/berryITypedParameter.h @@ -1,56 +1,56 @@ /*========================================================================= Program: BlueBerry Platform Language: C++ Date: $Date$ Version: $Revision$ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #ifndef BERRYITYPEDPARAMETER_H_ #define BERRYITYPEDPARAMETER_H_ #include #include -#include "berryCommandsDll.h" +#include namespace berry { class ParameterType; /** * A command parameter that has a declared type. This interface is intended to * be implemented by implementors of {@link IParameter} that will support * parameter types. * */ struct BERRY_COMMANDS ITypedParameter : public virtual Object { berryInterfaceMacro(ITypedParameter, berry) /** * Returns the {@link ParameterType} associated with a command parameter or * null if the parameter does not declare a type. *

* Note that the parameter type returned may be undefined. *

* * @return the parameter type associated with a command parameter or * null if the parameter does not declare a type */ virtual SmartPointer GetParameterType() = 0; }; } #endif /* BERRYITYPEDPARAMETER_H_ */ diff --git a/BlueBerry/Bundles/org.blueberry.core.commands/src/berryParameterization.h b/BlueBerry/Bundles/org.blueberry.core.commands/src/berryParameterization.h index f327d42431..e0b693e8bc 100755 --- a/BlueBerry/Bundles/org.blueberry.core.commands/src/berryParameterization.h +++ b/BlueBerry/Bundles/org.blueberry.core.commands/src/berryParameterization.h @@ -1,145 +1,145 @@ /*========================================================================= Program: BlueBerry Platform Language: C++ Date: $Date$ Version: $Revision$ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #ifndef BERRYPARAMETERIZATION_H_ #define BERRYPARAMETERIZATION_H_ -#include "berryCommandsDll.h" +#include #include "common/berryCommandExceptions.h" #include #include namespace berry { struct IParameter; /** *

* A parameter with a specific value. This is usually a part of a * ParameterizedCommand, which is used to refer to a command * with a collection of parameterizations. *

* * @since 3.1 */ class BERRY_COMMANDS Parameterization { private: /** * The constant integer hash code value meaning the hash code has not yet * been computed. */ static const std::size_t HASH_CODE_NOT_COMPUTED; // = 0; /** * A factor for computing the hash code for all parameterized commands. */ static const std::size_t HASH_FACTOR; // = 89; /** * The seed for the hash code for all parameterized commands. */ static const std::size_t HASH_INITIAL; /** * The hash code for this object. This value is computed lazily, and marked * as invalid when one of the values on which it is based changes. */ mutable std::size_t hashCode; /** * The parameter that is being parameterized. This value is never * null. */ SmartPointer parameter; /** * The value that defines the parameterization. This value may be * null. */ std::string value; public: /** * Constructs a new instance of Parameterization. * * @param parameter * The parameter that is being parameterized; must not be * null. * @param value * The value for the parameter; may be null. */ Parameterization(const SmartPointer parameter, const std::string& value); /** * Copy constructor */ Parameterization(const Parameterization& p); Parameterization& operator=(const Parameterization& p); /* (non-Javadoc) * @see java.lang.Object#equals(java.lang.Object) */ bool operator==(const Parameterization& parameterization) const; operator bool() const; /** * Returns the parameter that is being parameterized. * * @return The parameter; never null. */ SmartPointer GetParameter() const; /** * Returns the value for the parameter in this parameterization. * * @return The value; may be null. */ std::string GetValue() const; /** * Returns the human-readable name for the current value, if any. If the * name cannot be found, then it simply returns the value. It also ensures * that any null values are converted into an empty string. * * @return The human-readable name of the value; never null. * @throws ParameterValuesException * If the parameter needed to be initialized, but couldn't be. */ #ifdef _MSC_VER std::string GetValueName() const throw(); #else std::string GetValueName() const throw(ParameterValuesException); #endif /* (non-Javadoc) * @see java.lang.Object#hashCode() */ std::size_t HashCode() const; }; } #endif /* BERRYPARAMETERIZATION_H_ */ diff --git a/BlueBerry/Bundles/org.blueberry.core.commands/src/berryParameterizedCommand.h b/BlueBerry/Bundles/org.blueberry.core.commands/src/berryParameterizedCommand.h index 7f02e97bef..1c4ef99e37 100755 --- a/BlueBerry/Bundles/org.blueberry.core.commands/src/berryParameterizedCommand.h +++ b/BlueBerry/Bundles/org.blueberry.core.commands/src/berryParameterizedCommand.h @@ -1,357 +1,357 @@ /*========================================================================= Program: BlueBerry Platform Language: C++ Date: $Date$ Version: $Revision$ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #ifndef BERRYPARAMETERIZEDCOMMAND_H_ #define BERRYPARAMETERIZEDCOMMAND_H_ #include #include #include "common/berryCommandExceptions.h" -#include "berryCommandsDll.h" +#include #include #include namespace berry { struct IParameter; class Command; class Parameterization; /** *

* A command that has had one or more of its parameters specified. This class * serves as a utility class for developers that need to manipulate commands * with parameters. It handles the behaviour of generating a parameter map and a * human-readable name. *

* * @since 3.1 */ class BERRY_COMMANDS ParameterizedCommand: public Object { //implements Comparable { public: berryObjectMacro(ParameterizedCommand) /** * The index of the parameter id in the parameter values. * * @deprecated no longer used */ static const int INDEX_PARAMETER_ID; // = 0; /** * The index of the human-readable name of the parameter itself, in the * parameter values. * * @deprecated no longer used */ static const int INDEX_PARAMETER_NAME; // = 1; /** * The index of the human-readable name of the value of the parameter for * this command. * * @deprecated no longer used */ static const int INDEX_PARAMETER_VALUE_NAME; // = 2; /** * The index of the value of the parameter that the command can understand. * * @deprecated no longer used */ static const int INDEX_PARAMETER_VALUE_VALUE; // = 3; /** * Constructs a new instance of ParameterizedCommand with * specific values for zero or more of its parameters. * * @param command * The command that is parameterized; must not be * null. * @param parameterizations * An array of parameterizations binding parameters to values for * the command. This value may be null. */ ParameterizedCommand(const SmartPointer command, const std::vector& parameterizations); bool operator<(const Object* object) const; /* * (non-Javadoc) * * @see java.lang.Object#equals(java.lang.Object) */ bool operator==(const Object* object) const; /** * Executes this command with its parameters. This does extra checking to * see if the command is enabled and defined. If it is not both enabled and * defined, then the execution listeners will be notified and an exception * thrown. * * @param trigger * The object that triggered the execution; may be * null. * @param applicationContext * The state of the application at the time the execution was * triggered; may be null. * @return The result of the execution; may be null. * @throws ExecutionException * If the handler has problems executing this command. * @throws NotDefinedException * If the command you are trying to execute is not defined. * @throws NotEnabledException * If the command you are trying to execute is not enabled. * @throws NotHandledException * If there is no handler. * @since 3.2 */ Object::Pointer ExecuteWithChecks(const Object::ConstPointer trigger, const Object::ConstPointer applicationContext) throw(ExecutionException, NotDefinedException, NotEnabledException, NotHandledException); /** * Returns the base command. It is possible for more than one parameterized * command to have the same identifier. * * @return The command; never null, but may be undefined. */ SmartPointer GetCommand() const; /** * Returns the command's base identifier. It is possible for more than one * parameterized command to have the same identifier. * * @return The command id; never null. */ std::string GetId() const; /** * Returns a human-readable representation of this command with all of its * parameterizations. * * @return The human-readable representation of this parameterized command; * never null. * @throws NotDefinedException * If the underlying command is not defined. */ std::string GetName() const throw(NotDefinedException); /** * Returns the parameter map, as can be used to construct an * ExecutionEvent. * * @return The map of parameter ids (String) to parameter * values (String). This map is never * null, but may be empty. */ std::map GetParameterMap() const; /* * (non-Javadoc) * * @see java.lang.Object#hashCode() */ std::size_t HashCode() const; /** * Returns a {@link String} containing the command id, parameter ids and * parameter values for this {@link ParameterizedCommand}. The returned * {@link String} can be stored by a client and later used to reconstruct an * equivalent {@link ParameterizedCommand} using the * {@link CommandManager#deserialize(String)} method. *

* The syntax of the returned {@link String} is as follows: *

* *
* serialization = commandId [ '(' parameters ')' ]
* parameters = parameter [ ',' parameters ]
* parameter = parameterId [ '=' parameterValue ] *
* *

* In the syntax above, sections inside square-brackets are optional. The * characters in single quotes ((, ), * , and =) indicate literal characters. *

*

* commandId represents the command id encoded with * separator characters escaped. parameterId and * parameterValue represent the parameter ids and * values encoded with separator characters escaped. The separator * characters (, ), , and * = are escaped by prepending a %. This * requires % to be escaped, which is also done by prepending * a %. *

*

* The order of the parameters is not defined (and not important). A missing * parameterValue indicates that the value of the * parameter is null. *

*

* For example, the string shown below represents a serialized parameterized * command that can be used to show the Resource perspective: *

*

* org.eclipse.ui.perspectives.showPerspective(org.eclipse.ui.perspectives.showPerspective.perspectiveId=org.eclipse.ui.resourcePerspective) *

*

* This example shows the more general form with multiple parameters, * null value parameters, and escaped = in the * third parameter value. *

*

* command.id(param1.id=value1,param2.id,param3.id=esc%=val3) *

* * @return A string containing the escaped command id, parameter ids and * parameter values; never null. * @see CommandManager#deserialize(String) * @since 3.2 */ std::string Serialize(); std::string ToString() const; /** *

* Generates all the possible combinations of command parameterizations for * the given command. If the command has no parameters, then this is simply * a parameterized version of that command. If a parameter is optional, both * the included and not included cases are considered. *

*

* If one of the parameters cannot be loaded due to a * ParameterValuesException, then it is simply ignored. *

* * @param command * The command for which the parameter combinations should be * generated; must not be null. * @return A collection of ParameterizedCommand instances * representing all of the possible combinations. This value is * never empty and it is never null. * @throws NotDefinedException * If the command is not defined. */ static std::vector GenerateCombinations(const SmartPointer command) throw(NotDefinedException); /** * Take a command and a map of parameter IDs to values, and generate the * appropriate parameterized command. * * @param command * The command object. Must not be null. * @param parameters * A map of String parameter ids to objects. May be * null. * @return the parameterized command, or null if it could not * be generated * @since 3.4 */ static ParameterizedCommand::Pointer GenerateCommand(const SmartPointer command, const std::map& parameters); private: /** * The constant integer hash code value meaning the hash code has not yet * been computed. */ static const std::size_t HASH_CODE_NOT_COMPUTED; // = 0; /** * A factor for computing the hash code for all parameterized commands. */ static const std::size_t HASH_FACTOR; // = 89; /** * The seed for the hash code for all parameterized commands. */ static const std::size_t HASH_INITIAL; /** * Escapes special characters in the command id, parameter ids and parameter * values for {@link #serialize()}. The special characters * {@link CommandManager#PARAMETER_START_CHAR}, * {@link CommandManager#PARAMETER_END_CHAR}, * {@link CommandManager#ID_VALUE_CHAR}, * {@link CommandManager#PARAMETER_SEPARATOR_CHAR} and * {@link CommandManager#ESCAPE_CHAR} are escaped by prepending a * {@link CommandManager#ESCAPE_CHAR} character. * * @param rawText * a String to escape special characters in for * serialization. * @return a String representing rawText with * special serialization characters escaped * @since 3.2 */ static std::string Escape(const std::string& rawText); /** * Generates every possible combination of parameter values for the given * parameters. Parameters values that cannot be initialized are just * ignored. Optional parameters are considered. * * @param startIndex * The index in the parameters that we should * process. This must be a valid index. * @param parameters * The parameters in to process; must not be null. * @return A collection (Collection) of combinations (List * of Parameterization). */ static std::vector > ExpandParameters(unsigned int startIndex, const std::vector >& parameters); /** * The base command which is being parameterized. This value is never * null. */ const SmartPointer command; /** * The hash code for this object. This value is computed lazily, and marked * as invalid when one of the values on which it is based changes. */ mutable std::size_t hashCode; /** * This is an array of parameterization defined for this command. This value * may be null if the command has no parameters. */ std::vector parameterizations; mutable std::string name; }; } #endif /* BERRYPARAMETERIZEDCOMMAND_H_ */ diff --git a/BlueBerry/Bundles/org.blueberry.core.commands/src/berryState.h b/BlueBerry/Bundles/org.blueberry.core.commands/src/berryState.h index bc52195683..e0087c30bf 100644 --- a/BlueBerry/Bundles/org.blueberry.core.commands/src/berryState.h +++ b/BlueBerry/Bundles/org.blueberry.core.commands/src/berryState.h @@ -1,134 +1,134 @@ /*========================================================================= Program: BlueBerry Platform Language: C++ Date: $Date$ Version: $Revision$ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #ifndef BERRYSTATE_H_ #define BERRYSTATE_H_ #include #include -#include "berryCommandsDll.h" +#include #include "berryIStateListener.h" namespace berry { /** *

* A piece of state information that can be shared between objects, and might be * persisted between sessions. This can be used for commands that toggle between * two states and wish to pass this state information between different * handlers. *

*

* This state object can either be used as a single state object shared between * several commands, or one state object per command -- depending on the needs * of the application. *

*

* Clients may instantiate or extend this class. *

* * @since 3.2 */ class BERRY_COMMANDS State : public Object { public: berryObjectMacro(State) /** * Adds a listener to changes for this state. * * @param listener * The listener to add; must not be null. */ void AddListener(IStateListener::Pointer listener); /** * Returns the identifier for this state. * * @return The id; may be null. */ std::string GetId() const; /** * The current value associated with this state. This can be any type of * object, but implementations will usually restrict this value to a * particular type. * * @return The current value; may be anything. */ Object::Pointer GetValue() const; /** * Removes a listener to changes from this state. * * @param listener * The listener to remove; must not be null. */ void RemoveListener(IStateListener::Pointer listener); /** * Sets the identifier for this object. This method should only be called * by the command framework. Clients should not call this method. * * @param id * The id; must not be null. */ void SetId(const std::string& id); /** * Sets the value for this state object. * * @param value * The value to set; may be anything. */ void SetValue(const Object::Pointer value); protected: /** * Notifies listeners to this state that it has changed in some way. * * @param oldValue * The old value; may be anything. */ void FireStateChanged(Object::Pointer oldValue); private: /** * The identifier of the state; may be null if it has not * been initialized. */ std::string id; /** * The value held by this state; may be anything at all. */ Object::Pointer value; IStateListener::Events stateEvents; }; } #endif /*BERRYSTATE_H_*/ diff --git a/BlueBerry/Bundles/org.blueberry.core.commands/src/common/berryAbstractBitSetEvent.h b/BlueBerry/Bundles/org.blueberry.core.commands/src/common/berryAbstractBitSetEvent.h index aa08782de8..d21d6325a3 100755 --- a/BlueBerry/Bundles/org.blueberry.core.commands/src/common/berryAbstractBitSetEvent.h +++ b/BlueBerry/Bundles/org.blueberry.core.commands/src/common/berryAbstractBitSetEvent.h @@ -1,58 +1,58 @@ /*========================================================================= Program: BlueBerry Platform Language: C++ Date: $Date$ Version: $Revision$ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #ifndef BERRYABSTRACTBITSETEVENT_H_ #define BERRYABSTRACTBITSETEVENT_H_ #include "berryObject.h" #include "berryMacros.h" -#include "../berryCommandsDll.h" +#include namespace berry { /** *

* An event that carries with it two or more boolean values. This provides a * single integer value which can then be used as a bit set. *

* * @since 3.1 */ class BERRY_COMMANDS AbstractBitSetEvent : public virtual Object { public: berryObjectMacro(AbstractBitSetEvent) protected: AbstractBitSetEvent(); /** * A collection of bits representing whether certain values have changed. A * bit is set (i.e., 1) if the corresponding property has * changed. It can be assumed that this value will be correctly initialized * by the superconstructor. */ int changedValues; }; } #endif /* BERRYABSTRACTBITSETEVENT_H_ */ diff --git a/BlueBerry/Bundles/org.blueberry.core.commands/src/common/berryCommandExceptions.h b/BlueBerry/Bundles/org.blueberry.core.commands/src/common/berryCommandExceptions.h index 6c11c94a90..f1e96a7a4f 100644 --- a/BlueBerry/Bundles/org.blueberry.core.commands/src/common/berryCommandExceptions.h +++ b/BlueBerry/Bundles/org.blueberry.core.commands/src/common/berryCommandExceptions.h @@ -1,58 +1,58 @@ /*========================================================================= Program: BlueBerry Platform Language: C++ Date: $Date$ Version: $Revision$ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #ifndef BERRYCOMMANDEXCEPTIONS_H_ #define BERRYCOMMANDEXCEPTIONS_H_ -#include "../berryCommandsDll.h" +#include #include namespace berry { POCO_DECLARE_EXCEPTION(BERRY_COMMANDS, CommandException, Poco::RuntimeException); POCO_DECLARE_EXCEPTION(BERRY_COMMANDS, ExecutionException, CommandException); POCO_DECLARE_EXCEPTION(BERRY_COMMANDS, NotHandledException, CommandException); POCO_DECLARE_EXCEPTION(BERRY_COMMANDS, NotDefinedException, CommandException); POCO_DECLARE_EXCEPTION(BERRY_COMMANDS, NotEnabledException, CommandException); POCO_DECLARE_EXCEPTION(BERRY_COMMANDS, ParameterValueConversionException, CommandException); /** * Signals that a problem has occurred while trying to create an instance of * IParameterValues. In applications based on the registry * provided by core, this usually indicates a problem creating an * IExecutableExtension. For other applications, this exception * could be used to signify any general problem during initialization. * */ POCO_DECLARE_EXCEPTION(BERRY_COMMANDS, ParameterValuesException, CommandException); /** * Signals that an exception occured while serializing a * {@link ParameterizedCommand} to a string or deserializing a string to a * {@link ParameterizedCommand}. * * This class is not intended to be extended by clients. * */ POCO_DECLARE_EXCEPTION(BERRY_COMMANDS, SerializationException, CommandException); } #endif /*BERRYCOMMANDEXCEPTIONS_H_*/ diff --git a/BlueBerry/Bundles/org.blueberry.core.commands/src/common/berryHandleObject.h b/BlueBerry/Bundles/org.blueberry.core.commands/src/common/berryHandleObject.h index 95c4451e8f..be15b02410 100644 --- a/BlueBerry/Bundles/org.blueberry.core.commands/src/common/berryHandleObject.h +++ b/BlueBerry/Bundles/org.blueberry.core.commands/src/common/berryHandleObject.h @@ -1,166 +1,166 @@ /*========================================================================= Program: BlueBerry Platform Language: C++ Date: $Date$ Version: $Revision$ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #ifndef BERRYHANDLEOBJECT_H_ #define BERRYHANDLEOBJECT_H_ #include #include -#include "../berryCommandsDll.h" +#include #include namespace berry { /** *

* An object that can exist in one of two states: defined and undefined. This is * used by APIs that want to give a handle to an object, even though the object * does not fully exist yet. This way, users can attach listeners to objects * before they come into existence. It also protects the API from users that do * not release references when they should. *

*

* To enforce good coding practice, all handle objects must implement * equals and toString. Please use * string to cache the result for toString once * calculated. *

*

* All handle objects are referred to using a single identifier. This identifier * is a instance of String. It is important that this identifier * remain unique within whatever context that handle object is being used. For * example, there should only ever be one instance of Command * with a given identifier. *

* * @since 3.1 */ class BERRY_COMMANDS HandleObject : public virtual Object { // extends EventManager implements IIdentifiable { public: berryObjectMacro(HandleObject) private: /** * The constant integer hash code value meaning the hash code has not yet * been computed. */ static const std::size_t HASH_CODE_NOT_COMPUTED; // = 0; /** * A factor for computing the hash code for all schemes. */ static const std::size_t HASH_FACTOR; // = 89; /** * The seed for the hash code for all schemes. */ static const std::size_t HASH_INITIAL; /** * The hash code for this object. This value is computed lazily, and marked * as invalid when one of the values on which it is based changes. */ mutable std::size_t hashCode; // = HASH_CODE_NOT_COMPUTED; protected: /** * Whether this object is defined. A defined object is one that has been * fully initialized. By default, all objects start as undefined. */ bool defined; /** * The identifier for this object. This identifier should be unique across * all objects of the same type and should never change. This value will * never be null. */ const std::string id; /** * The string representation of this object. This string is for debugging * purposes only, and is not meant to be displayed to the user. This value * is computed lazily, and is cleared if one of its dependent values * changes. */ mutable std::string str; /** * Constructs a new instance of HandleObject. * * @param id * The id of this handle; must not be null. */ HandleObject(const std::string& id); public: /** * Tests whether this object is equal to another object. A handle object is * only equal to another handle object with the same id and the same class. * * @param object * The object with which to compare; may be null. * @return true if the objects are equal; false * otherwise. */ bool operator==(const Object* object) const; virtual std::string GetId() const; /** * Computes the hash code for this object based on the id. * * @return The hash code for this object. */ virtual std::size_t HashCode() const { if (hashCode == HASH_CODE_NOT_COMPUTED) { hashCode = HASH_INITIAL * HASH_FACTOR + Poco::hash(id); if (hashCode == HASH_CODE_NOT_COMPUTED) { hashCode++; } } return hashCode; } /** * Whether this instance is defined. A defined instance is one that has been * fully initialized. This allows objects to effectively disappear even * though other objects may still have references to them. * * @return true if this object is defined; false * otherwise. */ virtual bool IsDefined() const; /** * Makes this object becomes undefined. This method should make any defined * properties null. It should also send notification to any * listeners that these properties have changed. */ virtual void Undefine() = 0; }; } #endif /*BERRYHANDLEOBJECT_H_*/ diff --git a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryQtDnDTweaklet.h b/BlueBerry/Bundles/org.blueberry.core.commands/src/internal/berryPluginActivator.cpp old mode 100755 new mode 100644 similarity index 60% copy from BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryQtDnDTweaklet.h copy to BlueBerry/Bundles/org.blueberry.core.commands/src/internal/berryPluginActivator.cpp index d4ba28a835..cf356d7538 --- a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryQtDnDTweaklet.h +++ b/BlueBerry/Bundles/org.blueberry.core.commands/src/internal/berryPluginActivator.cpp @@ -1,35 +1,41 @@ /*========================================================================= Program: BlueBerry Platform Language: C++ Date: $Date$ Version: $Revision$ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ -#ifndef BERRYQTDNDTWEAKLET_H_ -#define BERRYQTDNDTWEAKLET_H_ +#include "berryPluginActivator.h" -#include +#include namespace berry { -class QtDnDTweaklet : public DnDTweaklet +org_blueberry_core_commands_Activator::org_blueberry_core_commands_Activator() { -public: +} + +void org_blueberry_core_commands_Activator::start(ctkPluginContext* context) +{ + Q_UNUSED(context) +} - ITracker* CreateTracker(); -}; +void org_blueberry_core_commands_Activator::stop(ctkPluginContext* context) +{ + Q_UNUSED(context) +} } -#endif /* BERRYQTDNDTWEAKLET_H_ */ +Q_EXPORT_PLUGIN2(org_blueberry_core_commands, berry::org_blueberry_core_commands_Activator) diff --git a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryQtIconImageDescriptor.h b/BlueBerry/Bundles/org.blueberry.core.commands/src/internal/berryPluginActivator.h old mode 100755 new mode 100644 similarity index 60% copy from BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryQtIconImageDescriptor.h copy to BlueBerry/Bundles/org.blueberry.core.commands/src/internal/berryPluginActivator.h index 9afe1a7db5..42ee1c9c7f --- a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryQtIconImageDescriptor.h +++ b/BlueBerry/Bundles/org.blueberry.core.commands/src/internal/berryPluginActivator.h @@ -1,49 +1,43 @@ /*========================================================================= Program: BlueBerry Platform Language: C++ Date: $Date$ Version: $Revision$ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ -#ifndef BERRYQTICONIMAGEDESCRIPTOR_H_ -#define BERRYQTICONIMAGEDESCRIPTOR_H_ +#ifndef BERRYPLUGINACTIVATOR_H +#define BERRYPLUGINACTIVATOR_H -#include - -class QIcon; +#include namespace berry { -class QtIconImageDescriptor : public ImageDescriptor +class org_blueberry_core_commands_Activator : + public QObject, public ctkPluginActivator { - -private: - - QIcon* icon; + Q_OBJECT + Q_INTERFACES(ctkPluginActivator) public: + org_blueberry_core_commands_Activator(); - QtIconImageDescriptor(void* img); - - virtual void* CreateImage(bool returnMissingImageOnError = true); - - virtual void DestroyImage(void* img); - - virtual bool operator==(const Object* o) const; - + void start(ctkPluginContext* context); + void stop(ctkPluginContext* context); }; +typedef org_blueberry_core_commands_Activator PluginActivator; + } -#endif /* BERRYQTICONIMAGEDESCRIPTOR_H_ */ +#endif // BERRYPLUGINACTIVATOR_H diff --git a/BlueBerry/Bundles/org.blueberry.core.expressions/CMakeLists.txt b/BlueBerry/Bundles/org.blueberry.core.expressions/CMakeLists.txt index f9ae7ef20d..74de52045d 100644 --- a/BlueBerry/Bundles/org.blueberry.core.expressions/CMakeLists.txt +++ b/BlueBerry/Bundles/org.blueberry.core.expressions/CMakeLists.txt @@ -1,3 +1,4 @@ +PROJECT(org_blueberry_core_expressions) -MACRO_CREATE_PLUGIN() -TARGET_LINK_LIBRARIES(${PLUGIN_TARGET} optimized PocoXML debug PocoXMLd) +MACRO_CREATE_CTK_PLUGIN(EXPORT_DIRECTIVE BERRY_EXPRESSIONS + EXPORTED_INCLUDE_SUFFIXES src src/common) diff --git a/BlueBerry/Bundles/org.blueberry.core.expressions/META-INF/MANIFEST.MF b/BlueBerry/Bundles/org.blueberry.core.expressions/META-INF/MANIFEST.MF deleted file mode 100644 index 45fd68e461..0000000000 --- a/BlueBerry/Bundles/org.blueberry.core.expressions/META-INF/MANIFEST.MF +++ /dev/null @@ -1,6 +0,0 @@ -Manifest-Version: 1.0 -Bundle-Name: BlueBerry Core Expressions Plugin -Bundle-SymbolicName: org.blueberry.core.expressions -Bundle-Version: 1.0.0 -Require-Bundle: org.blueberry.osgi, org.blueberry.core.runtime -Bundle-Vendor: DKFZ, Medical and Biological Informatics \ No newline at end of file diff --git a/BlueBerry/Bundles/org.blueberry.core.expressions/files.cmake b/BlueBerry/Bundles/org.blueberry.core.expressions/files.cmake index c1956308fe..7fb364bff5 100644 --- a/BlueBerry/Bundles/org.blueberry.core.expressions/files.cmake +++ b/BlueBerry/Bundles/org.blueberry.core.expressions/files.cmake @@ -1,44 +1,53 @@ +SET(MOC_H_FILES + src/internal/berryPluginActivator.h +) + +SET(CACHED_RESOURCE_FILES + plugin.xml +) + SET(SRC_CPP_FILES berryElementHandler.cpp berryEvaluationContext.cpp berryEvaluationResult.cpp berryExpression.cpp berryExpressionConverter.cpp berryExpressionInfo.cpp berryExpressionTagNames.cpp berryPropertyTester.cpp ) SET(INTERNAL_CPP_FILES berryAdaptExpression.cpp berryAndExpression.cpp berryCompositeExpression.cpp berryCountExpression.cpp berryDefaultVariable.cpp berryDefinitionRegistry.cpp berryEnablementExpression.cpp berryEqualsExpression.cpp berryExpressions.cpp berryInstanceofExpression.cpp berryIterateExpression.cpp berryNotExpression.cpp berryOrExpression.cpp + berryPluginActivator.cpp berryProperty.cpp berryPropertyTesterDescriptor.cpp berryReferenceExpression.cpp berryResolveExpression.cpp berryStandardElementHandler.cpp berrySystemTestExpression.cpp berryTestExpression.cpp berryTypeExtension.cpp berryTypeExtensionManager.cpp berryWithExpression.cpp ) foreach(file ${SRC_CPP_FILES}) SET(CPP_FILES ${CPP_FILES} src/${file}) endforeach(file ${SRC_CPP_FILES}) foreach(file ${INTERNAL_CPP_FILES}) SET(CPP_FILES ${CPP_FILES} src/internal/${file}) endforeach(file ${INTERNAL_CPP_FILES}) diff --git a/BlueBerry/Bundles/org.blueberry.core.expressions/manifest_headers.cmake b/BlueBerry/Bundles/org.blueberry.core.expressions/manifest_headers.cmake new file mode 100644 index 0000000000..74a9585f93 --- /dev/null +++ b/BlueBerry/Bundles/org.blueberry.core.expressions/manifest_headers.cmake @@ -0,0 +1,6 @@ +set(Plugin-Name "BlueBerry Core Expressions Plugin") +set(Plugin-Version "1.0.0") +set(Plugin-Vendor "DKFZ, Medical and Biological Informatics") +set(Plugin-ContactAddress "http://www.mitk.org") +set(Require-Plugin org.blueberry.osgi org.blueberry.core.runtime) + diff --git a/BlueBerry/Bundles/org.blueberry.core.expressions/src/berryElementHandler.h b/BlueBerry/Bundles/org.blueberry.core.expressions/src/berryElementHandler.h index e2412a9ea1..44f0b322c7 100644 --- a/BlueBerry/Bundles/org.blueberry.core.expressions/src/berryElementHandler.h +++ b/BlueBerry/Bundles/org.blueberry.core.expressions/src/berryElementHandler.h @@ -1,130 +1,130 @@ /*========================================================================= Program: BlueBerry Platform Language: C++ Date: $Date$ Version: $Revision$ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #ifndef BERRYELEMENTHANDLER_H_ #define BERRYELEMENTHANDLER_H_ #include #include #include #include "berryExpression.h" -#include "berryExpressionsDll.h" +#include #include "internal/berryCompositeExpression.h" namespace berry { class ExpressionConverter; /** * An element handler converts an {@link IConfigurationElement} into a * corresponding expression object. *

* The class should be subclassed by clients wishing to provide an element * handler for special expressions. *

* @since 3.0 */ class BERRY_EXPRESSIONS ElementHandler : public Object { public: berryObjectMacro(ElementHandler) virtual ~ElementHandler() {} /** * The default element handler which can cope with all XML expression elements * defined by the common expression language. * * @return the default element handler */ static ElementHandler::Pointer GetDefault(); /** * Creates the corresponding expression for the given configuration element. * * @param converter the expression converter used to initiate the * conversion process * * @param config the configuration element to convert * * @return the corresponding expression * * @throws CoreException if the conversion failed */ virtual Expression::Pointer Create(ExpressionConverter* converter, SmartPointer config) = 0; /** * Creates the corresponding expression for the given DOM element. This is * an optional operation that is only required if the handler supports conversion * of DOM elements. * * @param converter the expression converter used to initiate the * conversion process * * @param element the DOM element to convert * * @return the corresponding expression * * @throws CoreException if the conversion failed * * @since 3.3 */ virtual Expression::Pointer Create(ExpressionConverter* converter, Poco::XML::Element* element); protected: /** * Converts the children of the given configuration element and adds them * to the given composite expression. *

* Note this is an internal method and should not be called by clients. *

* @param converter the converter used to do the actual conversion * @param element the configuration element for which the children * are to be processed * @param expression the composite expression representing the result * of the conversion * * @throws CoreException if the conversion failed */ virtual void ProcessChildren(ExpressionConverter* converter, SmartPointer element, SmartPointer expression); /** * Converts the children of the given DOM element and adds them to the * given composite expression. *

* Note this is an internal method and should not be called by clients. *

* @param converter the converter used to do the actual conversion * @param element the DOM element for which the children are to be processed * @param expression the composite expression representing the result * of the conversion * * @throws CoreException if the conversion failed * * @since 3.3 */ virtual void ProcessChildren(ExpressionConverter* converter, Poco::XML::Element* element, SmartPointer expression); }; } // namespace berry #endif /*BERRYELEMENTHANDLER_H_*/ diff --git a/BlueBerry/Bundles/org.blueberry.core.expressions/src/berryEvaluationContext.h b/BlueBerry/Bundles/org.blueberry.core.expressions/src/berryEvaluationContext.h index 05e9bd2f34..3c6c697b4e 100644 --- a/BlueBerry/Bundles/org.blueberry.core.expressions/src/berryEvaluationContext.h +++ b/BlueBerry/Bundles/org.blueberry.core.expressions/src/berryEvaluationContext.h @@ -1,124 +1,124 @@ /*========================================================================= Program: BlueBerry Platform Language: C++ Date: $Date$ Version: $Revision$ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #ifndef BERRYEVALUATIONCONTEXT_H_ #define BERRYEVALUATIONCONTEXT_H_ #include "berryIEvaluationContext.h" #include "berryIVariableResolver.h" -#include "berryExpressionsDll.h" +#include #include "Poco/Any.h" #include #include namespace berry { /** * A default implementation of an evaluation context. *

* Clients may instantiate this default context. The class is * not intended to be subclassed by clients. *

* * @since 3.0 */ class BERRY_EXPRESSIONS EvaluationContext : public IEvaluationContext { private: IEvaluationContext* fParent; Object::Pointer fDefaultVariable; std::map fVariables; std::vector fVariableResolvers; bool fAllowPluginActivation; public: /** * Create a new evaluation context with the given parent and default * variable. * * @param parent the parent context. Can be null. * @param defaultVariable the default variable */ EvaluationContext(IEvaluationContext* parent, Object::Pointer defaultVariable); /** * Create a new evaluation context with the given parent and default * variable. * * @param parent the parent context. Can be null. * @param defaultVariable the default variable * @param resolvers an array of IVariableResolvers to * resolve additional variables. * * @see #resolveVariable(String, Object[]) */ EvaluationContext(IEvaluationContext* parent, Object::Pointer defaultVariable, std::vector resolvers); /** * {@inheritDoc} */ IEvaluationContext* GetParent() const; /** * {@inheritDoc} */ IEvaluationContext* GetRoot(); /** * {@inheritDoc} */ Object::Pointer GetDefaultVariable() const; /** * {@inheritDoc} */ void SetAllowPluginActivation(bool value); /** * {@inheritDoc} */ bool GetAllowPluginActivation() const; /** * {@inheritDoc} */ void AddVariable(const std::string& name, Object::Pointer value); /** * {@inheritDoc} */ Object::Pointer RemoveVariable(const std::string& name); /** * {@inheritDoc} */ Object::Pointer GetVariable(const std::string& name) const; /** * {@inheritDoc} */ Object::Pointer ResolveVariable(const std::string& name, std::vector& args); }; } // namespace berry #endif /*BERRYEVALUATIONCONTEXT_H_*/ diff --git a/BlueBerry/Bundles/org.blueberry.core.expressions/src/berryEvaluationResult.h b/BlueBerry/Bundles/org.blueberry.core.expressions/src/berryEvaluationResult.h index c682b11ba7..92589c11bd 100644 --- a/BlueBerry/Bundles/org.blueberry.core.expressions/src/berryEvaluationResult.h +++ b/BlueBerry/Bundles/org.blueberry.core.expressions/src/berryEvaluationResult.h @@ -1,229 +1,229 @@ /*========================================================================= Program: BlueBerry Platform Language: C++ Date: $Date$ Version: $Revision$ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #ifndef BERRYEVALUATIONRESULT_ #define BERRYEVALUATIONRESULT_ #include -#include "berryExpressionsDll.h" +#include namespace berry { /** * An evaluation result represents the result of an expression * evaluation. There are exact three instances of evaluation * result. They are: FALSE_EVAL, TRUE_EVAL and * NOT_LOADED. NOT_LOADED represents * the fact that an expression couldn't be evaluated since a * plug-in providing certain test expressions isn't loaded yet. *

* In addition the class implements the three operation and * , or and not. The operation are * defined as follows: *

*

* The and operation: *

* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
ANDFALSE_EVALTRUE_EVALNOT_LOADED
FALSE_EVALFALSE_EVALFALSE_EVALFALSE_EVAL
TRUE_EVALFALSE_EVALTRUE_EVALNOT_LOADED
NOT_LOADEDFALSE_EVALNOT_LOADEDNOT_LOADED
*

* The or operation: *

* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
ORFALSE_EVALTRUE_EVALNOT_LOADED
FALSE_EVALFALSE_EVALTRUE_EVALNOT_LOADED
TRUE_EVALTRUE_EVALTRUE_EVALTRUE_EVAL
NOT_LOADEDNOT_LOADEDTRUE_EVALNOT_LOADED
*

* The not operation: *

* * * * * * * * * * * * * * * * * * * * * *
NOTFALSE_EVALTRUE_EVALNOT_LOADED
TRUE_EVALFALSE_EVALNOT_LOADED
* *

* The class is not intended to be subclassed by clients. *

* @since 3.0 */ class BERRY_EXPRESSIONS EvaluationResult { private: int fValue; static const int FALSE_VALUE; static const int TRUE_VALUE; static const int NOT_LOADED_VALUE; public: /** The evaluation result representing the value FALSE */ static const EvaluationResult FALSE_EVAL; /** The evaluation result representing the value TRUE */ static const EvaluationResult TRUE_EVAL; /** The evaluation result representing the value NOT_LOADED */ static const EvaluationResult NOT_LOADED; private: static const EvaluationResult AND[3][3]; static const EvaluationResult OR[3][3]; static const EvaluationResult NOT[3]; /* * No instances outside of EvaluationResult */ EvaluationResult(int value); public: bool operator==(const EvaluationResult&); bool operator!=(const EvaluationResult&); /** * Returns an EvaluationResult whose value is this && other). * * @param other the right hand side of the and operation. * * @return this && other as defined by the evaluation result */ EvaluationResult And(EvaluationResult other); /** * Returns an EvaluationResult whose value is this || other). * * @param other the right hand side of the or operation. * * @return this || other as defined by the evaluation result */ EvaluationResult Or(EvaluationResult other); /** * Returns the inverted value of this evaluation result * * @return the inverted value of this evaluation result */ EvaluationResult Not(); /** * Returns an evaluation result instance representing the * given boolean value. If the given boolean value is * TRUE_EVAL then ExpressionResult.TRUE_EVAL * is returned. If the value is FALSE_EVAL then * ExpressionResult.FALSE_EVAL is returned. * * @param b a boolean value * * @return the expression result representing the boolean * value */ static EvaluationResult ValueOf(bool b); /** * For debugging purpose only * * @return a string representing this object. The result is not * human readable */ std::string ToString(); }; } // namespace berry #endif /*BERRYEVALUATIONRESULT_*/ diff --git a/BlueBerry/Bundles/org.blueberry.core.expressions/src/berryExpression.h b/BlueBerry/Bundles/org.blueberry.core.expressions/src/berryExpression.h index 42125ce7ff..cf4ab37b8c 100644 --- a/BlueBerry/Bundles/org.blueberry.core.expressions/src/berryExpression.h +++ b/BlueBerry/Bundles/org.blueberry.core.expressions/src/berryExpression.h @@ -1,241 +1,241 @@ /*========================================================================= Program: BlueBerry Platform Language: C++ Date: $Date$ Version: $Revision$ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #ifndef BERRYEXPRESSION_H_ #define BERRYEXPRESSION_H_ #include "berryExpressionInfo.h" #include "berryIEvaluationContext.h" #include "berryEvaluationResult.h" -#include "berryExpressionsDll.h" +#include #include #include #include namespace berry { /** * Abstract base class for all expressions provided by the common * expression language. *

* An expression is evaluated by calling {@link #evaluate(IEvaluationContext)}. *

*

* This class may be subclassed to provide specific expressions. *

* * @since 3.0 */ class BERRY_EXPRESSIONS Expression : public Object { public: berryObjectMacro(Expression) /** * The constant integer hash code value meaning the hash code has not yet * been computed. */ static const std::size_t HASH_CODE_NOT_COMPUTED; /** * A factor for computing the hash code for all expressions. */ static const std::size_t HASH_FACTOR; /** * Name of the value attribute of an expression (value is value). */ static const std::string ATT_VALUE; private: /** * The hash code for this object. This value is computed lazily. If it is * not yet computed, it is equal to {@link #HASH_CODE_NOT_COMPUTED}. */ mutable std::size_t fHashCode; protected: /** * Checks whether two objects are equal using the * equals(Object) method of the left object. * This method handles null for either the left * or right object. * * @param left the first object to compare; may be null. * @param right the second object to compare; may be null. * @return TRUE_EVAL if the two objects are equivalent; * FALSE_EVAL otherwise. * * @since 3.2 */ // static bool Equals(final Object left, final Object right); /** * Tests whether two arrays of objects are equal to each other. The arrays * must not be null, but their elements may be * null. * * @param leftArray the left array to compare; may be null, and * may be empty and may contain null elements. * @param rightArray the right array to compare; may be null, * and may be empty and may contain null elements. * * @return TRUE_EVAL if the arrays are equal length and the elements * at the same position are equal; FALSE_EVAL otherwise. * * @since 3.2 */ static bool Equals(std::vector& leftArray, std::vector& rightArray); static bool Equals(std::vector& leftArray, std::vector& rightArray); /** * Returns the hash code for the given object. This method * handles null. * * @param object the object for which the hash code is desired; may be * null. * * @return The hash code of the object; zero if the object is * null. * * @since 3.2 */ static std::size_t HashCode(Expression::Pointer object); /** * Returns the hash code for the given array. This method handles * null. * * @param array the array for which the hash code is desired; may be * null. * @return the hash code of the array; zero if the object is * null. * * @since 3.2 */ static std::size_t HashCode(std::vector& array); static std::size_t HashCode(std::vector& array); /** * Method to compute the hash code for this object. The result * returned from this method is cached in the fHashCode * field. If the value returned from the method equals {@link #HASH_CODE_NOT_COMPUTED} * (e.g. -1) then the value is incremented by one. *

* This default implementation calls super.hashCode() *

* @return a hash code for this object. * * @since 3.2 */ virtual std::size_t ComputeHashCode() const; public: /** * The expression corresponding to {@link EvaluationResult#TRUE_EVAL}. */ static const Expression::Pointer TRUE_EVAL; /** * The expression corresponding to {@link EvaluationResult#FALSE_EVAL}. */ static const Expression::Pointer FALSE_EVAL; Expression(); virtual ~Expression(); virtual std::size_t HashCode() const; /** * Evaluates this expression. * * @param context an evaluation context providing information like variable, * name spaces, etc. necessary to evaluate this expression * * @return the result of the expression evaluation * * @throws CoreException if the evaluation failed. The concrete reason is * defined by the subclass implementing this method */ virtual EvaluationResult Evaluate(IEvaluationContext* context) = 0; /** * Computes the expression information for the given expression tree. *

* This is a convenience method for collecting the expression information * using {@link Expression#collectExpressionInfo(ExpressionInfo)}. *

* * @return the expression information * * @since 3.2 */ virtual const ExpressionInfo* ComputeExpressionInfo() const; /** * Collects information about this expression tree. This default * implementation add the expression's type to the set of misbehaving * expression types. * * @param info the expression information object used * to collect the information * * @since 3.2 */ virtual void CollectExpressionInfo(ExpressionInfo* info) const; virtual std::string ToString(); virtual bool operator==(const Object* object) const; }; class TRUE_EVALExpression : public Expression { public: EvaluationResult Evaluate(IEvaluationContext* /*context*/) { return EvaluationResult::TRUE_EVAL; } void CollectExpressionInfo(ExpressionInfo* /*info*/) {} }; class FALSE_EVALExpression : public Expression { public: EvaluationResult Evaluate(IEvaluationContext* /*context*/) { return EvaluationResult::FALSE_EVAL; } void CollectExpressionInfo(ExpressionInfo* /*info*/) {} }; } // namespace berry #endif /*BERRYEXPRESSION_H_*/ diff --git a/BlueBerry/Bundles/org.blueberry.core.expressions/src/berryExpressionInfo.h b/BlueBerry/Bundles/org.blueberry.core.expressions/src/berryExpressionInfo.h index 7402e81c4d..c53e9d018a 100644 --- a/BlueBerry/Bundles/org.blueberry.core.expressions/src/berryExpressionInfo.h +++ b/BlueBerry/Bundles/org.blueberry.core.expressions/src/berryExpressionInfo.h @@ -1,190 +1,190 @@ /*========================================================================= Program: BlueBerry Platform Language: C++ Date: $Date$ Version: $Revision$ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #ifndef BERRYEXPRESSIONINFO_H_ #define BERRYEXPRESSIONINFO_H_ #include #include #include -#include "berryExpressionsDll.h" +#include namespace berry { /** * A status object describing information about an expression tree. * This information can for example be used to decide whether a * expression tree as to be reevaluated if the value of some * variables changes. *

* This class is not intended to be extended by clients. *

* * @since 3.2 */ class BERRY_EXPRESSIONS ExpressionInfo { private: bool fHasDefaultVariableAccess; bool fHasSystemPropertyAccess; // Although we are using this as sets we use lists since // they are faster for smaller numbers of elements std::set fAccessedVariableNames; std::set fMisbehavingExpressionTypes; std::set fAccessedPropertyNames; public: /** * Returns true if the default variable is accessed * by the expression tree. * * @return whether the default variable is accessed or not */ bool HasDefaultVariableAccess() const; /** * Marks the default variable as accessed. */ void MarkDefaultVariableAccessed(); /** * Returns true if the system property is accessed * by the expression tree. * * @return whether the system property is accessed or not */ bool HasSystemPropertyAccess() const; /** * Marks the system property as accessed. */ void MarkSystemPropertyAccessed(); /** * Returns the set off accessed variables. * * @return the set off accessed variables */ std::set GetAccessedVariableNames() const; /** * Marks the given variable as accessed. * * @param name the accessed variable */ void AddVariableNameAccess(const std::string& name); /** * Returns the set of accessed properties. * * @return the set of accessed properties, or an empty array * @since 3.4 */ std::set GetAccessedPropertyNames() const; /** * Marks that this expression access this property. It should be the fully * qualified property name. * * @param name * the fully qualified property name * @since 3.4 */ void AddAccessedPropertyName(const std::string& name); /** * Returns the set of expression types which don't implement the * new (@link Expression#computeReevaluationInfo(IEvaluationContext)} * method. If one expression didn't implement the method the expression * tree no optimizations can be done. Returns null if * all expressions implement the method. * * @return the set of expression types which don't implement the * computeReevaluationInfo method. */ std::set GetMisbehavingExpressionTypes() const; /** * Adds the given class to the list of misbehaving classes. * * @param clazz the class to add. */ void AddMisBehavingExpressionType(const std::type_info& clazz); /** * Merges this reevaluation information with the given info. * * @param other the information to merge with */ void Merge(ExpressionInfo* other); /** * Merges this reevaluation information with the given info * ignoring the default variable access. * * @param other the information to merge with */ void MergeExceptDefaultVariable(ExpressionInfo* other); private: /** * Merges only the default variable access. * * @param other the information to merge with */ void MergeDefaultVariableAccess(ExpressionInfo* other); /** * Merges only the system property access. * * @param other the information to merge with */ void MergeSystemPropertyAccess(ExpressionInfo* other); /** * Merges only the accessed variable names. * * @param other the information to merge with */ void MergeAccessedVariableNames(ExpressionInfo* other); /** * Merges only the accessed property names. * * @param other the information to merge with * @since 3.4 */ void MergeAccessedPropertyNames(ExpressionInfo* other); /** * Merges only the misbehaving expression types. * * @param other the information to merge with */ void MergeMisbehavingExpressionTypes(ExpressionInfo* other); }; } // namespace berry #endif /*BERRYEXPRESSIONINFO_H_*/ diff --git a/BlueBerry/Bundles/org.blueberry.core.expressions/src/berryExpressionTagNames.h b/BlueBerry/Bundles/org.blueberry.core.expressions/src/berryExpressionTagNames.h index 42f704eaa6..ef044d93db 100644 --- a/BlueBerry/Bundles/org.blueberry.core.expressions/src/berryExpressionTagNames.h +++ b/BlueBerry/Bundles/org.blueberry.core.expressions/src/berryExpressionTagNames.h @@ -1,86 +1,86 @@ /*========================================================================= Program: BlueBerry Platform Language: C++ Date: $Date$ Version: $Revision$ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #ifndef BERRYEXPRESSIONTAGNAMES_H_ #define BERRYEXPRESSIONTAGNAMES_H_ #include -#include "berryExpressionsDll.h" +#include namespace berry { /** * Class defining the tag names of the XML elements of the common * expression language. * * @since 3.0 */ class BERRY_EXPRESSIONS ExpressionTagNames { public: /** The tag name of the enablement expression (value: enablement) */ static const std::string ENABLEMENT; /** The tag name of the and expression (value: and) */ static const std::string AND; /** The tag name of the or expression (value: or) */ static const std::string OR; /** The tag name of the not expression (value: not) */ static const std::string NOT; /** The tag name of the instanceof expression (value: instanceof) */ static const std::string INSTANCEOF; /** The tag name of the test expression (value: test) */ static const std::string TEST; /** The tag name of the with expression (value: with) */ static const std::string WITH; /** The tag name of the adapt expression (value: adapt) */ static const std::string ADAPT; /** The tag name of the count expression (value: count) */ static const std::string COUNT; /** The tag name of the adapt expression (value: iterate) */ static const std::string ITERATE; /** The tag name of the resolve expression (value: resolve) */ static const std::string RESOLVE; /** The tag name of the systemTest expression (value: systemTest) */ static const std::string SYSTEM_TEST; /** The tag name of the equals expression (value: equals) */ static const std::string EQUALS; /** * The tag name of the reference expression (value: reference) * * @since 3.3 */ static const std::string REFERENCE; }; } // namespace berry #endif /*BERRYEXPRESSIONTAGNAMES_H_*/ diff --git a/BlueBerry/Bundles/org.blueberry.core.expressions/src/berryExpressionsDll.h b/BlueBerry/Bundles/org.blueberry.core.expressions/src/berryExpressionsDll.h deleted file mode 100644 index 9989fc49c2..0000000000 --- a/BlueBerry/Bundles/org.blueberry.core.expressions/src/berryExpressionsDll.h +++ /dev/null @@ -1,43 +0,0 @@ -/*========================================================================= - -Program: BlueBerry Platform -Language: C++ -Date: $Date$ -Version: $Revision$ - -Copyright (c) German Cancer Research Center, Division of Medical and -Biological Informatics. All rights reserved. -See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. - -This software is distributed WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. See the above copyright notices for more information. - -=========================================================================*/ - -#ifndef BERRYEXPRESSIONSDLL_H_ -#define BERRYEXPRESSIONSDLL_H_ - - -// -// The following block is the standard way of creating macros which make exporting -// from a DLL simpler. All files within this DLL are compiled with the MITK_EXPORTS -// symbol defined on the command line. this symbol should not be defined on any project -// that uses this DLL. This way any other project whose source files include this file see -// MITK_API functions as being imported from a DLL, wheras this DLL sees symbols -// defined with this macro as being exported. -// -#if defined(_WIN32) && !defined(BERRY_STATIC) - #if defined(org_blueberry_core_expressions_EXPORTS) - #define BERRY_EXPRESSIONS __declspec(dllexport) - #else - #define BERRY_EXPRESSIONS __declspec(dllimport) - #endif -#endif - - -#if !defined(BERRY_EXPRESSIONS) - #define BERRY_EXPRESSIONS -#endif - -#endif /*BERRYEXPRESSIONSDLL_H_*/ diff --git a/BlueBerry/Bundles/org.blueberry.core.expressions/src/berryICountable.h b/BlueBerry/Bundles/org.blueberry.core.expressions/src/berryICountable.h index 83c75c06c2..ab84b50f19 100644 --- a/BlueBerry/Bundles/org.blueberry.core.expressions/src/berryICountable.h +++ b/BlueBerry/Bundles/org.blueberry.core.expressions/src/berryICountable.h @@ -1,54 +1,54 @@ /*========================================================================= Program: BlueBerry Platform Language: C++ Date: $Date$ Version: $Revision$ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #ifndef BERRYICOUNTABLE_H_ #define BERRYICOUNTABLE_H_ #include #include -#include "berryExpressionsDll.h" +#include namespace berry { /** * Objects that are adaptable to ICountable can be used * as the default variable in a count expression. * * @see IAdaptable * @see IAdapterManager * * @since 3.3 */ struct BERRY_EXPRESSIONS ICountable : public Object { berryObjectMacro(ICountable) /** * Returns the number of elements. * * @return the number of elements */ virtual int Count() = 0; virtual ~ICountable() {} }; } #endif /*BERRYICOUNTABLE_H_*/ diff --git a/BlueBerry/Bundles/org.blueberry.core.expressions/src/berryIEvaluationContext.h b/BlueBerry/Bundles/org.blueberry.core.expressions/src/berryIEvaluationContext.h index 4b4f60c64e..694365b4dd 100644 --- a/BlueBerry/Bundles/org.blueberry.core.expressions/src/berryIEvaluationContext.h +++ b/BlueBerry/Bundles/org.blueberry.core.expressions/src/berryIEvaluationContext.h @@ -1,145 +1,145 @@ /*========================================================================= Program: BlueBerry Platform Language: C++ Date: $Date$ Version: $Revision$ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #ifndef BERRYIEVALUATIONCONTEXT_H_ #define BERRYIEVALUATIONCONTEXT_H_ #include #include #include #include -#include "berryExpressionsDll.h" +#include namespace berry { /** * An evaluation context is used to manage a set of objects needed during * XML expression evaluation. A context has a parent context, can manage * a set of named variables and has a default variable. The default variable * is used during XML expression evaluation if no explicit variable is * referenced. *

* This interface is not intended to be implemented by clients. Clients * are allowed to instantiate EvaluationContext. *

* * @since 3.0 */ struct BERRY_EXPRESSIONS IEvaluationContext : public Object { berryInterfaceMacro(IEvaluationContext, berry); virtual ~IEvaluationContext() {} /** * Returns the parent context or null if * this is the root of the evaluation context hierarchy. * * @return the parent evaluation context or null */ virtual IEvaluationContext* GetParent() const = 0; /** * Returns the root evaluation context. * * @return the root evaluation context */ virtual IEvaluationContext* GetRoot() = 0; /** * Specifies whether this evaluation context allows activation * of plug-ins for testers used in the expression tree. To actual * trigger the plug-in loading this flag has to be set to * true and the actual test expression must have the * attribute forcePluginActivation set to * true as well. * * @param value whether this evaluation context allows plug-in activation * @since 3.2 */ virtual void SetAllowPluginActivation(bool value) = 0; /** * Returns whether this evaluation context supports plug-in * activation. If not set via {@link #setAllowPluginActivation(boolean)} * the parent value is returned. If no parent is set false * is returned. * * @return whether plug-in activation is supported or not * @since 3.2 */ virtual bool GetAllowPluginActivation() const = 0; /** * Returns the default variable. * * @return the default variable or null if * no default variable is managed. */ virtual Object::Pointer GetDefaultVariable() const = 0; /** * Adds a new named variable to this context. If a variable * with the name already exists the new one overrides the * existing one. * * @param name the variable's name * @param value the variable's value */ virtual void AddVariable(const std::string& name, Object::Pointer value) = 0; /** * Removes the variable managed under the given name * from this evaluation context. * * @param name the variable's name * @return the currently stored value or null if * the variable doesn't exist */ virtual Object::Pointer RemoveVariable(const std::string& name) = 0; /** * Returns the variable managed under the given name. * * @param name the variable's name * @return the variable's value or null if the content * doesn't manage a variable with the given name */ virtual Object::Pointer GetVariable(const std::string& name) const = 0; /** * Resolves a variable for the given name and arguments. This * method can be used to dynamically resolve variable such as * plug-in descriptors, resources, etc. The method is used * by the resolve expression. * * @param name the variable to resolve * @param args an object array of arguments used to resolve the * variable * @return the variable's value or null if no variable * can be resolved for the given name and arguments * @exception CoreException if an errors occurs while resolving * the variable */ virtual Object::Pointer ResolveVariable(const std::string& name, std::vector& args) = 0; }; } // namespace berry #endif /*BERRYIEVALUATIONCONTEXT_H_*/ diff --git a/BlueBerry/Bundles/org.blueberry.core.expressions/src/berryIIterable.h b/BlueBerry/Bundles/org.blueberry.core.expressions/src/berryIIterable.h index a69ba859d9..77e6034dd5 100644 --- a/BlueBerry/Bundles/org.blueberry.core.expressions/src/berryIIterable.h +++ b/BlueBerry/Bundles/org.blueberry.core.expressions/src/berryIIterable.h @@ -1,59 +1,59 @@ /*========================================================================= Program: BlueBerry Platform Language: C++ Date: $Date$ Version: $Revision$ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #ifndef BERRYIITERABLE_H_ #define BERRYIITERABLE_H_ #include #include -#include "berryExpressionsDll.h" +#include #include namespace berry { /** * Objects that are adaptable to IIterable can be used * as the default variable in an iterate expression. * * @see IAdaptable * @see IAdapterManager * * @since 3.3 */ struct BERRY_EXPRESSIONS IIterable : public Object { berryObjectMacro(IIterable) typedef std::vector::iterator iterator; virtual ~IIterable() {} /** * Returns an iterator to iterate over the elements. * * @return an iterator */ virtual iterator begin() = 0; virtual iterator end() = 0; }; } // namespace berry #endif /*BERRYIITERABLE_H_*/ diff --git a/BlueBerry/Bundles/org.blueberry.core.expressions/src/berryIPropertyTester.h b/BlueBerry/Bundles/org.blueberry.core.expressions/src/berryIPropertyTester.h index 795cb57ed5..d658ff5a06 100644 --- a/BlueBerry/Bundles/org.blueberry.core.expressions/src/berryIPropertyTester.h +++ b/BlueBerry/Bundles/org.blueberry.core.expressions/src/berryIPropertyTester.h @@ -1,109 +1,113 @@ /*========================================================================= Program: BlueBerry Platform Language: C++ Date: $Date$ Version: $Revision$ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #ifndef BERRYIPROPERTYTESTER_H_ #define BERRYIPROPERTYTESTER_H_ #include #include -#include "berryExpressionsDll.h" +#include #include #include #include +#include + namespace berry { /** * A property tester can be used to add additional properties to test to an * existing type. *

* This interface is not intended to be implemented by clients. Clients * should subclass type PropertyTester. *

* * @since 3.0 */ struct BERRY_EXPRESSIONS IPropertyTester : public Object { berryInterfaceMacro(IPropertyTester, berry) virtual ~IPropertyTester() {} /** * Returns whether the property tester can handle the given * property or not. * * @param namespace the name space to be considered * @param property the property to test * @return true if the tester provides an implementation * for the given property; otherwise false is returned */ virtual bool Handles(const std::string& namespaze, const std::string& property) = 0; /** * Returns whether the implementation class for this property tester is * loaded or not. * * @return trueif the implementation class is loaded; * false otherwise */ virtual bool IsInstantiated() = 0; /** * Returns true if the implementation class of this property * tester can be loaded. This is the case if the plug-in providing * the implementation class is active. Returns false otherwise. * * @return whether the implementation class can be loaded or not */ virtual bool IsDeclaringPluginActive() = 0; /** * Loads the implementation class for this property tester and returns an * instance of this class. * * @return an instance of the implementation class for this property tester * * @throws CoreException if the implementation class cannot be loaded */ virtual IPropertyTester* Instantiate() = 0; /** * Executes the property test determined by the parameter property. * * @param receiver the receiver of the property test * @param property the property to test * @param args additional arguments to evaluate the property. If no arguments * are specified in the test expression an array of length 0 * is passed * @param expectedValue the expected value of the property. The value is either * of type java.lang.String or a boxed base type. If no value was * specified in the test expressions then null is passed * * @return returns true if the property is equal to the expected value; * otherwise false is returned */ virtual bool Test(Object::Pointer receiver, const std::string& property, std::vector& args, Object::Pointer expectedValue) = 0; }; } // namespace berry +Q_DECLARE_INTERFACE(berry::IPropertyTester, "org.blueberry.IPropertyTester") + #endif /*BERRYIPROPERTYTESTER_H_*/ diff --git a/BlueBerry/Bundles/org.blueberry.core.expressions/src/berryIVariableResolver.h b/BlueBerry/Bundles/org.blueberry.core.expressions/src/berryIVariableResolver.h index 0962ae1065..83c62f8767 100644 --- a/BlueBerry/Bundles/org.blueberry.core.expressions/src/berryIVariableResolver.h +++ b/BlueBerry/Bundles/org.blueberry.core.expressions/src/berryIVariableResolver.h @@ -1,55 +1,55 @@ /*========================================================================= Program: BlueBerry Platform Language: C++ Date: $Date$ Version: $Revision$ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #ifndef BERRYIVARIABLERESOLVER_H_ #define BERRYIVARIABLERESOLVER_H_ -#include "berryExpressionsDll.h" +#include namespace berry { /** * A variable resolver can be used to add additional variable resolving * strategies to an {@link EvaluationContext}. * * @see org.blueberry.core.expressions.EvaluationContext#resolveVariable(String, Object[]) * * @since 3.0 */ struct BERRY_EXPRESSIONS IVariableResolver { virtual ~IVariableResolver() {}; /** * Resolves a variable for the given name and arguments. The * handler is allowed to return null to indicate * that it is not able to resolve the requested variable. * * @param name the variable to resolve * @param args an object array of arguments used to resolve the * variable * @return the variable's value or null if no variable * could be resolved * @exception CoreException if an errors occurs while resolving * the variable */ virtual Object::Pointer Resolve(const std::string& name, std::vector args) = 0; }; } // namespace berry #endif /*BERRYIVARIABLERESOLVER_H_*/ diff --git a/BlueBerry/Bundles/org.blueberry.core.expressions/src/berryPropertyTester.h b/BlueBerry/Bundles/org.blueberry.core.expressions/src/berryPropertyTester.h index b708e81709..e0707d13e1 100644 --- a/BlueBerry/Bundles/org.blueberry.core.expressions/src/berryPropertyTester.h +++ b/BlueBerry/Bundles/org.blueberry.core.expressions/src/berryPropertyTester.h @@ -1,126 +1,126 @@ /*========================================================================= Program: BlueBerry Platform Language: C++ Date: $Date$ Version: $Revision$ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #ifndef BERRYPROPERTYTESTER_H_ #define BERRYPROPERTYTESTER_H_ #include #include "internal/berryPropertyTesterDescriptor.h" -#include "berryExpressionsDll.h" +#include #include namespace berry { /** * Abstract superclass of all property testers. Implementation classes of * the extension point org.blueberry.core.expresssions.propertyTesters * must extend PropertyTester. *

* A property tester implements the property tests enumerated in the property * tester extension point. For the following property test extension *

  *   <propertyTester
  *       namespace="org.blueberry.jdt.core"
  *       id="org.blueberry.jdt.core.IPackageFragmentTester"
  *       properties="isDefaultPackage"
  *       type="org.blueberry.jdt.core.IPackageFragment"
  *       class="org.blueberry.demo.MyPackageFragmentTester">
  *     </propertyTester>
  * 
* the corresponding implementation class looks like: *
  *   public class MyPackageFragmentTester {
  *       public boolean test(Object receiver, String property, Object[] args, Object expectedValue) {
  *           IPackageFragment fragement= (IPackageFragment)receiver;
  *           if ("isDefaultPackage".equals(property)) {
  *               return expectedValue == null
  *                ? fragement.isDefaultPackage()
  *                : fragement.isDefaultPackage() == ((Boolean)expectedValue).booleanValue();
  *           }
  *           Assert.isTrue(false);
  *           return false;
  *       }
  *   }
  * 
* The property can then be used in a test expression as follows: *
  *   <instanceof value="org.blueberry.core.IPackageFragment"/>
  *   <test property="org.blueberry.jdt.core.isDefaultPackage"/>
  * 
*

*

* There is no guarantee that the same instance of a property tester is used * to handle <test property="..."/> requests. So property testers * should always be implemented in a stateless fashion. *

* @since 3.0 */ class BERRY_EXPRESSIONS PropertyTester : public IPropertyTester { private: IConfigurationElement::Pointer fConfigElement; std::string fNamespace; std::string fProperties; public: /** * Initialize the property tester with the given name space and property. *

* Note: this method is for internal use only. Clients must not call * this method. *

* @param descriptor the descriptor object for this tester */ void InternalInitialize(PropertyTesterDescriptor::Pointer descriptor); /** * Note: this method is for internal use only. Clients must not call * this method. * * @return the property tester descriptor */ PropertyTesterDescriptor::Pointer InternalCreateDescriptor(); /** * {@inheritDoc} */ bool Handles(const std::string& namespaze, const std::string& property); /** * {@inheritDoc} */ bool IsInstantiated(); /** * {@inheritDoc} */ bool IsDeclaringPluginActive(); /** * {@inheritDoc} */ IPropertyTester* Instantiate(); }; } // namespace berry #endif /*BERRYPROPERTYTESTER_H_*/ diff --git a/BlueBerry/Bundles/org.blueberry.core.expressions/src/internal/berryExpressions.cpp b/BlueBerry/Bundles/org.blueberry.core.expressions/src/internal/berryExpressions.cpp index 9f349bffc2..52283b238e 100644 --- a/BlueBerry/Bundles/org.blueberry.core.expressions/src/internal/berryExpressions.cpp +++ b/BlueBerry/Bundles/org.blueberry.core.expressions/src/internal/berryExpressions.cpp @@ -1,319 +1,319 @@ /*========================================================================= Program: BlueBerry Platform Language: C++ Date: $Date$ Version: $Revision$ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #include "berryExpressions.h" -#include "berryPlatform.h" -#include "berryPlatformException.h" -#include "service/berryServiceRegistry.h" +#include +#include +#include -#include "berryIAdapterManager.h" +#include #include #include #include -#include "Poco/String.h" -#include "Poco/NumberParser.h" +#include +#include #include namespace berry { const bool Expressions::TRACING = true; Expressions::Expressions() { // no instance } bool Expressions::IsInstanceOf(Object::ConstPointer element, const std::string& type) { // null isn't an instanceof of anything. if (element.IsNull()) return false; // TODO Reflection // return IsSubtype(element, type) return element->GetClassName() == type; } void Expressions::CheckAttribute(const std::string& name, bool value) { if (!value) { throw CoreException("Missing attribute", name); } } void Expressions::CheckAttribute(const std::string& name, bool result, const std::string& value, std::vector& validValues) { CheckAttribute(name, result); for (unsigned int i= 0; i < validValues.size(); i++) { if (value == validValues[i]) return; } throw CoreException("Wrong attribute value", value); } void Expressions::CheckCollection(Object::ConstPointer var, Expression::Pointer expression) { if (var.Cast >()) return; throw CoreException("Expression variable is not of type ObjectVector", expression->ToString()); } IIterable::Pointer Expressions::GetAsIIterable(Object::Pointer var, Expression::Pointer expression) { IIterable::Pointer iterable(var.Cast()); if (!iterable.IsNull()) { return iterable; } else { IAdapterManager::Pointer manager= Platform::GetServiceRegistry().GetServiceById("org.blueberry.service.adaptermanager"); Object::Pointer result; Poco::Any any(manager->GetAdapter(var, IIterable::GetStaticClassName())); if (!any.empty() && any.type() == typeid(Object::Pointer)) { result = Poco::AnyCast(any); } if (result) { iterable = result.Cast(); return iterable; } if (manager->QueryAdapter(var->GetClassName(), IIterable::GetStaticClassName()) == IAdapterManager::NOT_LOADED) return IIterable::Pointer(); throw CoreException("The variable is not iterable", expression->ToString()); } } ICountable::Pointer Expressions::GetAsICountable(Object::Pointer var, Expression::Pointer expression) { ICountable::Pointer countable(var.Cast()); if (!countable.IsNull()) { return countable; } else { IAdapterManager::Pointer manager = Platform::GetServiceRegistry().GetServiceById("org.blueberry.service.adaptermanager"); Object::Pointer result; Poco::Any any(manager->GetAdapter(var, ICountable::GetStaticClassName())); if (!any.empty() && any.type() == typeid(Object::Pointer)) { result = Poco::AnyCast(any); } if (result) { countable = result.Cast(); } if (manager->QueryAdapter(var->GetClassName(), ICountable::GetStaticClassName()) == IAdapterManager::NOT_LOADED) return ICountable::Pointer(); throw CoreException("The variable is not countable", expression->ToString()); } } bool Expressions::GetOptionalBooleanAttribute(IConfigurationElement::Pointer element, const std::string& attributeName) { std::string value; if (element->GetAttribute(attributeName, value)) return Poco::toLower(value) == "true"; return false; } bool Expressions::GetOptionalBooleanAttribute(Poco::XML::Element* element, const std::string& attributeName) { std::string value = element->getAttribute(attributeName); if (value.size() == 0) return false; return Poco::toLower(value) == "true"; } void Expressions::GetArguments(std::vector& args, IConfigurationElement::Pointer element, const std::string& attributeName) { std::string value; if (element->GetAttribute(attributeName, value)) { ParseArguments(args, value); } } void Expressions::GetArguments(std::vector& args, Poco::XML::Element* element, const std::string& attributeName) { std::string value = element->getAttribute(attributeName); if (value.size()> 0) { ParseArguments(args, value); } } void Expressions::ParseArguments(std::vector& result, const std::string& args) { int start= 0; int comma; while ((comma = FindNextComma(args, start)) != -1) { result.push_back(ConvertArgument(Poco::trim(args.substr(start, comma-start)))); start= comma + 1; } result.push_back(ConvertArgument(Poco::trim(args.substr(start)))); } int Expressions::FindNextComma(const std::string& str, int start) { bool inString = false; for (unsigned int i = start; i < str.size(); i++) { char ch = str.at(i); if (ch == ',' && ! inString) return i; if (ch == '\'') { if (!inString) { inString= true; } else { if (i + 1 < str.size() && str.at(i + 1) == '\'') { i++; } else { inString= false; } } } else if (ch == ',' && !inString) { return i; } } if (inString) throw CoreException("String not terminated", str); return -1; } Object::Pointer Expressions::ConvertArgument(const std::string& arg, bool result) { if (!result) { return Object::Pointer(); } else if (arg.length() == 0) { ObjectString::Pointer var(new ObjectString(arg)); return var; } else if (arg.at(0) == '\'' && arg.at(arg.size() - 1) == '\'') { ObjectString::Pointer var(new ObjectString(UnEscapeString(arg.substr(1, arg.size() - 2)))); return var; } else if ("true" == arg) { ObjectBool::Pointer var(new ObjectBool(true)); return var; } else if ("false" == arg) { ObjectBool::Pointer var(new ObjectBool(false)); return var; } else if (arg.find('.') != std::string::npos) { try { double num = Poco::NumberParser::parseFloat(arg); ObjectFloat::Pointer var(new ObjectFloat((float) num)); return var; } catch (Poco::SyntaxException) { ObjectString::Pointer var(new ObjectString(arg)); return var; } } else { try { int num = Poco::NumberParser::parse(arg); ObjectInt::Pointer var(new ObjectInt(num)); return var; } catch (Poco::SyntaxException e) { ObjectString::Pointer var(new ObjectString(arg)); return var; } } } std::string Expressions::UnEscapeString(const std::string& str) { std::string result = ""; for (unsigned int i= 0; i < str.size(); i++) { char ch= str.at(i); if (ch == '\'') { if (i == str.size() - 1 || str.at(i + 1) != '\'') throw CoreException("String not correctly escaped", str); result.append(1, '\''); i++; } else { result.append(1, ch); } } return result; } } // namespace berry diff --git a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryQtDnDTweaklet.h b/BlueBerry/Bundles/org.blueberry.core.expressions/src/internal/berryPluginActivator.cpp old mode 100755 new mode 100644 similarity index 59% copy from BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryQtDnDTweaklet.h copy to BlueBerry/Bundles/org.blueberry.core.expressions/src/internal/berryPluginActivator.cpp index d4ba28a835..f475c9c798 --- a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryQtDnDTweaklet.h +++ b/BlueBerry/Bundles/org.blueberry.core.expressions/src/internal/berryPluginActivator.cpp @@ -1,35 +1,41 @@ /*========================================================================= Program: BlueBerry Platform Language: C++ Date: $Date$ Version: $Revision$ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ -#ifndef BERRYQTDNDTWEAKLET_H_ -#define BERRYQTDNDTWEAKLET_H_ +#include "berryPluginActivator.h" -#include +#include namespace berry { -class QtDnDTweaklet : public DnDTweaklet +org_blueberry_core_expressions_Activator::org_blueberry_core_expressions_Activator() { -public: +} + +void org_blueberry_core_expressions_Activator::start(ctkPluginContext* context) +{ + Q_UNUSED(context) +} - ITracker* CreateTracker(); -}; +void org_blueberry_core_expressions_Activator::stop(ctkPluginContext* context) +{ + Q_UNUSED(context) +} } -#endif /* BERRYQTDNDTWEAKLET_H_ */ +Q_EXPORT_PLUGIN2(org_blueberry_core_expressions, berry::org_blueberry_core_expressions_Activator) diff --git a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryQtIconImageDescriptor.h b/BlueBerry/Bundles/org.blueberry.core.expressions/src/internal/berryPluginActivator.h old mode 100755 new mode 100644 similarity index 59% copy from BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryQtIconImageDescriptor.h copy to BlueBerry/Bundles/org.blueberry.core.expressions/src/internal/berryPluginActivator.h index 9afe1a7db5..746f594a5c --- a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryQtIconImageDescriptor.h +++ b/BlueBerry/Bundles/org.blueberry.core.expressions/src/internal/berryPluginActivator.h @@ -1,49 +1,43 @@ /*========================================================================= Program: BlueBerry Platform Language: C++ Date: $Date$ Version: $Revision$ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ -#ifndef BERRYQTICONIMAGEDESCRIPTOR_H_ -#define BERRYQTICONIMAGEDESCRIPTOR_H_ +#ifndef BERRYPLUGINACTIVATOR_H +#define BERRYPLUGINACTIVATOR_H -#include - -class QIcon; +#include namespace berry { -class QtIconImageDescriptor : public ImageDescriptor +class org_blueberry_core_expressions_Activator : + public QObject, public ctkPluginActivator { - -private: - - QIcon* icon; + Q_OBJECT + Q_INTERFACES(ctkPluginActivator) public: + org_blueberry_core_expressions_Activator(); - QtIconImageDescriptor(void* img); - - virtual void* CreateImage(bool returnMissingImageOnError = true); - - virtual void DestroyImage(void* img); - - virtual bool operator==(const Object* o) const; - + void start(ctkPluginContext* context); + void stop(ctkPluginContext* context); }; +typedef org_blueberry_core_expressions_Activator PluginActivator; + } -#endif /* BERRYQTICONIMAGEDESCRIPTOR_H_ */ +#endif // BERRYPLUGINACTIVATOR_H diff --git a/BlueBerry/Bundles/org.blueberry.core.expressions/src/internal/berryPropertyTesterDescriptor.cpp b/BlueBerry/Bundles/org.blueberry.core.expressions/src/internal/berryPropertyTesterDescriptor.cpp index b6dc377ad0..4775988ee3 100644 --- a/BlueBerry/Bundles/org.blueberry.core.expressions/src/internal/berryPropertyTesterDescriptor.cpp +++ b/BlueBerry/Bundles/org.blueberry.core.expressions/src/internal/berryPropertyTesterDescriptor.cpp @@ -1,116 +1,122 @@ /*========================================================================= Program: BlueBerry Platform Language: C++ Date: $Date$ Version: $Revision$ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #include "berryPropertyTesterDescriptor.h" #include "berryPlatform.h" #include "berryPlatformException.h" #include "Poco/String.h" namespace berry { const std::string PropertyTesterDescriptor::PROPERTIES= "properties"; //$NON-NLS-1$ const std::string PropertyTesterDescriptor::NAMESPACE= "namespace"; //$NON-NLS-1$ const std::string PropertyTesterDescriptor::CLASS= "class"; //$NON-NLS-1$ PropertyTesterDescriptor::PropertyTesterDescriptor(IConfigurationElement::Pointer element) : fConfigElement(element) { fNamespace = ""; fConfigElement->GetAttribute(NAMESPACE, fNamespace); if (fNamespace.size() == 0) { throw new CoreException("No namespace"); } std::string buffer(","); std::string properties = ""; fConfigElement->GetAttribute(PROPERTIES, properties); if (properties.size() == 0) { throw new CoreException("No properties"); } Poco::translateInPlace(buffer, "\r\n\t ", ""); // std::string::iterator iter; // for (iter = properties.begin(); iter != properties.end(); ++iter) // { // char ch= properties.charAt(i); // if (!Character.isWhitespace(ch)) // buffer.append(ch); // } // buffer.append(','); fProperties = buffer; } PropertyTesterDescriptor::PropertyTesterDescriptor(IConfigurationElement::Pointer element, const std::string& namespaze, const std::string& properties) : fConfigElement(element), fNamespace(namespaze), fProperties(properties) { } const std::string& PropertyTesterDescriptor::GetProperties() { return fProperties; } const std::string& PropertyTesterDescriptor::GetNamespace() { return fNamespace; } IConfigurationElement::Pointer PropertyTesterDescriptor::GetExtensionElement() { return fConfigElement; } bool PropertyTesterDescriptor::Handles(const std::string& namespaze, const std::string& property) { return fNamespace == namespaze && fProperties.find("," + property + ",") != std::string::npos; } bool PropertyTesterDescriptor::IsInstantiated() { return false; } bool PropertyTesterDescriptor::IsDeclaringPluginActive() { IBundle::Pointer fBundle= Platform::GetBundle(fConfigElement->GetContributor()); return fBundle->IsActive(); } IPropertyTester* PropertyTesterDescriptor::Instantiate() { - return fConfigElement->CreateExecutableExtension(CLASS); + IPropertyTester* tester = fConfigElement->CreateExecutableExtension(CLASS); + if (tester == 0) + { + // support legacy BlueBerry extension + tester = fConfigElement->CreateExecutableExtension(CLASS, IPropertyTester::GetManifestName()); + } + return tester; } bool PropertyTesterDescriptor::Test(Object::Pointer /*receiver*/, const std::string& /*method*/, std::vector& /*args*/, Object::Pointer /*expectedValue*/) { poco_bugcheck_msg("Method should never be called"); return false; } } diff --git a/BlueBerry/Bundles/org.blueberry.core.jobs/CMakeLists.txt b/BlueBerry/Bundles/org.blueberry.core.jobs/CMakeLists.txt index 24ac6f0662..4f5be244be 100644 --- a/BlueBerry/Bundles/org.blueberry.core.jobs/CMakeLists.txt +++ b/BlueBerry/Bundles/org.blueberry.core.jobs/CMakeLists.txt @@ -1 +1,5 @@ -MACRO_CREATE_PLUGIN() +PROJECT(org_blueberry_core_jobs) + +MACRO_CREATE_CTK_PLUGIN(EXPORT_DIRECTIVE BERRY_JOBS + EXPORTED_INCLUDE_SUFFIXES src) + diff --git a/BlueBerry/Bundles/org.blueberry.core.jobs/META-INF/MANIFEST.MF b/BlueBerry/Bundles/org.blueberry.core.jobs/META-INF/MANIFEST.MF deleted file mode 100644 index e28bb98e80..0000000000 --- a/BlueBerry/Bundles/org.blueberry.core.jobs/META-INF/MANIFEST.MF +++ /dev/null @@ -1,7 +0,0 @@ -Manifest-Version: 1.0 -Bundle-Name: BlueBerry Jobs Mechanism -Bundle-SymbolicName: org.blueberry.core.jobs -Bundle-Version: 0.1 -Bundle-Vendor: DKFZ, Medical and Biological Informatics -Require-Bundle: org.blueberry.osgi, org.blueberry.solstice.common -Bundle-Activator: \ No newline at end of file diff --git a/BlueBerry/Bundles/org.blueberry.core.jobs/files.cmake b/BlueBerry/Bundles/org.blueberry.core.jobs/files.cmake index 8c97f8670e..2f18be947d 100644 --- a/BlueBerry/Bundles/org.blueberry.core.jobs/files.cmake +++ b/BlueBerry/Bundles/org.blueberry.core.jobs/files.cmake @@ -1,40 +1,45 @@ +SET(MOC_H_FILES + src/internal/berryPluginActivator.h +) + SET(SRC_CPP_FILES berryIJobChangeListener.cpp berryIJobManager.cpp berryJob.cpp berryJobExceptions.cpp berryJobStatus.cpp berryMultiRule.cpp berryNullProgressMonitor.cpp berryProgressProvider.cpp berryQualifiedName.cpp ) SET(INTERNAL_CPP_FILES berryInternalJob.cpp berryJobChangeEvent.cpp berryJobListeners.cpp berryJobManager.cpp berryJobQueue.cpp + berryPluginActivator.cpp berryWorker.cpp berryWorkerPool.cpp ) SET(H_FILES src/berryJobsDll.h src/berryLockListener.h src/berryISchedulingRule.h src/berryIProgressMonitor.h src/berryISchedulingRule.h src/berryILock.h ) SET(CPP_FILES ) foreach(file ${SRC_CPP_FILES}) SET(CPP_FILES ${CPP_FILES} src/${file}) endforeach(file ${SRC_CPP_FILES}) foreach(file ${INTERNAL_CPP_FILES}) SET(CPP_FILES ${CPP_FILES} src/internal/${file}) endforeach(file ${INTERNAL_CPP_FILES}) diff --git a/BlueBerry/Bundles/org.blueberry.core.jobs/manifest_headers.cmake b/BlueBerry/Bundles/org.blueberry.core.jobs/manifest_headers.cmake new file mode 100644 index 0000000000..d39fde7cbe --- /dev/null +++ b/BlueBerry/Bundles/org.blueberry.core.jobs/manifest_headers.cmake @@ -0,0 +1,6 @@ +set(Plugin-Name "BlueBerry Jobs Mechanism") +set(Plugin-Version "1.0.0") +set(Plugin-Vendor "DKFZ, Medical and Biological Informatics") +set(Plugin-ContactAddress "http://www.mitk.org") +set(Require-Plugin org.blueberry.osgi org.blueberry.solstice.common) + diff --git a/BlueBerry/Bundles/org.blueberry.core.jobs/src/berryIJobChangeEvent.h b/BlueBerry/Bundles/org.blueberry.core.jobs/src/berryIJobChangeEvent.h index ba10dad2e0..d8e936c22d 100644 --- a/BlueBerry/Bundles/org.blueberry.core.jobs/src/berryIJobChangeEvent.h +++ b/BlueBerry/Bundles/org.blueberry.core.jobs/src/berryIJobChangeEvent.h @@ -1,75 +1,75 @@ /*========================================================================= Program: BlueBerry Platform Language: C++ Date: $Date$ Version: $Revision$ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #ifndef BERRYIJOBCHANGEEVENT_H_ #define BERRYIJOBCHANGEEVENT_H_ #include #include #include #include -#include "berryJobsDll.h" +#include namespace berry { class Job; /** * An event describing a change to the state of a job. * * @see IJobChangeListener * @noimplement This interface is not intended to be implemented by clients. */ struct BERRY_JOBS IJobChangeEvent : public Object { berryInterfaceMacro(IJobChangeEvent, berry) /** * The amount of time in milliseconds to wait after scheduling the job before it * should be run, or -1 if not applicable for this type of event. * This value is only applicable for the scheduled event. * * @return the delay time for this event */ virtual Poco::Timestamp::TimeDiff GetDelay() const = 0; /** * The job on which this event occurred. * * @return the job for this event */ virtual SmartPointer GetJob() const = 0; /** * The result returned by the job's run method, or null if * not applicable. This value is only applicable for the done event. * * @return the status for this event */ virtual IStatus::Pointer GetResult() const = 0; }; } #endif /* BERRYIJOBCHANGEEVENT_H_ */ diff --git a/BlueBerry/Bundles/org.blueberry.core.jobs/src/berryIJobManager.h b/BlueBerry/Bundles/org.blueberry.core.jobs/src/berryIJobManager.h index 601562e691..0b1729e591 100644 --- a/BlueBerry/Bundles/org.blueberry.core.jobs/src/berryIJobManager.h +++ b/BlueBerry/Bundles/org.blueberry.core.jobs/src/berryIJobManager.h @@ -1,441 +1,441 @@ /*========================================================================= Program: BlueBerry Platform Language: C++ Date: $Date$ Version: $Revision$ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #ifndef _BERRY_IJOBMANAGER_H #define _BERRY_IJOBMANAGER_H #include -#include "berryJobsDll.h" +#include #include "berryJob.h" #include "berryProgressProvider.h" #include "berryIProgressMonitor.h" #include "berryIJobChangeListener.h" #include namespace berry { /** * The job manager provides facilities for scheduling, querying, and maintaining jobs * and locks. In particular, the job manager provides the following services: *
    *
  • Maintains a queue of jobs that are waiting to be run. Items can be added to * the queue using the schedule method.
  • *
  • @todo Allows manipulation of groups of jobs called job families. } Job families can * be canceled, put to sleep, or woken up atomically. There is also a mechanism * for querying the set of known jobs in a given family.>
  • * *
  • Allows listeners to find out about progress on running jobs, and to find out * when jobs have changed states.
  • *
  • @todo Provides a factory for creating lock objects. Lock objects are smart monitors * that have strategies for avoiding deadlock. >
  • * *
  • Provide feedback to a client that is waiting for a given job or family of jobs * to complete.
  • *
* * @see Job * @see ILock * * @noimplement This interface is not intended to be implemented by clients. */ struct BERRY_JOBS IJobManager: public Object { berryInterfaceMacro(IJobManager, berry) /** * A system property key indicating whether the job manager should create * job threads as daemon threads. Set to true to force all worker * threads to be created as daemon threads. Set to false to force * all worker threads to be created as non-daemon threads. * * not used yet */ static const std::string PROP_USE_DAEMON_THREADS ; /** * Registers a job listener with the job manager. * Has no effect if an identical listener is already registered. * * @param listener the listener to be added * @see #removeJobChangeListener(IJobChangeListener) * @see IJobChangeListener */ virtual void AddJobChangeListener(IJobChangeListener::Pointer listener) = 0; ///** // * Begins applying this rule in the calling thread. If the rule conflicts with another // * rule currently running in another thread, this method blocks until there are // * no conflicting rules. Calls to beginRule must eventually be followed // * by a matching call to endRule in the same thread and with the identical // * rule instance. // *

// * Rules can be nested only if the rule for the inner beginRule // * is contained within the rule for the outer beginRule. Rule containment // * is tested with the API method ISchedulingRule.contains. Also, begin/end // * pairs must be strictly nested. Only the rule that has most recently begun // * can be ended at any given time. // *

// * A rule of null can be used, but will be ignored for scheduling // * purposes. The outermost non-null rule in the thread will be used for scheduling. A // * null rule that is begun must still be ended. // *

// * If this method is called from within a job that has a scheduling rule, the // * given rule must also be contained within the rule for the running job. // *

// * Note that endRule must be called even if beginRule fails. // * The recommended usage is: // *

   // * final ISchedulingRule rule = ...;
   // * try {
   // *   manager.beginRule(rule, monitor);
   // * } finally {
   // *   manager.endRule(rule);
   // * }
   // * 
// * // * @param rule the rule to begin applying in this thread, or null // * @param monitor a progress monitor, or null if progress // * reporting and cancellation are not desired // * @throws IllegalArgumentException if the rule is not strictly nested within // * all other rules currently active for this thread // * @throws OperationCanceledException if the supplied monitor reports cancelation // * before the rule becomes available // * @see ISchedulingRule#contains(ISchedulingRule) // */ /// virtual void BeginRule(const ISchedulingRule& rule, const IProgressMonitor& monitor) = 0; ///** // * Cancels all jobs in the given job family. Jobs in the family that are currently waiting // * will be removed from the queue. Sleeping jobs will be discarded without having // * a chance to wake up. Currently executing jobs will be asked to cancel but there // * is no guarantee that they will do so. // * // * @param family the job family to cancel, or null to cancel all jobs // * @see Job#belongsTo(Object) // */ /// virtual void Cancel(const Object& family); /** * Returns a progress monitor that can be used to provide * aggregated progress feedback on a set of running jobs. A user * interface will typically group all jobs in a progress group together, * providing progress feedback for individual jobs as well as aggregated * progress for the entire group. Jobs in the group may be run sequentially, * in parallel, or some combination of the two. *

* Recommended usage (this snippet runs two jobs in sequence in a * single progress group): *

    *    Job parseJob, compileJob;
    *    IProgressMonitor pm = Platform.getJobManager().createProgressGroup();
    *    try {
    *       pm.beginTask("Building", 10);
    *       parseJob.setProgressGroup(pm, 5);
    *       parseJob.schedule();
    *       compileJob.setProgressGroup(pm, 5);
    *       compileJob.schedule();
    *       parseJob.join();
    *       compileJob.join();
    *    } finally {
    *       pm.done();
    *    }
    * 
* * @see Job#setProgressGroup(IProgressMonitor, int) * @see IProgressMonitor * @return a progress monitor */ virtual IProgressMonitor::Pointer CreateProgressGroup() = 0; ///** // * Returns the job that is currently running in this thread, or null if there // * is no currently running job. // * // * @return the job or null // */ //// virtual Job CurrentJob() = 0; ///** // * Ends the application of a rule to the calling thread. Calls to endRule // * must be preceded by a matching call to beginRule in the same thread // * with an identical rule instance. // *

// * Rules can be nested only if the rule for the inner beginRule // * is contained within the rule for the outer beginRule. Also, begin/end // * pairs must be strictly nested. Only the rule that has most recently begun // * can be ended at any given time. // * // * @param rule the rule to end applying in this thread // * @throws IllegalArgumentException if this method is called on a rule for which // * there is no matching begin, or that does not match the most recent begin. // * @see ISchedulingRule#contains(ISchedulingRule) // */ /// virtual void EndRule(const ISchedulingRule& rule) = 0; ///** // * Returns all waiting, executing and sleeping jobs belonging // * to the given family. If no jobs are found, an empty array is returned. // * // * @param family the job family to find, or null to find all jobs // * @return the job array // * @see Job#belongsTo(Object) // */ /// virtual Job[] Find(const Object& family) = 0; /** * Returns whether the job manager is currently idle. The job manager is * idle if no jobs are currently running or waiting to run. * * @return true if the job manager is idle, and * false otherwise * @since 3.1 */ virtual bool IsIdle()= 0; /** * Returns whether the job manager is currently suspended. * * @return true if the job manager is suspended, and * false otherwise * @since 3.4 * @see #suspend() * @see #resume() */ virtual bool IsSuspended() = 0; ///** // * Waits until all jobs of the given family are finished. This method will block the // * calling thread until all such jobs have finished executing, or until this thread is // * interrupted. If there are no jobs in // * the family that are currently waiting, running, or sleeping, this method returns // * immediately. Feedback on how the join is progressing is provided to a progress // * monitor. // *

// * If this method is called while the job manager is suspended, only jobs // * that are currently running will be joined; Once there are no jobs // * in the family in the {@link Job#RUNNING} state, this method returns. // *

// *

// * Note that there is a deadlock risk when using join. If the calling thread owns // * a lock or object monitor that the joined thread is waiting for, deadlock // * will occur. This method can also result in starvation of the current thread if // * another thread continues to add jobs of the given family, or if a // * job in the given family reschedules itself in an infinite loop. // *

// * // * @param family the job family to join, or null to join all jobs. // * @param monitor Progress monitor for reporting progress on how the // * wait is progressing, or null if no progress monitoring is required. // * @exception InterruptedException if this thread is interrupted while waiting // * @exception OperationCanceledException if the progress monitor is canceled while waiting // * @see Job#belongsTo(Object) // * @see #suspend() // */ /// virtual void Join(const Object& family, const IProgressMonitor& monitor) /// throw(InterruptedException, OperationCanceledException) = 0; ///** // * Creates a new lock object. All lock objects supplied by the job manager // * know about each other and will always avoid circular deadlock amongst // * themselves. // * // * @return the new lock object // */ /// virtual ILock newLock() = 0; /** * Removes a job listener from the job manager. * Has no effect if an identical listener is not already registered. * * @param listener the listener to be removed * @see #addJobChangeListener(IJobChangeListener) * @see IJobChangeListener */ virtual void RemoveJobChangeListener(IJobChangeListener::Pointer listener) = 0; ///** // * Resumes execution of jobs after a previous suspend. All // * jobs that were sleeping or waiting prior to the suspension, or that were // * scheduled while the job manager was suspended, will now be eligible // * for execution. // *

// * Calling this method on a rule that is not suspended has no effect. If another // * thread also owns the rule at the time this method is called, then the rule will // * not be resumed until all threads have released the rule. // * // * @deprecated This method is not safe and should not be used. // * Suspending a scheduling rule violates the thread safety // * of clients that use scheduling rules as a mutual exclusion mechanism, // * and can result in concurrency problems in all clients that use the suspended rule. // * @see #suspend(ISchedulingRule, IProgressMonitor) // */ /// virtual void Resume(const ISchedulingRule& rule) = 0; ///** // * Resumes execution of jobs after a previous suspend. All // * jobs that were sleeping or waiting prior to the suspension, or that were // * scheduled while the job manager was suspended, will now be eligible // * for execution. // *

// * Calling resume when the job manager is not suspended // * has no effect. // * // * @see #suspend() // * @see #isSuspended() // */ ////virtual void Resume() = 0; ///** // * Provides a hook that is notified whenever a thread is about to wait on a lock, // * or when a thread is about to release a lock. This hook must only be set once. // *

// * This method is for internal use by the platform-related plug-ins. // * Clients should not call this method. // *

// * @see LockListener // */ // TODO LockListener .. SetLockListener /// virtual void SetLockListener(const LockListener& listener) = 0; /** * Registers a progress provider with the job manager. If there was a * provider already registered, it is replaced. *

* This method is intended for use by the currently executing Eclipse application. * Plug-ins outside the currently running application should not call this method. *

* * @param provider the new provider, or null if no progress * is needed */ virtual void SetProgressProvider(ProgressProvider::Pointer) = 0; /** * Suspends execution of all jobs. Jobs that are already running * when this method is invoked will complete as usual, but all sleeping and * waiting jobs will not be executed until the job manager is resumed. *

* The job manager will remain suspended until a subsequent call to * resume. Further calls to suspend * when the job manager is already suspended are ignored. *

* All attempts to join sleeping and waiting jobs while the job manager is * suspended will return immediately. *

* Note that this very powerful function should be used with extreme caution. * Suspending the job manager will prevent all jobs in the system from executing, * which may have adverse affects on components that are relying on * execution of jobs. The job manager should never be suspended without intent * to resume execution soon afterwards. * * @see #resume() * @see #join(Object, IProgressMonitor) * @see #isSuspended() */ // virtual void Suspend() = 0; ///** // * Defers execution of all jobs with scheduling rules that conflict with the // * given rule. The caller will be blocked until all currently executing jobs with // * conflicting rules are completed. Conflicting jobs that are sleeping or waiting at // * the time this method is called will not be executed until the rule is resumed. // *

// * While a rule is suspended, all calls to beginRule and // * endRule on a suspended rule will not block the caller. // * The rule remains suspended until a subsequent call to // * resume(ISchedulingRule) with the identical rule instance. // * Further calls to suspend with an identical rule prior to calling // * resume are ignored. // *

// *

// * This method is long-running; progress and cancelation are provided by // * the given progress monitor. In the case of cancelation, the rule will // * not be suspended. // *

// * Note: this very powerful function should be used with extreme caution. // * Suspending rules will prevent jobs in the system from executing, which may // * have adverse effects on components that are relying on execution of jobs. // * The job manager should never be suspended without intent to resume // * execution soon afterwards. Deadlock will result if the thread responsible // * for resuming the rule attempts to join a suspended job. // * // * @deprecated This method is not safe and should not be used. // * Suspending a scheduling rule violates the thread safety // * of clients that use scheduling rules as a mutual exclusion mechanism, // * and can result in concurrency problems in all clients that use the suspended rule. // * @param rule The scheduling rule to suspend. Must not be null. // * @param monitor a progress monitor, or null if progress // * reporting is not desired // * @exception OperationCanceledException if the operation is canceled. // * Cancelation can occur even if no progress monitor is provided. // * @see #resume(ISchedulingRule) // */ /// virtual void Suspend(const ISchedulingRule& rule, const IProgressMonitor& monitor) = 0; ///** // * Requests that all jobs in the given job family be suspended. Jobs currently // * waiting to be run will be removed from the queue and moved into the // * SLEEPING state. Jobs that have been put to sleep // * will remain in that state until either resumed or canceled. This method has // * no effect on jobs that are not currently waiting to be run. // *

// * Sleeping jobs can be resumed using wakeUp. // * // * @param family the job family to sleep, or null to sleep all jobs. // * @see Job#belongsTo(Object) // */ /// virtual void Sleep(const Object& family) = 0; ///** // * Transfers ownership of a scheduling rule to another thread. The identical // * scheduling rule must currently be owned by the calling thread as a result of // * a previous call to beginRule. The destination thread must // * not already own a scheduling rule. // *

// * Calling this method is equivalent to atomically calling endRule // * in the calling thread followed by an immediate beginRule in // * the destination thread. The destination thread is responsible for subsequently // * calling endRule when it is finished using the rule. // *

// * This method has no effect when the destination thread is the same as the // * calling thread. // * // * @param rule The scheduling rule to transfer // * @param destinationThread The new owner for the transferred rule. // * @since 3.1 // */ /// virtual void TransferRule(const ISchedulingRule& rule, Poco::Thread* destinationThread) = 0; ///** // * Resumes scheduling of all sleeping jobs in the given family. This method // * has no effect on jobs in the family that are not currently sleeping. // * // * @param family the job family to wake up, or null to wake up all jobs // * @see Job#belongsTo(Object) // */ /// virtual void WakeUp(const Object& family) = 0; }; } #endif /* IJOBMANAGER */ diff --git a/BlueBerry/Bundles/org.blueberry.core.jobs/src/berryIProgressMonitor.h b/BlueBerry/Bundles/org.blueberry.core.jobs/src/berryIProgressMonitor.h index 4e268c65e8..b17f592216 100644 --- a/BlueBerry/Bundles/org.blueberry.core.jobs/src/berryIProgressMonitor.h +++ b/BlueBerry/Bundles/org.blueberry.core.jobs/src/berryIProgressMonitor.h @@ -1,118 +1,118 @@ /*========================================================================= Program: BlueBerry Platform Language: C++ Date: $Date$ Version: $Revision$ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #ifndef BERRY_IPROGRESS_MONITOR_H #define BERRY_IPROGRESS_MONITOR_H -#include "berryJobsDll.h" +#include #include "berryObject.h" #include namespace berry { struct IProgressMonitor: public Object { berryInterfaceMacro(IProgressMonitor, berry) /** Constant indicating an unknown amount of work. */ static const int UNKNOWN = -1; /** * Notifies that the main task is beginning. This must only be called once * on a given progress monitor instance. * * @param name the name (or description) of the main task * @param totalWork the total number of work units into which * the main task is been subdivided. If the value is UNKNOWN * the implementation is free to indicate progress in a way which * doesn't require the total number of work units in advance. */ virtual void BeginTask(const std::string& name, int totalWork) = 0; /** * Notifies that the work is done; that is, either the main task is completed * or the user canceled it. This method may be called more than once * (implementations should be prepared to handle this case). */ virtual void Done() = 0; /** * Internal method to handle scaling correctly. This method * must not be called by a client. Clients should * always use the method worked(int). * * @param work the amount of work done */ virtual void InternalWorked(double work) = 0; /** * Returns whether cancellation of current operation has been requested. * Long-running operations should poll to see if cancellation * has been requested. * * @return true if cancellation has been requested, * and false otherwise * @see #setCanceled(bool) */ virtual bool IsCanceled() = 0; /** * Sets the cancel state to the given value. * * @param value true indicates that cancellation has * been requested (but not necessarily acknowledged); * false clears this flag * @see #isCanceled() */ virtual void SetCanceled(bool value) = 0; /** * Sets the task name to the given value. This method is used to * restore the task label after a nested operation was executed. * Normally there is no need for clients to call this method. * * @param name the name (or description) of the main task * @see #beginTask */ virtual void SetTaskName(const std::string& name) = 0; /** * Notifies that a subtask of the main task is beginning. * Subtasks are optional; the main task might not have subtasks. * * @param name the name (or description) of the subtask */ virtual void SubTask(const std::string& name) = 0; /** * Notifies that a given number of work unit of the main task * has been completed. Note that this amount represents an * installment, as opposed to a cumulative amount of work done * to date. * * @param work a non-negative number of work units just completed */ virtual void Worked(int work) = 0; }; } #endif /* _BERRY_IPROGRESS_MONITOR_H */ diff --git a/BlueBerry/Bundles/org.blueberry.core.jobs/src/berryIProgressMonitorWithBlocking.h b/BlueBerry/Bundles/org.blueberry.core.jobs/src/berryIProgressMonitorWithBlocking.h index 56e4711cdd..8d49983ff4 100644 --- a/BlueBerry/Bundles/org.blueberry.core.jobs/src/berryIProgressMonitorWithBlocking.h +++ b/BlueBerry/Bundles/org.blueberry.core.jobs/src/berryIProgressMonitorWithBlocking.h @@ -1,85 +1,85 @@ /*========================================================================= Program: BlueBerry Platform Language: C++ Date: $Date$ Version: $Revision$ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #ifndef _BERRY_IPROGRESSMONITORWITHBLOCKING_H #define _BERRY_IPROGRESSMONITORWITHBLOCKING_H #include "berryObject.h" -#include "berryJobsDll.h" +#include #include "berryIStatus.h" #include "berryIProgressMonitor.h" namespace berry { /** * An extension to the IProgressMonitor interface for monitors that want to * support feedback when an activity is blocked due to concurrent activity in * another thread. *

* When a monitor that supports this extension is passed to an operation, the * operation should call setBlocked whenever it knows that it * must wait for a lock that is currently held by another thread. The operation * should continue to check for and respond to cancellation requests while * blocked. When the operation is no longer blocked, it must call clearBlocked * to clear the blocked state. *

* This interface can be used without OSGi running. *

* Clients may implement this interface. *

* @see IProgressMonitor */ struct BERRY_JOBS IProgressMonitorWithBlocking: public IProgressMonitor { berryInterfaceMacro(IProgressMonitorWithBlocking, berry) /** * Indicates that this operation is blocked by some background activity. If * a running operation ever calls setBlocked, it must * eventually call clearBlocked before the operation * completes. *

* If the caller is blocked by a currently executing job, this method will return * an IJobStatus indicating the job that is currently blocking * the caller. If this blocking job is not known, this method will return a plain * informational IStatus object. *

* * @param reason an optional status object whose message describes the * reason why this operation is blocked, or null if this * information is not available. * @see #clearBlocked() */ virtual void SetBlocked(IStatus::Pointer reason)= 0; /** * Clears the blocked state of the running operation. If a running * operation ever calls setBlocked, it must eventually call * clearBlocked before the operation completes. * * @see #setBlocked(IStatus) */ virtual void ClearBlocked() = 0; }; } #endif /* _BERRY_IPROGRESSMONITORWITHBLOCKING_H */ diff --git a/BlueBerry/Bundles/org.blueberry.core.jobs/src/berryISchedulingRule.h b/BlueBerry/Bundles/org.blueberry.core.jobs/src/berryISchedulingRule.h index 0ecfc6ce31..64c105bef8 100644 --- a/BlueBerry/Bundles/org.blueberry.core.jobs/src/berryISchedulingRule.h +++ b/BlueBerry/Bundles/org.blueberry.core.jobs/src/berryISchedulingRule.h @@ -1,94 +1,94 @@ /*========================================================================= Program: BlueBerry Platform Language: C++ Date: $Date$ Version: $Revision$ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #ifndef _BERRY_ISCHEDULING_RULE_H_ #define _BERRY_ISCHEDULING_RULE_H_ -#include "berryJobsDll.h" +#include #include namespace berry { /** * Scheduling rules are used by jobs to indicate when they need exclusive access * to a resource. * @todo * Scheduling rules can also be applied synchronously to a thread * using IJobManager.beginRule(ISchedulingRule) and * IJobManager.endRule(ISchedulingRule). * * The job manager guarantees that * no two jobs with conflicting scheduling rules will run concurrently. * @todo * Multiple rules can be applied to a given thread only if the outer rule explicitly * allows the nesting as specified by the contains method. * *

* Clients may implement this interface. * * @see Job#GetRule() * @see Job#SetRule(ISchedulingRule) * @see Job#Schedule(long) * @see IJobManager#BeginRule(ISchedulingRule, org.eclipse.core.runtime.IProgressMonitor) * @see IJobManager#EndRule(ISchedulingRule) */ struct BERRY_JOBS ISchedulingRule: public Object { berryInterfaceMacro(ISchedulingRule, berry) /** * Returns whether this scheduling rule completely contains another scheduling * rule. Rules can only be nested within a thread if the inner rule is completely * contained within the outer rule. *

* Implementations of this method must obey the rules of a partial order relation * on the set of all scheduling rules. In particular, implementations must be reflexive * (a.contains(a) is always true), antisymmetric (a.contains(b) and b.contains(a) iff * equals(b), * and transitive (if a.contains(b) and b.contains(c), then a.contains(c)). Implementations * of this method must return false when compared to a rule they * know nothing about. * * @param rule the rule to check for containment * @return true if this rule contains the given rule, and * false otherwise. */ virtual bool Contains(ISchedulingRule::Pointer rule) const = 0; /** * Returns whether this scheduling rule is compatible with another scheduling rule. * If true is returned, then no job with this rule will be run at the * same time as a job with the conflicting rule. If false is returned, * then the job manager is free to run jobs with these rules at the same time. *

* Implementations of this method must be reflexive, symmetric, and consistent, * and must return false when compared to a rule they know * nothing about. * * @param rule the rule to check for conflicts * @return true if the rule is conflicting, and false * otherwise. */ virtual bool IsConflicting(ISchedulingRule::Pointer myRule) const = 0; }; } #endif // _BERRY_ISCHEDULING_RULE_H_ diff --git a/BlueBerry/Bundles/org.blueberry.core.jobs/src/berryJob.cpp b/BlueBerry/Bundles/org.blueberry.core.jobs/src/berryJob.cpp index 1a4b5ecc03..0a445f83fe 100644 --- a/BlueBerry/Bundles/org.blueberry.core.jobs/src/berryJob.cpp +++ b/BlueBerry/Bundles/org.blueberry.core.jobs/src/berryJob.cpp @@ -1,205 +1,205 @@ /*========================================================================= Program: BlueBerry Platform Language: C++ Date: $Date$ Version: $Revision$ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even PURPOSE. See the above copyright notices for more information. =========================================================================*/ #include "berryJob.h" #include "berryIJobManager.h" #include "internal/berryJobManager.h" #include "berryIStatus.h" #include "berryStatus.h" #include namespace berry { -const IStatus::Pointer Job::ASYNC_FINISH(new Status ( IStatus::OK_TYPE, JobManager::PI_JOBS, 1, "") ) ; +const IStatus::Pointer Job::ASYNC_FINISH(new Status ( IStatus::OK_TYPE, JobManager::PI_JOBS(), 1, "") ) ; Job::Job(std::string name) : InternalJob(name) { } const IJobManager* Job::GetJobManager() { return ptr_manager; } bool Job::BelongsTo(Object::Pointer /*family*/) { return false; } bool Job::Cancel() { return InternalJob::Cancel(); } void Job::Done(IStatus::Pointer result) { InternalJob::Done(result); } std::string Job::GetName() const { return InternalJob::GetName(); } int Job::GetPriority() const { return InternalJob::GetPriority(); } // TODO QualifiedName muss noch implementiert werden // Object Job::GetProperty(QualifiedName key) // { // return InternalJob::GetProperty(key); // } IStatus::Pointer Job::GetResult() const { return InternalJob::GetResult(); } ISchedulingRule::Pointer Job::GetRule() const { return InternalJob::GetRule(); } int Job::GetState() const { return InternalJob::GetState(); } Poco::Thread* Job::GetThread() const { return InternalJob::GetThread(); } bool Job::IsBlocking() { return InternalJob::IsBlocking(); } bool Job::IsSystem() const { return InternalJob::IsSystem(); } bool Job::IsUser() const { return InternalJob::IsUser(); } // TODO Join //void Job::Join() // throw (InterruptedException) // { // InternalJob::Join(); // } void Job::RemoveJobChangeListener(IJobChangeListener::Pointer listener) { InternalJob::RemoveJobChangeListener(listener); } void Job::Schedule() { Poco::Timestamp::TimeDiff tmpNoDelay = 0; InternalJob::Schedule(tmpNoDelay); } void Job::Schedule(Poco::Timestamp::TimeDiff delay) { InternalJob::Schedule(delay); } void Job::SetName(std::string name) { InternalJob::SetName(name); } void Job::SetPriority(int priority) { InternalJob::SetPriority(priority); } void Job::SetProgressGroup(IProgressMonitor::Pointer group, int ticks) { InternalJob::SetProgressGroup(group, ticks); } // TODO SetProperty // void Job::SetProperty(QualifiedName key, Object value) // { // InternalJob::SetProperty(key, value); // } void Job::SetRule(ISchedulingRule::Pointer rule) { InternalJob::SetRule(rule); } void Job::SetSystem(bool value) { InternalJob::SetSystem(value); } void Job::SetUser(bool value) { InternalJob::SetUser(value); } void Job::SetThread(Poco::Thread* thread) { InternalJob::SetThread(thread); } bool Job::ShouldRun() { return true; } bool Job::ShouldSchedule() { return true; } bool Job::Sleep() { return InternalJob::Sleep(); } void Job::WakeUp() { InternalJob::WakeUp(0); } void Job::WakeUp(long delay) { InternalJob::WakeUp(delay); } void Job::Canceling() { //default implementation does nothing } } diff --git a/BlueBerry/Bundles/org.blueberry.core.jobs/src/berryJob.h b/BlueBerry/Bundles/org.blueberry.core.jobs/src/berryJob.h index 65e4b99c37..ac6595f76d 100644 --- a/BlueBerry/Bundles/org.blueberry.core.jobs/src/berryJob.h +++ b/BlueBerry/Bundles/org.blueberry.core.jobs/src/berryJob.h @@ -1,640 +1,640 @@ /*========================================================================= Program: BlueBerry Platform Language: C++ Date: $Date$ Version: $Revision$ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #ifndef _BERRY_JOB_H #define _BERRY_JOB_H #include -#include "berryJobsDll.h" +#include // #include "berryISchedulingRule.h" #include "berryJobExceptions.h" #include "internal/berryInternalJob.h" #include #include namespace berry { struct IJobManager; /** * Jobs are units of runnable work that can be scheduled to be run with the job * manager. Once a job has completed, it can be scheduled to run again (jobs are * reusable). *

* Jobs have a state that indicates what they are currently doing. When constructed, * jobs start with a state value of NONE. When a job is scheduled * to be run, it moves into the WAITING state. When a job starts * running, it moves into the RUNNING state. When execution finishes * (either normally or through cancellation), the state changes back to * NONE. *

* A job can also be in the SLEEPING state. This happens if a user * calls Job.sleep() on a waiting job, or if a job is scheduled to run after a specified * delay. Only jobs in the WAITING state can be put to sleep. * Sleeping jobs can be woken at any time using Job.wakeUp(), which will put the * job back into the WAITING state. *

* Jobs can be assigned a priority that is used as a hint about how the job should * be scheduled. There is no guarantee that jobs of one priority will be run before * all jobs of lower priority. The documentation of the various priority constants provide * more detail about what each priority means. By default, jobs start in the * LONG priority class. * * @see IJobManager * */ //TODO struct Job: public InternalJob, public IAdaptable class BERRY_JOBS Job: public InternalJob { public: berryObjectMacro(Job) /** * Job status return value that is used to indicate asynchronous job completion. * @see Job#Run(IProgressMonitor::Pointer) * @see Job#Done(IStatus::Pointer) */ static const IStatus::Pointer ASYNC_FINISH ; /* Job priorities */ /** * Job priority constant (value 10) for interactive jobs. * Interactive jobs generally have priority over all other jobs. * Interactive jobs should be either fast running or very low on CPU * usage to avoid blocking other interactive jobs from running. * * @see #GetPriority() * @see #SetPriority(int) * @see #Run(IProgressMonitor::Pointer) */ static const int INTERACTIVE = 10; /** * Job priority constant (value 20) for short background jobs. * Short background jobs are jobs that typically complete within a second, * but may take longer in some cases. Short jobs are given priority * over all other jobs except interactive jobs. * * @see #GetPriority() * @see #SetPriority(int) * @see #Run(IProgressMonitor::Pointer) */ static const int SHORT = 20; /** * Job priority constant (value 30) for long-running background jobs. * * @see #GetPriority() * @see #SetPriority(int) * @see #Run(IProgressMonitor::Pointer) */ static const int LONG = 30; /** * Job priority constant (value 40) for build jobs. Build jobs are * generally run after all other background jobs complete. * * @see #GetPriority() * @see #SetPriority(int) * @see #Run(IProgressMonitor) */ static const int BUILD = 40; /** * Job priority constant (value 50) for decoration jobs. * Decoration jobs have lowest priority. Decoration jobs generally * compute extra information that the user may be interested in seeing * but is generally not waiting for. * * @see #GetPriority() * @see #SetPriority(int) * @see #Run(IProgressMonitor) */ static const int DECORATE = 50; /** * Job state code (value 0) indicating that a job is not * currently sleeping, waiting, or running (i.e., the job manager doesn't know * anything about the job). * * @see #GetState() */ static const int NONE = 0; /** * Job state code (value 1) indicating that a job is sleeping. * * @see #Run(IProgressMonitor) * @see #GetState() */ static const int SLEEPING = 0x01; /** * Job state code (value 2) indicating that a job is waiting to be run. * * @see #GetState() */ static const int WAITING = 0x02; /** * Job state code (value 4) indicating that a job is currently running * * @see #GetState() */ static const int RUNNING = 0x04; /** * Returns the job manager. * * @return the job manager */ static const IJobManager* GetJobManager(); /** * Creates a new job with the specified name. The job name is a human-readable * value that is displayed to users. The name does not need to be unique, but it * must not be null. * * @param name the name of the job. */ Job(std::string name); /** * Registers a job listener with this job * Has no effect if an identical listener is already registered. * * @param listener the listener to be added. */ void AddJobChangeListener(IJobChangeListener::Pointer listener); /** * Returns whether this job belongs to the given family. Job families are * represented as objects that are not interpreted or specified in any way * by the job manager. Thus, a job can choose to belong to any number of * families. *

* Clients may override this method. This default implementation always returns * false. Overriding implementations must return false * for families they do not recognize. *

* * @param family the job family identifier * @return true if this job belongs to the given family, and * false otherwise. */ bool BelongsTo(Object::Pointer family); /** * Stops the job. If the job is currently waiting, * it will be removed from the queue. If the job is sleeping, * it will be discarded without having a chance to resume and its sleeping state * will be cleared. If the job is currently executing, it will be asked to * stop but there is no guarantee that it will do so. * * @return false if the job is currently running (and thus may not * respond to cancellation), and true in all other cases. */ bool Cancel(); /** * Jobs that complete their execution asynchronously must indicate when they * are finished by calling this method. This method must not be called by * a job that has not indicated that it is executing asynchronously. *

* This method must not be called from within the scope of a job's run * method. Jobs should normally indicate completion by returning an appropriate * status from the run method. Jobs that return a status of * ASYNC_FINISH from their run method must later call * done to indicate completion. * * @param result a status object indicating the result of the job's execution. * @see #ASYNC_FINISH * @see #Run(IProgressMonitor::Pointer) */ void Done(IStatus::Pointer result); /** * Returns the human readable name of this job. The name is never * null. * * @return the name of this job */ std::string GetName() const; /** * Returns the priority of this job. The priority is used as a hint when the job * is scheduled to be run. * * @return the priority of the job. One of INTERACTIVE, SHORT, LONG, BUILD, * or DECORATE. */ int GetPriority() const; /** * Returns the value of the property of this job identified by the given key, * or null if this job has no such property. * * @param key the name of the property * @return the value of the property, * or null if this job has no such property * @see #SetProperty(QualifiedName, Object) */ //TODO QualifiedName GetPropertys ///Object GetProperty(QualifiedName key) const ; /** * Returns the result of this job's last run. * * @return the result of this job's last run, or null if this * job has never finished running. */ IStatus::Pointer GetResult() const ; /** * Returns the scheduling rule for this job. Returns null if this job has no * scheduling rule. * * @return the scheduling rule for this job, or null. * @see ISchedulingRule * @see #SetRule(ISchedulingRule::Pointer) */ ISchedulingRule::Pointer GetRule() const; /** * Returns the state of the job. Result will be one of: *

    *
  • Job.RUNNING - if the job is currently running.
  • *
  • Job.WAITING - if the job is waiting to be run.
  • *
  • Job.SLEEPING - if the job is sleeping.
  • *
  • Job.NONE - in all other cases.
  • *
*

* Note that job state is inherently volatile, and in most cases clients * cannot rely on the result of this method being valid by the time the * result is obtained. For example, if getState returns * RUNNING, the job may have actually completed by the * time the getState method returns. All clients can infer from * invoking this method is that the job was recently in the returned state. * * @return the job state */ int GetState() const; /** * Returns the thread that this job is currently running in. * * @return the thread this job is running in, or null * if this job is not running or the thread is unknown. */ Poco::Thread* GetThread() const; /** * Returns whether this job is blocking a higher priority non-system job from * starting due to a conflicting scheduling rule. Returns false * if this job is not running, or is not blocking a higher priority non-system job. * * @return true if this job is blocking a higher priority non-system * job, and false otherwise. * @see #GetRule() * @see #IsSystem() */ bool IsBlocking(); /** * Returns whether this job is a system job. System jobs are typically not * revealed to users in any UI presentation of jobs. Other than their UI presentation, * system jobs act exactly like other jobs. If this value is not explicitly set, jobs * are treated as non-system jobs. The default value is false. * * @return true if this job is a system job, and * false otherwise. * @see #SetSystem(bool) */ bool IsSystem() const; /** * Returns whether this job has been directly initiated by a UI end user. * These jobs may be presented differently in the UI. The default value * is false. * * @return true if this job is a user-initiated job, and * false otherwise. * @see #SetUser(bool) */ bool IsUser() const; /** * Waits until this job is finished. This method will block the calling thread until the * job has finished executing, or until this thread has been interrupted. If the job * has not been scheduled, this method returns immediately. A job must not * be joined from within the scope of its run method. *

* If this method is called on a job that reschedules itself from within the * run method, the join will return at the end of the first execution. * In other words, join will return the first time this job exits the * {@link #RUNNING} state, or as soon as this job enters the {@link #NONE} state. *

*

* If this method is called while the job manager is suspended, this job * will only be joined if it is already running; if this job is waiting or sleeping, * this method returns immediately. *

*

* Note that there is a deadlock risk when using join. If the calling thread owns * a lock or object monitor that the joined thread is waiting for, deadlock * will occur. *

* * @exception InterruptedException if this thread is interrupted while waiting * @see ILock * @see IJobManager#Suspend() */ //TODO Error Join Problem InterruptedException /// void Join() ; /** * Removes a job listener from this job. * Has no effect if an identical listener is not already registered. * * @param listener the listener to be removed */ void RemoveJobChangeListener(IJobChangeListener::Pointer listener); /** * Schedules this job to be run. The job is added to a queue of waiting * jobs, and will be run when it arrives at the beginning of the queue. *

* This is a convenience method, fully equivalent to * Schedule(0L). *

* @see #Schedule(long) */ void Schedule(); /** * Schedules this job to be run after a specified delay. The job is put in the * {@link #SLEEPING} state until the specified delay has elapsed, after which * the job is added to a queue of {@link #WAITING} jobs. Once the job arrives * at the beginning of the queue, it will be run at the first available opportunity. *

* Jobs of equal priority and delay with conflicting scheduling * rules are guaranteed to run in the order they are scheduled. No guarantees * are made about the relative execution order of jobs with unrelated or * null scheduling rules, or different priorities. *

* If this job is currently running, it will be rescheduled with the specified * delay as soon as it finishes. If this method is called multiple times * while the job is running, the job will still only be rescheduled once, * with the most recent delay value that was provided. *

* Scheduling a job that is waiting or sleeping has no effect. *

* * @param delay a time delay in milliseconds before the job should run * @see ISchedulingRule */ void Schedule(Poco::Timestamp::TimeDiff delay); /** * Changes the name of this job. If the job is currently running, waiting, * or sleeping, the new job name may not take effect until the next time the * job is scheduled. *

* The job name is a human-readable value that is displayed to users. The name * does not need to be unique, but it must not be null. * * @param name the name of the job. */ void SetName(std::string name); /** * Sets the priority of the job. This will not affect the execution of * a running job, but it will affect how the job is scheduled while * it is waiting to be run. * * @param priority the new job priority. One of * INTERACTIVE, SHORT, LONG, BUILD, or DECORATE. */ void SetPriority(int priority); /** * Associates this job with a progress group. Progress feedback * on this job's next execution will be displayed together with other * jobs in that group. The provided monitor must be a monitor * created by the method IJobManager.createProgressGroup * and must have at least ticks units of available work. *

* The progress group must be set before the job is scheduled. * The group will be used only for a single invocation of the job's * run method, after which any association of this job to the * group will be lost. * * @see IJobManager#createProgressGroup() * @param group The progress group to use for this job * @param ticks the number of work ticks allocated from the * parent monitor, or {@link IProgressMonitor#UNKNOWN} */ void SetProgressGroup(IProgressMonitor::Pointer group, int ticks); /** * Sets the value of the property of this job identified * by the given key. If the supplied value is null, * the property is removed from this resource. *

* Properties are intended to be used as a caching mechanism * by ISV plug-ins. They allow key-object associations to be stored with * a job instance. These key-value associations are maintained in * memory (at all times), and the information is never discarded automatically. *

* The qualifier part of the property name must be the unique identifier * of the declaring plug-in (e.g. "com.example.plugin"). *

* * @param key the qualified name of the property * @param value the value of the property, * or null if the property is to be removed * @see #GetProperty(QualifiedName) */ //TODO QualifiedName SetProperty /// void SetProperty(QualifiedName key, Object value); /** * Sets the scheduling rule to be used when scheduling this job. This method * must be called before the job is scheduled. * * @param rule the new scheduling rule, or null if the job * should have no scheduling rule * @see #GetRule() */ void SetRule(ISchedulingRule::Pointer rule); /** * Sets whether or not this job is a system job. System jobs are typically not * revealed to users in any UI presentation of jobs. Other than their UI presentation, * system jobs act exactly like other jobs. If this value is not explicitly set, jobs * are treated as non-system jobs. This method must be called before the job * is scheduled. * * @param value true if this job should be a system job, and * false otherwise. * @see #IsSystem() */ void SetSystem(bool value); /** * Sets whether or not this job has been directly initiated by a UI end user. * These jobs may be presented differently in the UI. This method must be * called before the job is scheduled. * * @param value true if this job is a user-initiated job, and * false otherwise. * @see #IsUser() */ void SetUser(bool value); /** * Sets the thread that this job is currently running in, or null * if this job is not running or the thread is unknown. *

* Jobs that use the {@link #ASYNC_FINISH} return code should tell * the job what thread it is running in. This is used to prevent deadlocks. * * @param thread the thread that this job is running in. * * @see #ASYNC_FINISH * @see #Run(IProgressMonitor::Pointer) */ void SetThread(Poco::Thread* thread); /** * Returns whether this job should be run. * If false is returned, this job will be discarded by the job manager * without running. *

* This method is called immediately prior to calling the job's * run method, so it can be used for last minute pre-condition checking before * a job is run. This method must not attempt to schedule or change the * state of any other job. *

* Clients may override this method. This default implementation always returns * true. *

* * @return true if this job should be run * and false otherwise */ virtual bool ShouldRun(); /** * Returns whether this job should be scheduled. * If false is returned, this job will be discarded by the job manager * without being added to the queue. *

* This method is called immediately prior to adding the job to the waiting job * queue.,so it can be used for last minute pre-condition checking before * a job is scheduled. *

* Clients may override this method. This default implementation always returns * true. *

* * @return true if the job manager should schedule this job * and false otherwise */ virtual bool ShouldSchedule(); /** * Requests that this job be suspended. If the job is currently waiting to be run, it * will be removed from the queue move into the {@link #SLEEPING} state. * The job will remain asleep until either resumed or canceled. If this job is not * currently waiting to be run, this method has no effect. *

* Sleeping jobs can be resumed using wakeUp. * * @return false if the job is currently running (and thus cannot * be put to sleep), and true in all other cases * @see #WakeUp() */ bool Sleep(); /** * Puts this job immediately into the {@link #WAITING} state so that it is * eligible for immediate execution. If this job is not currently sleeping, * the request is ignored. *

* This is a convenience method, fully equivalent to * wakeUp(0L). *

* @see #Sleep() */ void WakeUp(); /** * Puts this job back into the {@link #WAITING} state after * the specified delay. This is equivalent to canceling the sleeping job and * rescheduling with the given delay. If this job is not currently sleeping, * the request is ignored. * * @param delay the number of milliseconds to delay * @see #Sleep() */ void WakeUp(long delay); protected: /** * A hook method indicating that this job is running and {@link #cancel()} * is being called for the first time. *

* Subclasses may override this method to perform additional work when * a cancellation request is made. This default implementation does nothing. */ virtual void Canceling(); /** * Executes this job. Returns the result of the execution. *

* The provided monitor can be used to report progress and respond to * cancellation. If the progress monitor has been canceled, the job * should finish its execution at the earliest convenience and return a result * status of severity {@link IStatus#CANCEL}. The singleton * cancel status {@link Status#CANCEL_STATUS} can be used for * this purpose. The monitor is only valid for the duration of the invocation * of this method. *

* This method must not be called directly by clients. Clients should call * schedule, which will in turn cause this method to be called. *

* Jobs can optionally finish their execution asynchronously (in another thread) by * returning a result status of {@link #ASYNC_FINISH}. Jobs that finish * asynchronously must specify the execution thread by calling * setThread, and must indicate when they are finished by calling * the method done. * * @param monitor the monitor to be used for reporting progress and * responding to cancellation. The monitor is never null * @return resulting status of the run. The result must not be null * @see #ASYNC_FINISH * @see #Done(IStatus) */ virtual IStatus::Pointer Run(IProgressMonitor::Pointer myProgressMonitor) = 0; }; } #endif /* BERRY_JOB_H */ diff --git a/BlueBerry/Bundles/org.blueberry.core.jobs/src/berryJobExceptions.h b/BlueBerry/Bundles/org.blueberry.core.jobs/src/berryJobExceptions.h index 1b57a82c0e..ae5d7e49c1 100644 --- a/BlueBerry/Bundles/org.blueberry.core.jobs/src/berryJobExceptions.h +++ b/BlueBerry/Bundles/org.blueberry.core.jobs/src/berryJobExceptions.h @@ -1,35 +1,35 @@ /*========================================================================= Program: BlueBerry Platform Language: C++ Date: $Date$ Version: $Revision$ Copyright (c) German Cancer Research Center, Division of g Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #ifndef BERRYJOBSEXCEPTIONS_H_ #define BERRYJOBSEXCEPTIONS_H_ -#include "berryJobsDll.h" +#include #include namespace berry { POCO_DECLARE_EXCEPTION(BERRY_JOBS, InterruptedException, Poco::RuntimeException) POCO_DECLARE_EXCEPTION(BERRY_JOBS, IllegalStateException, Poco::RuntimeException) POCO_DECLARE_EXCEPTION(BERRY_JOBS, JobRuntimeException, Poco::RuntimeException) POCO_DECLARE_EXCEPTION(BERRY_JOBS, FinallyThrowException, Poco::RuntimeException) POCO_DECLARE_EXCEPTION(BERRY_JOBS, IllegalArgumentException, Poco::Exception) } #endif /* BERRYJOBSEXCEPTIONS_H_ */ diff --git a/BlueBerry/Bundles/org.blueberry.core.jobs/src/berryJobStatus.cpp b/BlueBerry/Bundles/org.blueberry.core.jobs/src/berryJobStatus.cpp index ca90d05739..a111c680c0 100644 --- a/BlueBerry/Bundles/org.blueberry.core.jobs/src/berryJobStatus.cpp +++ b/BlueBerry/Bundles/org.blueberry.core.jobs/src/berryJobStatus.cpp @@ -1,83 +1,83 @@ /*========================================================================= Program: BlueBerry Platform Language: C++ Date: $Date$ Version: $Revision$ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #include "berryJobStatus.h" #include "internal/berryJobManager.h" -#include "berryJobsDll.h" +#include namespace berry { JobStatus::JobStatus(const Status::Severity& serverity, Job::Pointer sptr_job, const std::string& message) : m_myJob(sptr_job), m_internalStatus(new Status(serverity, - JobManager::PI_JOBS, 1, message)) + JobManager::PI_JOBS(), 1, message)) { } Job::Pointer JobStatus::GetJob() { return m_myJob; } std::vector JobStatus::GetChildren() const { return m_internalStatus->GetChildren(); } int JobStatus::GetCode() const { return m_internalStatus->GetCode(); } std::exception JobStatus::GetException() const { return m_internalStatus->GetException(); } std::string JobStatus::GetMessage() const { return m_internalStatus->GetMessage(); } std::string JobStatus::GetPlugin() const { return m_internalStatus->GetPlugin(); } IStatus::Severity JobStatus::GetSeverity() const { return m_internalStatus->GetSeverity(); } bool JobStatus::IsMultiStatus() const { return m_internalStatus->IsMultiStatus(); } bool JobStatus::IsOK() const { return m_internalStatus->IsOK(); } bool JobStatus::Matches(const Severities& severityMask) const { return m_internalStatus->Matches(severityMask); } } diff --git a/BlueBerry/Bundles/org.blueberry.core.jobs/src/berryJobsDll.h b/BlueBerry/Bundles/org.blueberry.core.jobs/src/berryJobsDll.h deleted file mode 100644 index 6ec552876f..0000000000 --- a/BlueBerry/Bundles/org.blueberry.core.jobs/src/berryJobsDll.h +++ /dev/null @@ -1,43 +0,0 @@ -/*========================================================================= - -Program: BlueBerry Platform -Language: C++ -Date: $Date$ -Version: $Revision$ - -Copyright (c) German Cancer Research Center, Division of Medical and -Biological Informatics. All rights reserved. -See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. - -This software is distributed WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. See the above copyright notices for more information. - -=========================================================================*/ - -#ifndef _BERRY_JOBS_DLL_H_ -#define _BERRY_JOBS_DLL_H_ - - -// -// The following block is the standard way of creating macros which make exporting -// from a DLL simpler. All files within this DLL are compiled with the org_blueberry_core_jobs_EXPORTS -// symbol defined on the command line. this symbol should not be defined on any project -// that uses this DLL. This way any other project whose source files include this file see -//org_blueberry_core_jobs_EXPORTS functions as being imported from a DLL, wheras this DLL sees symbols -// defined with this macro as being exported. -// -#if defined(_WIN32) && !defined(BERRY_STATIC) - #if defined(org_blueberry_core_jobs_EXPORTS) - #define BERRY_JOBS __declspec(dllexport) - #else - #define BERRY_JOBS __declspec(dllimport) - #endif -#endif - - -#if !defined(BERRY_JOBS) - #define BERRY_JOBS -#endif - -#endif /*_BERRY_JOBS_DLL_H_*/ diff --git a/BlueBerry/Bundles/org.blueberry.core.jobs/src/berryLockListener.h b/BlueBerry/Bundles/org.blueberry.core.jobs/src/berryLockListener.h index d2e6d4ff08..81a229055d 100644 --- a/BlueBerry/Bundles/org.blueberry.core.jobs/src/berryLockListener.h +++ b/BlueBerry/Bundles/org.blueberry.core.jobs/src/berryLockListener.h @@ -1,90 +1,90 @@ /*========================================================================= Program: BlueBerry Platform Language: C++ Date: $Date$ Version: $Revision$ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #ifndef _BERRY_LOCKLISTENER_H_ #define _BERRY_LOCKLISTENER_H_ -#include "berryJobsDll.h" +#include #include #include namespace berry { /** * A lock listener is notified whenever a thread is about to wait * on a lock, and when a thread is about to release a lock. *

* This class is for internal use by the platform-related plug-ins. * Clients outside of the base platform should not reference or subclass this class. *

* * @see IJobManager#SetLockListener(LockListener::Pointer) */ class LockListener: public Object { berryObjectMacro( LockListener) // LockManager::ConstPointer manager = ((JobManager)Job.getJobManager()).getLockManager(); public: /** * Notification that a thread is about to block on an attempt to acquire a lock. * Returns whether the thread should be granted immediate access to the lock. *

* This default implementation always returns false. * Subclasses may override. * * @param lockOwner the thread that currently owns the lock this thread is * waiting for, or null if unknown. * @return true if the thread should be granted immediate access, * and false if it should wait for the lock to be available */ inline virtual bool AboutToWait(Poco::Thread* lockOwner) { return false; } /** * Notification that a thread is about to release a lock. *

* This default implementation does nothing. Subclasses may override. */ inline virtual void AboutToRelease() { //do nothing } protected: /** * Returns whether this thread currently owns any locks * @return true if this thread owns any locks, and * false otherwise. */ inline bool IsLockOwnerThread() const { return manager.isLockOwner(); } }; } #endif // _BERRY_LOCKLISTENER_H_ diff --git a/BlueBerry/Bundles/org.blueberry.core.jobs/src/berryQualifiedName.h b/BlueBerry/Bundles/org.blueberry.core.jobs/src/berryQualifiedName.h index db4985df4a..ec55eb441c 100644 --- a/BlueBerry/Bundles/org.blueberry.core.jobs/src/berryQualifiedName.h +++ b/BlueBerry/Bundles/org.blueberry.core.jobs/src/berryQualifiedName.h @@ -1,113 +1,113 @@ /*========================================================================= Program: BlueBerry Platform Language: C++ Date: $Date$ Version: $Revision$ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #ifndef _BERRY_QUALIFIED_NAME_ #define _BERRY_QUALIFIED_NAME_ #include #include "berryObject.h" -#include "berryJobsDll.h" +#include namespace berry { /** * Qualified names are two-part names: qualifier and local name. * The qualifier must be in URI form (see RFC2396). * Note however that the qualifier may be null if * the default name space is being used. The empty string is not * a valid local name. *

* This class can be used without OSGi running. *

* This class is not intended to be subclassed by clients. *

* @noextend This class is not intended to be subclassed by clients.ds */ struct BERRY_JOBS QualifiedName { /** Qualifier part (potentially null). */ /*package*/ std::string qualifier; /** Local name part. */ /*package*/ std::string localName; /** * Creates and returns a new qualified name with the given qualifier * and local name. The local name must not be the empty string. * The qualifier may be null. *

* Clients may instantiate. *

* @param qualifier the qualifier string, or null * @param localName the local name string */ QualifiedName(std::string qualifier, std::string localName); /** * Returns whether this qualified name is equivalent to the given object. *

* Qualified names are equal if and only if they have the same * qualified parts and local parts. * Qualified names are not equal to objects other than qualified names. *

* * @param obj the object to compare to * @return true if these are equivalent qualified * names, and false otherwise */ bool operator==(const QualifiedName& qName) const; bool operator<(const QualifiedName& qName) const; /** * Returns the local part of this name. * * @return the local name string */ std::string GetLocalName() const; /** * Returns the qualifier part for this qualified name, or null * if none. * * @return the qualifier string, or null */ std::string GetQualifier() const; /* * Implements the method Object.hashCode. * * Returns the hash code for this qualified name. */ std::size_t HashCode() const; /** * Converts this qualified name into a string, suitable for * debug purposes only. */ std::string ToString(); }; } #endif // _BERRY_QUALIFIED_NAME_ diff --git a/BlueBerry/Bundles/org.blueberry.core.jobs/src/internal/berryInternalJob.h b/BlueBerry/Bundles/org.blueberry.core.jobs/src/internal/berryInternalJob.h index 092e4ee7a7..44eae72fdf 100644 --- a/BlueBerry/Bundles/org.blueberry.core.jobs/src/internal/berryInternalJob.h +++ b/BlueBerry/Bundles/org.blueberry.core.jobs/src/internal/berryInternalJob.h @@ -1,468 +1,468 @@ /*========================================================================= Program: BlueBerry Platform Language: C++ Date: $Date$ Version: $Revision$ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #ifndef BERRY_INTERNALJOB_H #define BERRY_INTERNALJOB_H #include #include #include -#include "../berryJobsDll.h" +#include #include "../berryJobExceptions.h" #include "../berryISchedulingRule.h" #include "../berryIProgressMonitor.h" #include "../berryIJobChangeListener.h" #include #include #include #include #include #include namespace berry { struct JobManager; /** * Internal implementation class for jobs. Clients must not implement this class * directly. All jobs must be subclasses of the API org.blueberry_core_jobs.Job class. */ // struct BERRY_JOBS InternalJob: public Object, public Comparable struct BERRY_JOBS InternalJob : public Object { friend struct JobQueue; friend struct JobManager; berryObjectMacro(InternalJob) bool operator==(const Object* otherJob) const; /** * Adds an entry at the end of the list of which this item is the head. */ void AddLast(InternalJob::Pointer entry); /* * Returns the job listeners that are only listening to this job. */ const IJobChangeListener::Events& GetListeners() const; /** * Returns the job's progress monitor, or null if it is not running. */ IProgressMonitor::Pointer GetProgressMonitor() const; /** * Returns the time that this job should be started, awakened, or * rescheduled, depending on the current state. * @return time in milliseconds */ Poco::Timestamp GetStartTime() const; /** * Returns the raw job state, including internal states no exposed as API. */ int InternalGetState() const; /* * @see Job#GetState() */ int GetState() const; /** * @see Job#GetName() */ std::string GetName() const; /* * @see Job#setRule(ISchedulingRule::Pointer) */ void InternalSetRule(ISchedulingRule::Pointer rule); /** * Must be called from JobManager#setPriority */ void InternalSetPriority(int newPriority); /** * Must be called from JobManager#ChangeState */ void InternalSetState(int i); /** * Returns whether this job was canceled when it was about to run */ bool IsAboutToRunCanceled() const; /** * Returns whether this job was canceled when it was running. */ bool IsRunCanceled() const ; /** * Returns true if this job conflicts with the given job, and false otherwise. */ bool IsConflicting(InternalJob::Pointer otherJob) const; /** * Returns the next entry (ahead of this one) in the list, or null if there is no next entry */ InternalJob::Pointer Next() const; /** * Returns the previous entry (behind this one) in the list, or null if there is no previous entry */ InternalJob::Pointer Previous() const; /** * Removes this entry from any list it belongs to. Returns the receiver. */ InternalJob::Pointer Remove(); /* * @see Job#run(IProgressMonitor) */ virtual IStatus::Pointer Run(IProgressMonitor::Pointer myProgressMonitor) = 0 ; /** * Sets whether this job was canceled when it was about to run */ void SetAboutToRunCanceled(bool value) throw (JobRuntimeException); /** * Sets the next entry in this linked list of jobs. * @param entry */ /** * Sets whether this job was canceled when it was running */ void SetRunCanceled(bool value) ; void SetNext(InternalJob::Pointer entry); /** * Sets the previous entry in this linked list of jobs. * @param entry */ void SetPrevious(InternalJob::Pointer entry); /** * Sets the progress monitor to use for the next execution of this job, * or for clearing the monitor when a job completes. * @param monitor a progress monitor */ void SetProgressMonitor(IProgressMonitor::Pointer monitor); /** * Sets or clears the result of an execution of this job. * @param result a result status, or null */ void SetResult(IStatus::Pointer result) ; /** * Sets a time to start, wake up, or schedule this job, * depending on the current state * @param time a time in milliseconds */ void SetStartTime(Poco::Timestamp::TimeDiff time); void SetStartTime(const Poco::Timestamp& newtime); /* * @see Job.SetThread */ void SetThread(Poco::Thread* thread); /* * @see Job.GetThread */ Poco::Thread* GetThread() const; /* * Prints a string-based representation of this job instance. * For debugging purposes only. */ std::string ToString(); /** * @param waitQueueStamp The waitQueueStamp to set. */ void SetWaitQueueStamp(Poco::Timestamp waitQueueStamp); /** * @return Returns the waitQueueStamp. */ Poco::Timestamp GetWaitQueueStamp(); protected: InternalJob(std::string name); /* * @see Job#AddJobListener(IJobChangeListener::Pointer) */ void AddJobChangeListener(IJobChangeListener::Pointer listener); /* * @see Job#BelongsTo(Object) */ virtual bool BelongsTo(Object::Pointer family); /* * @see Job#Cancel() */ bool Cancel(); /* * @see Job#Canceling() */ virtual void Canceling(); /* * * @see Job#Done(IStatus:.Pointer) */ void Done(IStatus::Pointer endResult); /* * @see Job#GetPriority() */ int GetPriority() const; /* * @see Job#GetProperty */ /// Object GetProperty(QualifiedName key) ; /* * @see Job#GetResult */ IStatus::Pointer GetResult() const ; /* * @see Job#GetRule */ ISchedulingRule::Pointer GetRule() const; /* * @see Job.IsSystem() */ bool IsSystem() const; /* * @see Job.IsUser() */ bool IsUser() const; /* * @see Job#Join() */ /// void Join() throws InterruptedException ; /* * @see Job#RemoveJobListener(IJobChangeListener) */ void RemoveJobChangeListener(IJobChangeListener::Pointer listener); /* * @see Job#Schedule(long) */ void Schedule(Poco::Timestamp::TimeDiff delay); /* * @see Job#SetName(std::string) */ void SetName(const std::string& name); /* * @see Job#SetPriority(int) */ void SetPriority(int newPriority); /* * @see Job#SetProgressGroup(IProgressMonitor::Pointer, int ticks) */ void SetProgressGroup(IProgressMonitor::Pointer group, int ticks); /* * @see Job#SetProperty(QualifiedName,Object) */ /// void SetProperty(QualifiedName key, Object value) ; /* internalSetRule * @see Job#SetRule(ISchedulingRule::Pointer) */ void SetRule(ISchedulingRule::Pointer rule); /* * @see Job.SetSystem */ void SetSystem(bool value); /* * @see Job.SetUser */ void SetUser(bool value); /* * @see Job#ShouldSchedule */ virtual bool ShouldSchedule(); /* * @see Job#Sleep() */ bool Sleep(); /* * @see Job#WakeUp(long) */ void WakeUp(long delay); public: /** * Flag on a job indicating that it was canceled when running. This flag * is used to ensure that #canceling is only ever called once on a job in * case of recursive cancellation attempts. */ static const int M_RUN_CANCELED = 0x0800; /** * Job state code (value 16) indicating that a job has been removed from * the wait queue and is about to start running. From an API point of view, * this is the same as RUNNING. */ static const int ABOUT_TO_RUN = 0x10; /** * Job state code (value 32) indicating that a job has passed scheduling * precondition checks and is about to be added to the wait queue. From an API point of view, * this is the same as WAITING. */ static const int ABOUT_TO_SCHEDULE = 0x20; /** * Job state code (value 8) indicating that a job is blocked by another currently * running job. From an API point of view, this is the same as WAITING. */ static const int BLOCKED = 0x08; /** * Start time constant indicating a job should be started at * a time in the infinite future, causing it to sleep forever. */ static const Poco::Timestamp::TimeDiff T_INFINITE; /** * Start time constant indicating that the job has no start time. */ static const Poco::Timestamp::TimeDiff T_NONE; private: //flag mask bits static const int M_STATE = 0xFF; static const int M_SYSTEM = 0x0100; static const int M_USER = 0x0200; /** * flag on a job indicating that it was about to run, but has been canceled */ static const int M_ABOUT_TO_RUN_CANCELED = 0x0400; static int nextJobNumber; int jobNumber; volatile int flags; /// ListenerList listeners ; std::string name; /** * The job ahead of me in a queue or list. */ InternalJob::Pointer next; /** * The job behind me in a queue or list. */ InternalJob* previous; int priority; /** * Arbitrary properties (key,value) pairs, attached * to a job instance by a third party. */ //std::map properties ; IStatus::Pointer m_result; // Pointer to the ISchedulingRule belonging to the particular job ISchedulingRule::Pointer sptr_schedulingRule; IProgressMonitor::Pointer sptr_monitor; /** * If the job is waiting, this represents the time the job should start by. * If this job is sleeping, this represents the time the job should wake up. * If this job is running, this represents the delay automatic rescheduling, * or -1 if the job should not be rescheduled. */ Poco::Timestamp m_startTime; /** * Stamp added when a job is added to the wait queue. Used to ensure * jobs in the wait queue maintain their insertion order even if they are * removed from the wait queue temporarily while blocked */ Poco::Timestamp waitQueueStamp; /* * The that is currently running this job */ Poco::Thread* ptr_thread; InternalJob(const Self&); protected: static JobManager* const ptr_manager; IJobChangeListener::Events jobEvents; /* * @see Job#isBlocking() */ bool IsBlocking(); }; } #endif /* BERRY_INTERNALJOB_H */ diff --git a/BlueBerry/Bundles/org.blueberry.core.jobs/src/internal/berryJobListeners.cpp b/BlueBerry/Bundles/org.blueberry.core.jobs/src/internal/berryJobListeners.cpp index 7777761944..703b580d83 100644 --- a/BlueBerry/Bundles/org.blueberry.core.jobs/src/internal/berryJobListeners.cpp +++ b/BlueBerry/Bundles/org.blueberry.core.jobs/src/internal/berryJobListeners.cpp @@ -1,160 +1,160 @@ /*========================================================================= Program: BlueBerry Platform Language: C++ Date: $Date$ Version: $Revision$ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #include "berryJobListeners.h" #include "berryJobManager.h" #include "../berryJob.h" #include #include namespace berry { struct AboutToRunDoit: public JobListeners::IListenerDoit { void Notify(const IJobChangeListener::Events& events, const IJobChangeEvent::ConstPointer event) const { events.jobAboutToRun(event); } }; struct AwakeDoit: public JobListeners::IListenerDoit { void Notify(const IJobChangeListener::Events& events, const IJobChangeEvent::ConstPointer event) const { events.jobAwake(event); } }; struct DoneDoit: public JobListeners::IListenerDoit { void Notify(const IJobChangeListener::Events& events, const IJobChangeEvent::ConstPointer event) const { events.jobDone(event); } }; struct RunningDoit: public JobListeners::IListenerDoit { void Notify(const IJobChangeListener::Events& events, const IJobChangeEvent::ConstPointer event) const { events.jobRunning(event); } }; struct ScheduledDoit: public JobListeners::IListenerDoit { void Notify(const IJobChangeListener::Events& events, const IJobChangeEvent::ConstPointer event) const { events.jobScheduled(event); } }; struct SleepingDoit: public JobListeners::IListenerDoit { void Notify(const IJobChangeListener::Events& events, const IJobChangeEvent::ConstPointer event) const { events.jobSleeping(event); } }; JobListeners::JobListeners() : aboutToRun(new AboutToRunDoit()), awake(new AwakeDoit()), done(new DoneDoit()), running(new RunningDoit()), scheduled( new ScheduledDoit()), sleeping(new SleepingDoit()) { } JobListeners::~JobListeners() { delete aboutToRun; delete awake; delete done; delete running; delete scheduled; delete sleeping; } JobChangeEvent::Pointer JobListeners::NewEvent(Job::Pointer job) { JobChangeEvent::Pointer instance(new JobChangeEvent()); instance->job = job; return instance; } JobChangeEvent::Pointer JobListeners::NewEvent(Job::Pointer job, IStatus::Pointer result) { JobChangeEvent::Pointer instance(new JobChangeEvent()); instance->job = job; instance->result = result; return instance; } JobChangeEvent::Pointer JobListeners::NewEvent(Job::Pointer job, Poco::Timestamp::TimeDiff delay) { JobChangeEvent::Pointer instance(new JobChangeEvent()); instance->job = job; instance->delay = delay; return instance; } void JobListeners::DoNotify(const IListenerDoit* doit, const IJobChangeEvent::ConstPointer event) { //notify all global listeners doit->Notify(global, event); //notify all local listeners const IJobChangeListener::Events& events = event->GetJob().Cast ()->GetListeners(); doit->Notify(events, event); } void JobListeners::HandleException(const std::exception& e) { //this code is roughly copied from InternalPlatform.run(ISafeRunnable), //but in-lined here for performance reasons try { dynamic_cast (e); return; } catch (const std::bad_cast&) { // TODO get bundle id (find a C++ way) //std::string pluginId = JobOSGiUtils.getDefault().getBundleId(listener); std::string pluginId; if (pluginId.empty()) - pluginId = JobManager::PI_JOBS; + pluginId = JobManager::PI_JOBS(); std::string message = "Problems occurred when invoking code from plug-in: " + pluginId; std::cerr << message << std::endl; // TODO Logging // RuntimeLog.log(new Status(IStatus.ERROR, pluginId, JobManager.PLUGIN_ERROR, // message, e)); } } } diff --git a/BlueBerry/Bundles/org.blueberry.core.jobs/src/internal/berryJobManager.cpp b/BlueBerry/Bundles/org.blueberry.core.jobs/src/internal/berryJobManager.cpp index 3bd14494f0..e92d5ef0cb 100644 --- a/BlueBerry/Bundles/org.blueberry.core.jobs/src/internal/berryJobManager.cpp +++ b/BlueBerry/Bundles/org.blueberry.core.jobs/src/internal/berryJobManager.cpp @@ -1,1197 +1,1201 @@ /*========================================================================= Program: BlueBerry Platform Language: C++ Date: $Date$ Version: $Revision$ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #define NOMINMAX #include "berryJobManager.h" #include "berryIProgressMonitor.h" #include "berryNullProgressMonitor.h" #include "berryIStatus.h" #include "berryJobStatus.h" #include #include namespace berry { /** * test class implementing ISchedulingRule to validate client defined rules */ struct NullRule: public ISchedulingRule { bool Contains(ISchedulingRule::Pointer myRule) const; bool IsConflicting(ISchedulingRule::Pointer myRule) const; }; bool NullRule::IsConflicting(ISchedulingRule::Pointer dummyRule) const { return dummyRule == this; } bool NullRule::Contains(ISchedulingRule::Pointer dummyRule) const { return dummyRule == this; } JobManager::JobManager() : sptr_testRule(new NullRule()),m_active(true), m_Pool(new WorkerPool(this)), m_sptr_progressProvider(0), m_JobQueueSleeping(true), m_JobQueueWaiting(false),m_suspended(false), m_waitQueueCounter(0) { m_JobListeners.global.SetExceptionHandler(MessageExceptionHandler< JobListeners> (&m_JobListeners, &JobListeners::HandleException)); } // DEBUG VARIABLES -const std::string JobManager::PI_JOBS = "org.blueberry.core.jobs"; +const std::string& JobManager::PI_JOBS() +{ + static std::string id("org.blueberry.core.jobs"); + return id; +} bool JobManager::DEBUG = false; bool JobManager::DEBUG_BEGIN_END = false; bool JobManager::DEBUG_DEADLOCK = false; bool JobManager::DEBUG_LOCKS = false; bool JobManager::DEBUG_TIMING = false; bool JobManager::DEBUG_SHUTDOWN = false; const int JobManager::PLUGIN_ERROR = 2; JobManager* JobManager::GetInstance() { // we don't need to lock the creation of "instance" because GetInstance() is // called when statically initializing InternalJob::ptr_manager (which happens // in single-threaded mode) static JobManager instance; return &instance; } std::string JobManager::PrintState(int state) { switch (state) { case Job::NONE: return "NONE"; case Job::WAITING: return "WAITING"; case Job::SLEEPING: return "SLEEPING"; case Job::RUNNING: return "RUNNING"; case InternalJob::BLOCKED: return "BLOCKED"; case InternalJob::ABOUT_TO_RUN: return "ABOUT_TO_RUN"; case InternalJob::ABOUT_TO_SCHEDULE: return "ABOUT_TO_SCHEDULE"; } return "UNKNOWN"; } void JobManager::Shutdown() { JobManager* ptr_instance(GetInstance()); if (ptr_instance != 0) { ptr_instance->DoShutdown(); // ptr_instance = 0; // need to call the destructor of the static object .. } } //void //JobManager //::Cancel(Object family) { // //don't synchronize because cancel calls listeners // for (Iterator it = select(family).iterator(); it.hasNext();) // cancel((Job) it.next()); // } IProgressMonitor::Pointer JobManager::CreateProgressGroup() { if (m_sptr_progressProvider != 0) return (m_sptr_progressProvider->CreateProgressGroup()); NullProgressMonitor::Pointer sptr_defaultProgressMonitor( new NullProgressMonitor); return sptr_defaultProgressMonitor; } Job* JobManager::CurrentJob() { //Poco::Thread* ptr_current = Poco::Thread::current(); //if (Worker* worker = dynamic_cast(ptr_current) ) // return ((Worker) ptr_current).currentJob(); // { // Poco::ScopedLock lockMe (m_mutex); // Poco::HashSet::Iterator it ; // for (it = m_running.begin(); it != m_running.end(); it ++) { // Job job* = dynamic_cast (it); // if (job->GetThread() == ptr_current) // return job; // } //} return 0; } //void //JobManager //::EndRule(ISchedulingRule rule) { //implicitJobs.end(rule, false); // } //Job[] //JobManager //::Find(Object family) { // List members = select(family); // return (Job[]) members.toArray(new Job[members.size()]); // } // // LockManager GetLockManager() { // return lockManager; // } // bool JobManager::IsIdle() { { Poco::ScopedLock m_managerLock(m_mutex); return m_running.empty() && m_JobQueueWaiting.IsEmpty(); } } bool JobManager::IsSuspended() { { Poco::ScopedLock m_managerLock(m_mutex); m_suspended = true; } return m_suspended; } // // /* // * @see IJobManager#join(String, IProgressMonitor) // */ //void //JobManager //::Join(final Object family, IProgressMonitor monitor) throws InterruptedException, OperationCanceledException { // monitor = monitorFor(monitor); // IJobChangeListener listener = null; // final Set jobs; // int jobCount; // Job blocking = null; // synchronized (lock) { // //don't join a waiting or sleeping job when suspended (deadlock risk) // int states = suspended ? Job.RUNNING : Job.RUNNING | Job.WAITING | Job.SLEEPING; // jobs = Collections.synchronizedSet(new HashSet(select(family, states))); // jobCount = jobs.size(); // if (jobCount > 0) { // //if there is only one blocking job, use it in the blockage callback below // if (jobCount == 1) // blocking = (Job) jobs.iterator().next(); // listener = new JobChangeAdapter() { // public void done(IJobChangeEvent event) { // //don't remove from list if job is being rescheduled // if (!((JobChangeEvent) event).reschedule) // jobs.remove(event.getJob()); // } // // //update the list of jobs if new ones are added during the join // public void scheduled(IJobChangeEvent event) { // //don't add to list if job is being rescheduled // if (((JobChangeEvent) event).reschedule) // return; // Job job = event.getJob(); // if (job.belongsTo(family)) // jobs.add(job); // } // }; // addJobChangeListener(listener); // } // } // if (jobCount == 0) { // //use up the monitor outside synchronized block because monitors call untrusted code // monitor.beginTask(JobMessages.jobs_blocked0, 1); // monitor.done(); // return; // } // //spin until all jobs are completed // try { // monitor.beginTask(JobMessages.jobs_blocked0, jobCount); // monitor.subTask(NLS.bind(JobMessages.jobs_waitFamSub, Integer.toString(jobCount))); // reportBlocked(monitor, blocking); // int jobsLeft; // int reportedWorkDone = 0; // while ((jobsLeft = jobs.size()) > 0) { // //don't let there be negative work done if new jobs have // //been added since the join began // int actualWorkDone = Math.max(0, jobCount - jobsLeft); // if (reportedWorkDone < actualWorkDone) { // monitor.worked(actualWorkDone - reportedWorkDone); // reportedWorkDone = actualWorkDone; // monitor.subTask(NLS.bind(JobMessages.jobs_waitFamSub, Integer.toString(jobsLeft))); // } // if (Thread.interrupted()) // throw new InterruptedException(); // if (monitor.isCanceled()) // throw new OperationCanceledException(); // //notify hook to service pending syncExecs before falling asleep // lockManager.aboutToWait(null); // Thread.sleep(100); // } // } finally { // lockManager.aboutToRelease(); // removeJobChangeListener(listener); // reportUnblocked(monitor); // monitor.done(); // } // } //JobManager //::NewLock() { // return lockManager.newLock(); // } void JobManager::RemoveJobChangeListener(IJobChangeListener::Pointer listener) { m_JobListeners.Remove(listener); } void JobManager::ReportBlocked(IProgressMonitor::Pointer sptr_monitor, InternalJob::Pointer sptr_blockingJob) const { if ( sptr_monitor.Cast() == 0 ) return ; if (sptr_blockingJob == 0 || sptr_blockingJob->IsSystem()) { - Status::Pointer sptr_reason( new Status(IStatus::INFO_TYPE, JobManager::PI_JOBS, 1, "the user operation is waiting for background work to complete" ) ); + Status::Pointer sptr_reason( new Status(IStatus::INFO_TYPE, JobManager::PI_JOBS(), 1, "the user operation is waiting for background work to complete" ) ); } else { std::stringstream msg ; msg << "the user operation is waiting for : " << sptr_blockingJob->GetName() << " to complete. " ; JobStatus::Pointer sptr_reason(new JobStatus(IStatus::INFO_TYPE, sptr_blockingJob.Cast(), msg.str() )); } // ((IProgressmonitorWithBlocking) sptr_monitor)->SetBlocked(sptr_reason); } void JobManager::ReportUnblocked(IProgressMonitor::Pointer sptr_monitor) const { if ( IProgressMonitorWithBlocking::Pointer sptr_monitorWithBlocking = sptr_monitor.Cast() ) sptr_monitorWithBlocking->ClearBlocked(); } void JobManager::Resume() { { Poco::ScopedLock lockMe(m_mutex); m_suspended = false; //poke the job pool m_Pool->JobQueued(); } } //TODO implicit Jobs //void //JobManager //::Resume(ISchedulingRule rule)const { // implicitJobs.resume(rule); // } void JobManager::SetProgressProvider(ProgressProvider::Pointer provider) { m_sptr_progressProvider = provider; } void JobManager::SetRule(InternalJob::Pointer job, ISchedulingRule::Pointer sptr_rule) { Poco::ScopedLock m_managerLock(m_mutex); //cannot change the rule of a job that is already running ( GetRule is set to protected which should be // changed if this assert is needed // assert(job->GetState() == Job.NONE); ValidateRule(sptr_rule); job->InternalSetRule(sptr_rule); } //void //JobManager //::Sleep(Object family) { // //don't synchronize because sleep calls listeners // for (Iterator it = select(family).iterator(); it.hasNext();) { // sleep((InternalJob) it.next()); // } // } void JobManager::Suspend() { { Poco::ScopedLock lockMe(m_mutex); m_suspended = true; } } //void //JobManager //::Suspend(ISchedulingRule rule, IProgressMonitor monitor)const { // Assert.isNotNull(rule); // implicitJobs.suspend(rule, monitorFor(monitor)); // } //void //JobManager //::TransferRule(ISchedulingRule rule, Thread destinationThread) { // implicitJobs.transfer(rule, destinationThread); // } //void //JobManager //::SetLockListener(LockListener listener) { // lockManager.setLockListener(listener); // } //void //JobManager //::WakeUp(Object family) { // //don't synchronize because wakeUp calls listeners // for (Iterator it = select(family).iterator(); it.hasNext();) { // wakeUp((InternalJob) it.next(), 0L); // } // } void JobManager::AddJobChangeListener(IJobChangeListener::Pointer listener) { m_JobListeners.Add(listener); } //void //JobManager //::BeginRule(ISchedulingRule rule, IProgressMonitor monitor) { // validateRule(rule); // implicitJobs.begin(rule, monitorFor(monitor), false); // } // // /** // * For debugging purposes only // */ //std::String //JobManager //::PrintJobName(Job job) { // if (job instanceof ThreadJob) { // Job realJob = ((ThreadJob) job).realJob; // if (realJob != null) // return realJob.getClass().getName(); // return "ThreadJob on rule: " + job.getRule(); //$NON-NLS-1$ // } // return job.getClass().getName(); // } // // instance = this; // initDebugOptions(); // synchronized (lock) { // running = new HashSet(10); // } // pool.setDaemon(JobOSGiUtils.getDefault().useDaemonThreads()); //} void JobManager::ChangeState(InternalJob::Pointer sptr_job, int newState) { bool blockedJobs = false; { Poco::ScopedLock m_managerLock(m_mutex); int tmp_oldState = sptr_job->InternalGetState(); switch (tmp_oldState) { case Job::NONE: case InternalJob::ABOUT_TO_SCHEDULE: break; case InternalJob::BLOCKED: //remove this job from the linked list of blocked jobs sptr_job->Remove(); break; case Job::WAITING: m_JobQueueWaiting.Remove(sptr_job); // assert(false, "Tried to remove a job that wasn't in the queue"); break; case Job::SLEEPING: m_JobQueueSleeping.Remove(sptr_job); // assert(false, "Tried to remove a job that wasn't in the queue"); case Job::RUNNING: case InternalJob::ABOUT_TO_RUN: m_running.erase(sptr_job); //add any blocked jobs back to the wait queue InternalJob::Pointer sptr_blocked(sptr_job->Previous()); sptr_job->Remove(); blockedJobs = sptr_blocked != 0; while (sptr_blocked != 0) { InternalJob::Pointer previous = sptr_blocked->Previous(); ChangeState(sptr_blocked, Job::WAITING); sptr_blocked = previous; } break; // default : // Assert.isLegal(false, "Invalid job state: " + job + ", state: " + oldState); } sptr_job->InternalSetState(newState); switch (newState) { case Job::NONE: sptr_job->SetStartTime(InternalJob::T_NONE); sptr_job->SetWaitQueueStamp(InternalJob::T_NONE); case InternalJob::BLOCKED: break; case Job::WAITING: m_JobQueueWaiting.Enqueue(sptr_job); break; case Job::SLEEPING: //try { m_JobQueueSleeping.Enqueue(sptr_job); //} catch (RuntimeException e) { // throw new RuntimeException("Error changing from state: " + oldState); //} break; case Job::RUNNING: case InternalJob::ABOUT_TO_RUN: sptr_job->SetStartTime(InternalJob::T_NONE); sptr_job->SetWaitQueueStamp(InternalJob::T_NONE); m_running.insert(sptr_job); break; case InternalJob::ABOUT_TO_SCHEDULE: break; // default : // Assert.isLegal(false, "Invalid job state: " + job + ", state: " + newState); } } //notify queue outside sync block if (blockedJobs) m_Pool->JobQueued(); } Poco::Timestamp::TimeDiff JobManager::DelayFor(int priority) { //these values may need to be tweaked based on machine speed switch (priority) { case Job::INTERACTIVE: return 0; case Job::SHORT: return 50; case Job::LONG: return 100; case Job::BUILD: return 500; case Job::DECORATE: return 1000; default: // Assert.isTrue(false, "Job has invalid priority: " + priority); //$NON-NLS-1$ return 0; } } void JobManager::DoSchedule(InternalJob::Pointer job, Poco::Timestamp::TimeDiff delay) { Poco::ScopedLock managerLock(m_mutex); //job may have been canceled already int state = job->InternalGetState(); if (state != InternalJob::ABOUT_TO_SCHEDULE && state != Job::SLEEPING) return; //if it's a decoration job with no rule, don't run it right now if the system is busy if (job->GetPriority() == Job::DECORATE && job->GetRule() == 0) { Poco::Timestamp::TimeDiff tmp_minDelay = m_running.size() * 100; delay = std::max(delay, tmp_minDelay); } if (delay > 0) { job->SetStartTime(Poco::Timestamp() + delay * 100); InternalJob::Pointer sptr_job(job); ChangeState(sptr_job, Job::SLEEPING); } else { job->SetStartTime(Poco::Timestamp() + DelayFor(job->GetPriority()) * 100); job->SetWaitQueueStamp(m_waitQueueCounter++); InternalJob::Pointer sptr_job(job); ChangeState(sptr_job, Job::WAITING); } } void JobManager::DoShutdown() { std::vector vec_ToCancel; { Poco::ScopedLock LockMe(m_mutex); if (m_active) { m_active = false; //cancel all running jobs vec_ToCancel.assign(m_running.begin(), m_running.end()); //clean up m_JobQueueSleeping.Clear(); m_JobQueueWaiting.Clear(); m_running.clear(); } } // Give running jobs a chance to finish. Wait 0.1 seconds for up to 3 times. if (!vec_ToCancel.empty()) { for (std::size_t i = 0; i < vec_ToCancel.size(); i++) { // cancel jobs outside sync block to avoid deadlock Cancel(vec_ToCancel[i]); } for (int waitAttempts = 0; waitAttempts < 3; waitAttempts++) { Poco::Thread::yield(); { Poco::ScopedLock LockMe(m_mutex); if (m_running.empty()) break; } if (DEBUG_SHUTDOWN) { // JobManager.debug("Shutdown - job wait cycle #" + (waitAttempts + 1)); std::vector vec_StillRunning; { Poco::ScopedLock LockMe(m_mutex); vec_StillRunning.assign(m_running.begin(), m_running.end()); // if (!vec_StillRunning.empty()) { //for (int j = 0; j < stillRunning.length; j++) { // JobManager.debug("\tJob: " + printJobName(stillRunning[j])); //$NON-NLS-1$ //} } } Poco::Thread::sleep(100); Poco::Thread::yield(); } // retrieve list of the jobs that are still running { Poco::ScopedLock LockMe(m_mutex); vec_ToCancel.assign(m_running.begin(), m_running.end()); } } if (!vec_ToCancel.empty()) { /*for (int i = 0; i < vec_ToCancel.size(); i++) {*/ // std::string tmp_jobName = PrintJobName(toCancel[i]); // //this doesn't need to be translated because it's just being logged // String msg = "Job found still running after platform shutdown. Jobs should be canceled by the plugin that // scheduled them during shutdown: " + jobName; // RuntimeLog.log(new Status(IStatus.WARNING, JobManager.PI_JOBS, JobManager.PLUGIN_ERROR, msg, null)); // // // TODO the RuntimeLog.log in its current implementation won't produce a log // // during this stage of shutdown. For now add a standard error output. // // One the logging story is improved, the System.err output below can be removed: // System.err.println(msg); // } } m_Pool->Shutdown(); } Job::Pointer JobManager::NextJob() { { Poco::ScopedLock managerLock(m_mutex); //do nothing if the job manager is suspended if (m_suspended) return Job::Pointer(0); // tickle the sleep queue to see if anyone wakes up Poco::Timestamp now; InternalJob::Pointer ptr_job = m_JobQueueSleeping.Peek(); while (ptr_job != 0 && ptr_job->GetStartTime() < now) { // a job that slept to long is set a new start time and is put into the waiting queue ptr_job->SetStartTime(now + DelayFor(ptr_job->GetPriority())); ptr_job->SetWaitQueueStamp(m_waitQueueCounter++); InternalJob::Pointer sptr_job(ptr_job); ChangeState(sptr_job, Job::WAITING); ptr_job = m_JobQueueSleeping.Peek(); } //process the wait queue until we find a job whose rules are satisfied. while ((ptr_job = m_JobQueueWaiting.Peek()) != 0) { InternalJob::Pointer sptr_job(ptr_job); InternalJob::Pointer sptr_blocker = FindBlockingJob(sptr_job); if (sptr_blocker == 0) break; //queue this job after the job that's blocking it ChangeState(sptr_job, InternalJob::BLOCKED); //assert job does not already belong to some other data structure //Assert.isTrue(job.next() == null); //Assert.isTrue(job.previous() == null); sptr_blocker->AddLast(ptr_job); } // the job to run must be in the running list before we exit // the sync block, otherwise two jobs with conflicting rules could start at once if (ptr_job != 0) { InternalJob::Pointer sptr_job(ptr_job); ChangeState(sptr_job, InternalJob::ABOUT_TO_RUN); } return ptr_job.Cast (); } } //TODO Job families //void //JobManager //::Select(List members, Object family, InternalJob firstJob, int stateMask) { // if (firstJob == null) // return; // InternalJob job = firstJob; // do { // //note that job state cannot be NONE at this point // if ((family == null || job.belongsTo(family)) && ((job.getState() & stateMask) != 0)) // members.add(job); // job = job.previous(); // } while (job != null && job != firstJob); // } //List //JobManager //::Select(Object family) { // return select(family, Job.WAITING | Job.SLEEPING | Job.RUNNING); // } //List //JobManager //::Select(Object family, int stateMask) { // List members = new ArrayList(); // synchronized (lock) { // if ((stateMask & Job.RUNNING) != 0) { // for (Iterator it = running.iterator(); it.hasNext();) { // select(members, family, (InternalJob) it.next(), stateMask); // } // } // if ((stateMask & Job.WAITING) != 0) // select(members, family, waiting.peek(), stateMask); // if ((stateMask & Job.SLEEPING) != 0) // select(members, family, sleeping.peek(), stateMask); // } // return members; // } // dummy validateRule implemenation void JobManager::ValidateRule(ISchedulingRule::Pointer sptr_rule) { //null rule always valid if (sptr_rule == 0) return; //contains method must be reflexive poco_assert(sptr_rule->Contains(sptr_rule)) ; //contains method must return false when given an unknown rule poco_assert(!sptr_rule->Contains(sptr_testRule)); //isConflicting method must be reflexive poco_assert(sptr_rule->IsConflicting(sptr_rule)); //isConflicting method must return false when given an unknown rule poco_assert(!sptr_rule->IsConflicting(sptr_testRule)); } bool JobManager::Cancel(InternalJob::Pointer sptr_job) { IProgressMonitor::Pointer sptr_progressMonitor(0); bool runCanceling = false; { Poco::ScopedLock mangerMutex (m_mutex); switch (sptr_job->GetState()) { case Job::NONE : return true; case Job::RUNNING : //cannot cancel a job that has already started (as opposed to ABOUT_TO_RUN) if (sptr_job->InternalGetState() == Job::RUNNING) { sptr_progressMonitor = sptr_job->GetProgressMonitor(); runCanceling = sptr_job->IsRunCanceled(); if(runCanceling) sptr_job->SetRunCanceled(true); break ; } //signal that the job should be canceled before it gets a chance to run sptr_job->SetAboutToRunCanceled(true); return false; default : ChangeState(sptr_job, Job::NONE); } } //call monitor outside sync block if (sptr_progressMonitor != 0) { if(runCanceling) { if (!sptr_progressMonitor->IsCanceled()) sptr_progressMonitor->SetCanceled(true); sptr_job->Canceling(); } return false; } //only notify listeners if the job was waiting or sleeping m_JobListeners.Done(sptr_job.Cast(), Status::CANCEL_STATUS, false); return true; } IProgressMonitor::Pointer JobManager::CreateMonitor( Job::Pointer sptr_jobToMonitor) { IProgressMonitor::Pointer sptr_monitor(0); if (m_sptr_progressProvider != 0) sptr_monitor = m_sptr_progressProvider->CreateMonitor(sptr_jobToMonitor); if (sptr_monitor == 0) { NullProgressMonitor::Pointer sptr_defaultMonitor(new NullProgressMonitor()); return sptr_defaultMonitor; } return sptr_monitor ; } IProgressMonitor::Pointer JobManager::CreateMonitor(InternalJob::Pointer sptr_job, IProgressMonitor::Pointer group, int ticks) { { Poco::ScopedLock managerLock(m_mutex); //group must be set before the job is scheduled //this includes the ABOUT_TO_SCHEDULE state, during which it is still //valid to set the progress monitor if (sptr_job->GetState() != Job::NONE) { IProgressMonitor::Pointer dummy(0); return dummy; } IProgressMonitor::Pointer sptr_monitor(0); if (m_sptr_progressProvider != 0) sptr_monitor = m_sptr_progressProvider->CreateMonitor(sptr_job.Cast() , group, ticks); if (sptr_monitor == 0) { // return a default NullprogressMonitor NullProgressMonitor::Pointer sptr_defaultMonitor(new NullProgressMonitor() ); return sptr_defaultMonitor; } return sptr_monitor; } } void JobManager::EndJob(InternalJob::Pointer ptr_job, IStatus::Pointer result, bool notify) { Poco::Timestamp::TimeDiff rescheduleDelay(InternalJob::T_NONE); { Poco::ScopedLock lock ( m_mutex); // if the job is finishing asynchronously, there is nothing more to do for now if (result == Job::ASYNC_FINISH) return; //if job is not known then it cannot be done if (ptr_job->GetState() == Job::NONE) return; ptr_job->SetResult(result); ptr_job->SetProgressMonitor(IProgressMonitor::Pointer(0)); ptr_job->SetThread(0); rescheduleDelay = ptr_job->GetStartTime().epochMicroseconds(); InternalJob::Pointer sptr_job(ptr_job); ChangeState(sptr_job, Job::NONE); } //notify listeners outside sync block bool reschedule = m_active && rescheduleDelay > InternalJob::T_NONE && ptr_job->ShouldSchedule(); if (notify) m_JobListeners.Done(ptr_job.Cast(), result, reschedule); //reschedule the job if requested and we are still active if (reschedule) Schedule(ptr_job, rescheduleDelay, reschedule); } InternalJob::Pointer JobManager::FindBlockingJob(InternalJob::Pointer waitingJob) { if (waitingJob->GetRule() == 0) return InternalJob::Pointer(0); { Poco::ScopedLock managerLock (m_mutex); if (m_running.empty() ) { InternalJob::Pointer dummy; return (dummy); } //check the running jobs bool hasBlockedJobs = false; Poco::HashSet::Iterator it; for ( it = m_running.begin(); it != m_running.end(); it ++ ) { InternalJob::Pointer sptr_job = *it ++; if (waitingJob->IsConflicting(sptr_job)) return sptr_job; if (!hasBlockedJobs) hasBlockedJobs = sptr_job->Previous() != 0; } // there are no blocked jobs, so we are done if (!hasBlockedJobs) { InternalJob::Pointer dummy; return (dummy); } //check all jobs blocked by running jobs Poco::HashSet::Iterator it_blocked; for( it_blocked = m_running.begin(); it_blocked != m_running.end(); it_blocked ++ ) { InternalJob::Pointer sptr_job = *it_blocked ++; while (true) { sptr_job = sptr_job->Previous(); if (sptr_job == 0) break; if (waitingJob->IsConflicting(sptr_job)) return sptr_job; } } } InternalJob::Pointer sptr_null; return (sptr_null); } bool JobManager::IsActive() { return m_active; } bool JobManager::IsBlocking(InternalJob::Pointer sptr_runningJob) { { Poco::ScopedLock lockMe (m_mutex); // if this job isn't running, it can't be blocking anyone if (sptr_runningJob->GetState() != Job::RUNNING) return false; // if any job is queued behind this one, it is blocked by it InternalJob::Pointer ptr_previous = sptr_runningJob->Previous(); while (ptr_previous != 0) { // ignore jobs of lower priority (higher priority value means lower priority) if (ptr_previous->GetPriority() < sptr_runningJob->GetPriority()) { if (!ptr_previous->IsSystem()) return true; // TODO Implicit Jobs // implicit jobs should interrupt unless they act on behalf of system jobs // if (previous instanceof ThreadJob && ((ThreadJob) previous).shouldInterrupt()) // return true; } ptr_previous = ptr_previous->previous; } // none found return false; } } //void //JobManager //::Join(InternalJob job) { // final IJobChangeListener listener; // final Semaphore barrier; // synchronized (lock) { // int state = job.getState(); // if (state == Job.NONE) // return; // //don't join a waiting or sleeping job when suspended (deadlock risk) // if (suspended && state != Job.RUNNING) // return; // //it's an error for a job to join itself // if (state == Job.RUNNING && job.getThread() == Thread.currentThread()) // throw new IllegalStateException("Job attempted to join itself"); //$NON-NLS-1$ // //the semaphore will be released when the job is done // barrier = new Semaphore(null); // listener = new JobChangeAdapter() { // public void done(IJobChangeEvent event) { // barrier.release(); // } // }; // job.addJobChangeListener(listener); // //compute set of all jobs that must run before this one // //add a listener that removes jobs from the blocking set when they finish // } // //wait until listener notifies this thread. // try { // while (true) { // //notify hook to service pending syncExecs before falling asleep // lockManager.aboutToWait(job.getThread()); // try { // if (barrier.acquire(Long.MAX_VALUE)) // break; // } catch (InterruptedException e) { // //loop and keep trying // } // } // } finally { // lockManager.aboutToRelease(); // job.removeJobChangeListener(listener); // } // } bool JobManager::RunNow(InternalJob::Pointer sptr_job) { { Poco::ScopedLock lockMe (m_mutex); //cannot start if there is a conflicting job if (FindBlockingJob(sptr_job) != 0) return false; ChangeState(sptr_job, Job::RUNNING); sptr_job->SetProgressMonitor(IProgressMonitor::Pointer(new NullProgressMonitor())); sptr_job->Run(IProgressMonitor::Pointer(0)); } return true; } void JobManager::Schedule(InternalJob::Pointer job, Poco::Timestamp::TimeDiff delay, bool reschedule) { if (!m_active) throw Poco::IllegalStateException("Job manager has been shut down."); poco_assert(job); // "Job is null" poco_assert(delay >= 0); // "Scheduling delay is negative" { Poco::ScopedLock managerLock (m_mutex); //if the job is already running, set it to be rescheduled when done if (job->GetState() == Job::RUNNING) { job->SetStartTime(delay); return; } //can't schedule a job that is waiting or sleeping if (job->InternalGetState() != Job::NONE) return; //remember that we are about to schedule the job //to prevent multiple schedule attempts from succeeding (bug 68452) InternalJob::Pointer sptr_job(job); ChangeState(sptr_job, InternalJob::ABOUT_TO_SCHEDULE); } //notify listeners outside sync block m_JobListeners.Scheduled(job.Cast(), delay, reschedule); //schedule the job DoSchedule(job, delay); //call the pool outside sync block to avoid deadlock m_Pool->JobQueued(); } bool JobManager::Sleep(InternalJob::Pointer job) { { Poco::ScopedLock lockMe (m_mutex); InternalJob::Pointer sptr_job(job); switch (job->GetState()) { case Job::RUNNING : //cannot be paused if it is already running (as opposed to ABOUT_TO_RUN) if (job->InternalGetState() == Job::RUNNING) return false; //job hasn't started running yet (aboutToRun listener) break; case Job::SLEEPING : //update the job wake time job->SetStartTime(InternalJob::T_INFINITE); //change state again to re-shuffle the sleep queue ChangeState(sptr_job, Job::SLEEPING); return true; case Job::NONE : return true; case Job::WAITING : //put the job to sleep break; } job->SetStartTime(InternalJob::T_INFINITE); ChangeState(sptr_job, Job::SLEEPING); } m_JobListeners.Sleeping(job.Cast()); return true; } void JobManager::SetPriority(InternalJob::Pointer job, int newPriority) { { Poco::ScopedLock lockMe (m_mutex); InternalJob::Pointer sptr_job(job); int oldPriority = job->GetPriority(); if (oldPriority == newPriority) return; job->InternalSetPriority(newPriority); //if the job is waiting to run, re-shuffle the queue if (sptr_job->GetState() == Job::WAITING) { Poco::Timestamp oldStart = job->GetStartTime(); job->SetStartTime(oldStart += (DelayFor(newPriority) - DelayFor(oldPriority))); m_JobQueueWaiting.Resort(job); } } } Poco::Timespan::TimeDiff JobManager::SleepHint() { Poco::ScopedLock managerLock (m_mutex); // wait forever if job manager is suspended if (m_suspended) return InternalJob::T_INFINITE; if (!m_JobQueueWaiting.IsEmpty()) return 0; // return the anticipated time that the next sleeping job will wake InternalJob::Pointer ptr_next(0); ptr_next = m_JobQueueSleeping.Peek(); if (ptr_next == 0) return InternalJob::T_INFINITE; Poco::Timestamp tmp_startTime = ptr_next->GetStartTime(); Poco::Timestamp tmp_currentTime; Poco::Timestamp::TimeDiff timeToStart = tmp_startTime - tmp_currentTime; return timeToStart; } Job::Pointer JobManager::StartJob() { Job::Pointer job(0); while (true) { job = NextJob(); if (!job) return Job::Pointer(0); //must perform this outside sync block because it is third party code bool shouldRun = job->ShouldRun(); //check for listener veto if (shouldRun) m_JobListeners.AboutToRun(job); //listeners may have canceled or put the job to sleep bool endJob = false; { Poco::ScopedLock lock(m_mutex); InternalJob::Pointer internal = job; if (internal->InternalGetState() == InternalJob::ABOUT_TO_RUN) { if (shouldRun && !internal->IsAboutToRunCanceled()) { internal->SetProgressMonitor(CreateMonitor(job)); //change from ABOUT_TO_RUN to RUNNING internal->InternalSetState(Job::RUNNING); break; } internal->SetAboutToRunCanceled(false); endJob = true; //fall through and end the job below } } if (endJob) { //job has been vetoed or canceled, so mark it as done EndJob(job,Status::CANCEL_STATUS, true); continue; } } m_JobListeners.Running(job); return job; } void JobManager::WakeUp(InternalJob::Pointer job, Poco::Timestamp::TimeDiff delay) { poco_assert(delay >= 0); // "Scheduling delay is negative" { Poco::ScopedLock m_managerLock (m_mutex); //cannot wake up if it is not sleeping if (job->GetState() != Job::SLEEPING) return; DoSchedule(job, delay); } //call the pool outside sync block to avoid deadlock m_Pool->JobQueued(); /// IListenerExtension only notify of wake up if immediate if (delay == 0) m_JobListeners.Awake(job.Cast()); } IProgressMonitor::Pointer JobManager::MonitorFor(IProgressMonitor::Pointer sptr_monitor) { if(sptr_monitor == 0 || sptr_monitor.Cast() ) { if(m_sptr_progressProvider != 0 ) sptr_monitor = m_sptr_progressProvider->GetDefaultMonitor(); } if(sptr_monitor == 0) { IProgressMonitor::Pointer sptr_nullProgressMonitor(new NullProgressMonitor()); return sptr_nullProgressMonitor; } return sptr_monitor; } } diff --git a/BlueBerry/Bundles/org.blueberry.core.jobs/src/internal/berryJobManager.h b/BlueBerry/Bundles/org.blueberry.core.jobs/src/internal/berryJobManager.h index 9a69fafbbb..5a00dbf42d 100644 --- a/BlueBerry/Bundles/org.blueberry.core.jobs/src/internal/berryJobManager.h +++ b/BlueBerry/Bundles/org.blueberry.core.jobs/src/internal/berryJobManager.h @@ -1,435 +1,435 @@ //*========================================================================= // // Program: BlueBerry Platform // Language: C++ // Date: $Date$ // Version: $Revision$ // // Copyright (c) German Cancer Research Center, Division of Medical and // Biological Informatics. All rights reserved. // See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. // // This software is distributed WITHOUT ANY WARRANTY; without even // the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // PURPOSE. See the above copyright notices for more information. // // =========================================================================*/ // // #ifndef _BERRY_JOBMANAGER_H #define _BERRY_JOBMANAGER_H #include "berryInternalJob.h" #include "berryJobQueue.h" #include "berryWorkerPool.h" #include "berryJobListeners.h" #include "../berryJob.h" #include "../berryIProgressMonitorWithBlocking.h" #include "../berryIJobManager.h" #include "../berryISchedulingRule.h" -#include "../berryJobsDll.h" +#include #include #include #include #include #include #include #include #include namespace berry { /** * Implementation of API type IJobManager * * Implementation note: all the data structures of this class are protected * by a single lock object held as a private field in this class. The JobManager * instance itself is not used because this class is publicly reachable, and third * party clients may try to synchronize on it. * * The WorkerPool class uses its own monitor for synchronizing its data * structures. To avoid deadlock between the two classes, the JobManager * must NEVER call the worker pool while its own monitor is held. */ struct BERRY_JOBS JobManager: public IJobManager { public: friend class WorkerPool; friend struct InternalJob; friend struct NullRule; berryObjectMacro(JobManager) /** * The unique identifier constant of this plug-in. */ - static const std::string PI_JOBS; + static const std::string& PI_JOBS(); static bool DEBUG; static bool DEBUG_BEGIN_END; static bool DEBUG_DEADLOCK; static bool DEBUG_LOCKS; static bool DEBUG_TIMING; static bool DEBUG_SHUTDOWN; /** * Status code constant indicating an error occurred while running a plug-in. * For backward compatibility with Platform.PLUGIN_ERROR left at (value = 2). */ static const int PLUGIN_ERROR; /// const ImplicitJobs iImplicitJobs = new ImplicitJobs(this); /** * The singleton job manager instance. It must be a singleton because * all job instances maintain a reference (as an optimization) and have no way * of updating it. */ static JobManager* GetInstance(); /** * For debugging purposes only */ static std::string PrintState(int state); /** * Note that although this method is not API, clients have historically used * it to force jobs shutdown in cases where OSGi shutdown does not occur. * For this reason, this method should be considered near-API and should not * be changed if at all possible. */ static void Shutdown(); // void Cancel(Object family) ; IProgressMonitor::Pointer CreateProgressGroup(); Job* CurrentJob(); // void EndRule(ISchedulingRule rule) ; // Job[] Find(Object family) ; // LockManager GetLockManager() { // return lockManager; // } bool IsIdle(); bool IsSuspended(); // void Join(final Object family, IProgressMonitor monitor) throws InterruptedException, OperationCanceledException ); // ILock NewLock() ; /** * @see IJobManager#RemoveChangeListener(IJobChangeListener::Pointer) */ void RemoveJobChangeListener(IJobChangeListener::Pointer listener); // /** //* report to the progress monitor that this thread is blocked, supplying //* an information message, and if possible the job that is causing the blockage. //* important: an invocation of this method must be followed eventually be //* an invocation of ReportUnblocked. //* @param monitor the monitor to report blocking to //* @param BlockingJob the job that is blocking this thread, or null //* @see #Reportunblocked //*/ void ReportBlocked( IProgressMonitor::Pointer monitor, InternalJob::Pointer blockingjob) const ; /** * Reports that this thread was blocked, but is no longer blocked and is able * to proceed. * @param monitor The monitor to report unblocking to. * @see #ReportBlocked */ void ReportUnblocked(IProgressMonitor::Pointer monitor) const ; /** * @have a look at IJobManager Resume */ void Resume(); // /** // * @have a look at IJobManager Resume // */ // void Resume(ISchedulingRule::Pointer rule)const ; /** * @have a look at IJobManager SetProgressProvider */ void SetProgressProvider(ProgressProvider::Pointer provider); void SetRule(InternalJob::Pointer job, ISchedulingRule::Pointer rule); // /* // * @see IJobManager#sleep(std::string) // */ // void Sleep(Object family) ; void Suspend(); /* * @see schedule(long) */ void Schedule(InternalJob::Pointer job, Poco::Timestamp::TimeDiff delay, bool reschedule); // void Suspend(ISchedulingRule::Pointer rule, IProgressMonitor::Pointer monitor)const ; // void TransferRule(ISchedulingRule rule, Thread destinationThread) ; // void SetLockListener(LockListener listener) ; // /** // * Puts a job to sleep. Returns true if the job was successfully put to sleep. // */ // void WakeUp(Object family) ; void AddJobChangeListener(IJobChangeListener::Pointer listener); // void beginRule(ISchedulingRule rule, IProgressMonitor monitor) ; protected: /** * Cancels a job */ bool Cancel(InternalJob::Pointer job); /** * Returns a new progress monitor for this job, belonging to the given * progress group. Returns null if it is not a valid time to set the job's group. */ IProgressMonitor::Pointer CreateMonitor(InternalJob::Pointer job, IProgressMonitor::Pointer group, int ticks); /** * Indicates that a job was running, and has now finished. Note that this method * can be called under OutOfMemoryError conditions and thus must be paranoid * about allocating objects. */ /// optional Extension IStatus for implementation help have a look at the Java JobAPI void EndJob(InternalJob::Pointer job,IStatus::Pointer result, bool notify); /** * Returns a running or blocked job whose scheduling rule conflicts with the * scheduling rule of the given waiting job. Returns null if there are no * conflicting jobs. A job can only run if there are no running jobs and no blocked * jobs whose scheduling rule conflicts with its rule. */ InternalJob::Pointer FindBlockingJob(InternalJob::Pointer waitingJob); /** * Returns whether the job manager is active (has not been shutdown). */ bool IsActive(); /** * Returns true if the given job is blocking the execution of a non-system * job. */ bool IsBlocking(InternalJob::Pointer runningJob); // void Join(InternalJob job) ; /** * Attempts to immediately start a given job. Returns true if the job was * successfully started, and false if it could not be started immediately * due to a currently running job with a conflicting rule. Listeners will never * be notified of jobs that are run in this way. */ bool RunNow(InternalJob::Pointer sptr_job); /** * Puts a job to sleep. Returns true if the job was successfully put to sleep. */ bool Sleep(InternalJob::Pointer job); /** * Changes a job priority. */ void SetPriority(InternalJob::Pointer job, int newPriority); /** * Returns the estimated time in milliseconds before the next job is scheduled * to wake up. The result may be negative. Returns InternalJob.T_INFINITE if * there are no sleeping or waiting jobs. */ Poco::Timespan::TimeDiff SleepHint(); /** * Returns the next job to be run, or null if no jobs are waiting to run. * The worker must call endJob when the job is finished running. */ Job::Pointer StartJob(); /* * @see Job#WakeUp(long) */ void WakeUp(InternalJob::Pointer job, Poco::Timestamp::TimeDiff delay); private: JobManager(); /* Poco Mutex for synchronizing purposes */ Poco::Mutex m_mutex; // Dummy Null rule to validate SchedulingRules implemented by clients SmartPointer sptr_testRule; // //ToDO static const ISchedulingRule nullRule = new ISchedulingRule() { // public bool Contains(ISchedulingRule rule) ; // public boolean IsConflicting(ISchedulingRule rule) ; /** * True if this manager is active, and false otherwise. A job manager * starts out active, and becomes inactive if it has been shutdown * and not restarted. */ volatile bool m_active; JobListeners m_JobListeners; // // /** // * The lock for synchronizing all activity in the job manager. To avoid deadlock, // * this lock must never be held for extended periods, and must never be // * held while third party code is being called. // */ // // private final Object lock = new Object(); // static const Object lock ; // // //private LockManager lockManager = new LockManager(); // static const LockManger lockManager; /** * The pool of worker threads. */ WorkerPool::Pointer m_Pool; ProgressProvider::Pointer m_sptr_progressProvider; /** * Jobs that are currently running. Should only be modified from changeState */ Poco::HashSet m_running; /** * Jobs that are sleeping. Some sleeping jobs are scheduled to wake * up at a given start time, while others will sleep indefinitely until woken. * Should only be modified from changeState */ JobQueue m_JobQueueSleeping; /** * jobs that are waiting to be run. Should only be modified from changeState */ JobQueue m_JobQueueWaiting; /** * True if this manager has been suspended, and false otherwise. A job manager * starts out not suspended, and becomes suspended when suspend * is invoked. Once suspended, no jobs will start running until resume * is cancelled. */ bool m_suspended; /** * Counter to record wait queue insertion order. */ long long m_waitQueueCounter; // /** // * For debugging purposes only // */ // const std::string PrintJobName(Job job); /** * Atomically updates the state of a job, adding or removing from the * necessary queues or sets. */ void ChangeState(InternalJob::Pointer job, int newState); /** * Returns a new progress monitor for this job. Never returns null. */ IProgressMonitor::Pointer CreateMonitor(Job::Pointer sptr_jobToMonitor); /** * Returns the delay in milliseconds that a job with a given priority can * tolerate waiting. */ Poco::Timestamp::TimeDiff DelayFor(int priority); /** * Performs the scheduling of a job. Does not perform any notifications. */ void DoSchedule(InternalJob::Pointer job, Poco::Timestamp::TimeDiff delay); /** * Shuts down the job manager. Currently running jobs will be told * to stop, but worker threads may still continue processing. * (note: This implemented IJobManager.Shutdown which was removed * due to problems caused by premature shutdown) */ void DoShutdown(); // void InitDebugOptions() ; /** * Removes and returns the first waiting job in the queue. Returns null if there * are no items waiting in the queue. If an item is removed from the queue, * it is moved to the running jobs list. */ Job::Pointer NextJob(); /** * Returns a non-null progress monitor instance. If the monitor is null, * returns the default monitor supplied by the progress provider, or a * NullProgressMonitor if no default monitor is available. */ IProgressMonitor::Pointer MonitorFor(IProgressMonitor::Pointer monitor); // /** // * Adds all family members in the list of jobs to the collection // */ // void Select(List members, Object family, InternalJob firstJob, int stateMask) ; // // /** // * Returns a list of all jobs known to the job manager that belong to the given family. // */ // List Select(Object family) ; // // /** // * Returns a list of all jobs known to the job manager that belong to the given // * family and are in one of the provided states. // */ // List Select(Object family, int stateMask) ; /** * Validates that the given scheduling rule obeys the constraints of * scheduling rules as described in the ISchedulingRule */ void ValidateRule(ISchedulingRule::Pointer rule); }; } #endif /* _BERRY_TEMPLATE_H */ diff --git a/BlueBerry/Bundles/org.blueberry.core.jobs/src/internal/berryJobQueue.h b/BlueBerry/Bundles/org.blueberry.core.jobs/src/internal/berryJobQueue.h index 7e621bde58..7013fa3444 100644 --- a/BlueBerry/Bundles/org.blueberry.core.jobs/src/internal/berryJobQueue.h +++ b/BlueBerry/Bundles/org.blueberry.core.jobs/src/internal/berryJobQueue.h @@ -1,107 +1,107 @@ /*========================================================================= Program: BlueBerry Platform Language: C++ Date: $Date$ Version: $Revision$ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #ifndef _BERRY_JOBQUEUE_H #define _BERRY_JOBQUEUE_H #include "berryInternalJob.h" #include "../berryJob.h" #include -#include "../berryJobsDll.h" +#include namespace berry { /** * A linked list based priority queue. Either the elements in the queue must * implement Comparable, or a Comparator must be provided. */ struct BERRY_JOBS JobQueue: public Object { private: /** * The dummy entry sits between the head and the tail of the queue. * dummy.previous() is the head, and dummy.next() is the tail. */ InternalJob::Pointer dummy; /** * If true, conflicting jobs will be allowed to overtake others in the * queue that have lower priority. If false, higher priority jumps can only * move up the queue by overtaking jobs that they don't conflict with. */ bool m_allowConflictOvertaking; /** * Returns whether the new entry to overtake the existing queue entry. * @param newEntry The entry to be added to the queue * @param queueEntry The existing queue entry */ bool CanOvertake(InternalJob::Pointer newEntry, InternalJob::Pointer queueEntry); public: /** * Create a new job queue. */ JobQueue(bool m_allowConflictOvertaking); /** * remove all elements */ void Clear(); /** * Return and remove the element with highest priority, or null if empty. */ InternalJob::Pointer Dequeue(); /** * Adds an item to the queue */ void Enqueue(InternalJob::Pointer newEntry); /** * Removes the given element from the queue. */ void Remove(InternalJob::Pointer jobToRemove); /** * The given object has changed priority. Reshuffle the heap until it is * valid. */ void Resort(InternalJob::Pointer entry); /** * Returns true if the queue is empty, and false otherwise. */ bool IsEmpty(); /** * Return greatest element without removing it, or null if empty */ InternalJob::Pointer Peek(); }; } #endif /* _BERRY_JOBQUEUE_H */ diff --git a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryQtDnDTweaklet.h b/BlueBerry/Bundles/org.blueberry.core.jobs/src/internal/berryPluginActivator.cpp old mode 100755 new mode 100644 similarity index 62% copy from BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryQtDnDTweaklet.h copy to BlueBerry/Bundles/org.blueberry.core.jobs/src/internal/berryPluginActivator.cpp index d4ba28a835..4fe8f4c8c9 --- a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryQtDnDTweaklet.h +++ b/BlueBerry/Bundles/org.blueberry.core.jobs/src/internal/berryPluginActivator.cpp @@ -1,35 +1,41 @@ /*========================================================================= Program: BlueBerry Platform Language: C++ Date: $Date$ Version: $Revision$ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ -#ifndef BERRYQTDNDTWEAKLET_H_ -#define BERRYQTDNDTWEAKLET_H_ +#include "berryPluginActivator.h" -#include +#include namespace berry { -class QtDnDTweaklet : public DnDTweaklet +org_blueberry_core_jobs_Activator::org_blueberry_core_jobs_Activator() { -public: +} + +void org_blueberry_core_jobs_Activator::start(ctkPluginContext* context) +{ + Q_UNUSED(context) +} - ITracker* CreateTracker(); -}; +void org_blueberry_core_jobs_Activator::stop(ctkPluginContext* context) +{ + Q_UNUSED(context) +} } -#endif /* BERRYQTDNDTWEAKLET_H_ */ +Q_EXPORT_PLUGIN2(org_blueberry_core_jobs, berry::org_blueberry_core_jobs_Activator) diff --git a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryQtDnDTweaklet.h b/BlueBerry/Bundles/org.blueberry.core.jobs/src/internal/berryPluginActivator.h old mode 100755 new mode 100644 similarity index 60% copy from BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryQtDnDTweaklet.h copy to BlueBerry/Bundles/org.blueberry.core.jobs/src/internal/berryPluginActivator.h index d4ba28a835..7b5a2aa4d9 --- a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryQtDnDTweaklet.h +++ b/BlueBerry/Bundles/org.blueberry.core.jobs/src/internal/berryPluginActivator.h @@ -1,35 +1,43 @@ /*========================================================================= Program: BlueBerry Platform Language: C++ Date: $Date$ Version: $Revision$ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ -#ifndef BERRYQTDNDTWEAKLET_H_ -#define BERRYQTDNDTWEAKLET_H_ +#ifndef BERRYPLUGINACTIVATOR_H +#define BERRYPLUGINACTIVATOR_H -#include +#include namespace berry { -class QtDnDTweaklet : public DnDTweaklet +class org_blueberry_core_jobs_Activator : + public QObject, public ctkPluginActivator { + Q_OBJECT + Q_INTERFACES(ctkPluginActivator) + public: + org_blueberry_core_jobs_Activator(); - ITracker* CreateTracker(); + void start(ctkPluginContext* context); + void stop(ctkPluginContext* context); }; +typedef org_blueberry_core_jobs_Activator PluginActivator; + } -#endif /* BERRYQTDNDTWEAKLET_H_ */ +#endif // BERRYPLUGINACTIVATOR_H diff --git a/BlueBerry/Bundles/org.blueberry.core.jobs/src/internal/berryWorker.cpp b/BlueBerry/Bundles/org.blueberry.core.jobs/src/internal/berryWorker.cpp index cc24718d58..02b215d4cc 100644 --- a/BlueBerry/Bundles/org.blueberry.core.jobs/src/internal/berryWorker.cpp +++ b/BlueBerry/Bundles/org.blueberry.core.jobs/src/internal/berryWorker.cpp @@ -1,139 +1,139 @@ /*========================================================================= Program: BlueBerry Platform Language: C++ Date: $Date$ Version: $Revision$ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #include "berryWorker.h" #include "berryWorkerPool.h" #include #include #include "berryJobManager.h" namespace berry { /************************* begin of nested JobRunnable class definition ****************************/ int Worker::m_nextWorkerNumber = 0; Worker::JobRunnable::JobRunnable(Worker* currentWorker) : ptr_currentWorker(currentWorker) { } // not a good implementation yet .. without the IStatus it can not be checked if a job has been // executed correctly void Worker::JobRunnable::run() { ptr_currentWorker->setPriority(PRIO_NORMAL); try { while ((ptr_currentWorker->ptr_currentJob = ptr_currentWorker->m_wpPool.Lock()->StartJob(ptr_currentWorker)) != 0) { IStatus::Pointer result = Status::OK_STATUS ; try { ptr_currentWorker->ptr_currentJob->SetThread(ptr_currentWorker); ptr_currentWorker->ptr_currentJob->Run(ptr_currentWorker->ptr_currentJob->GetProgressMonitor()); // java thread.interrupted throw FinallyThrowException(); } catch(FinallyThrowException) { RunMethodFinallyExecution(result); } // provided an unspecific exception handling, if specific exceptions are added within core job executing methods // the specific thrown exceptions should be handled below catch(...) { RunMethodFinallyExecution(result); } } throw FinallyThrowException(); } catch (FinallyThrowException&) { ptr_currentWorker->ptr_currentJob = 0; Worker::Pointer sptr_currentWorker(ptr_currentWorker); ptr_currentWorker->m_wpPool.Lock()->EndWorker(sptr_currentWorker); } catch (...) { ptr_currentWorker->ptr_currentJob = 0; Worker::Pointer sptr_currentWorker(ptr_currentWorker); ptr_currentWorker->m_wpPool.Lock()->EndWorker(sptr_currentWorker); } } void Worker::JobRunnable::RunMethodFinallyExecution(IStatus::Pointer sptr_result) { //clear interrupted state for this thread //Thread.interrupted(); //result must not be null if (sptr_result.IsNull()) { std::runtime_error tempError("NullPointerException") ; sptr_result = HandleException( ptr_currentWorker->ptr_currentJob, tempError ); } ptr_currentWorker->m_wpPool.Lock()->EndJob( ptr_currentWorker->ptr_currentJob, sptr_result ); if ((sptr_result->GetSeverity() & (IStatus::ERROR_TYPE | IStatus::WARNING_TYPE)) != 0) // TODO Logging RuntimeLog.log(result); std::cout << " Status after executing the job : " << sptr_result->ToString() ; ptr_currentWorker->ptr_currentJob = 0; //reset thread priority in case job changed it ptr_currentWorker->setPriority(PRIO_NORMAL); } IStatus::Pointer Worker::JobRunnable::HandleException(InternalJob::Pointer sptr_job, const std::exception& exception) { std::stringstream ss; ss << "An internal error occurred while executing the job: " << sptr_job->GetName() ; - IStatus::Pointer sptr_errorStatus(new Status(IStatus::ERROR_TYPE, JobManager::PI_JOBS, JobManager::PLUGIN_ERROR, ss.str(), exception) ) ; + IStatus::Pointer sptr_errorStatus(new Status(IStatus::ERROR_TYPE, JobManager::PI_JOBS(), JobManager::PLUGIN_ERROR, ss.str(), exception) ) ; return sptr_errorStatus ; } /************************* end of nested JobRunnable class definition ****************************/ Worker::Worker(WeakPointer myPool) : Poco::Thread("Worker-" + m_nextWorkerNumber++), m_Runnable(this), m_wpPool( myPool), ptr_currentJob(0) { } void Worker::Start() { Poco::Thread::start(m_Runnable); } } diff --git a/BlueBerry/Bundles/org.blueberry.core.jobs/src/internal/berryWorker.h b/BlueBerry/Bundles/org.blueberry.core.jobs/src/internal/berryWorker.h index e2d488689b..f2ffb2d1d9 100644 --- a/BlueBerry/Bundles/org.blueberry.core.jobs/src/internal/berryWorker.h +++ b/BlueBerry/Bundles/org.blueberry.core.jobs/src/internal/berryWorker.h @@ -1,95 +1,95 @@ /*========================================================================= Program: BlueBerry Platform Language: C++ Date: $Date$ Version: $Revision$ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #ifndef _BERRY_WORKER_H #define _BERRY_WORKER_H #include #include "berryObject.h" -#include "berryJobsDll.h" +#include #include #include #include "berryInternalJob.h" #include "berryIStatus.h" #include "berryStatus.h" namespace berry { class WorkerPool; /** * A worker thread processes jobs supplied to it by the worker pool. When * the worker pool gives it a null job, the worker dies. */ class BERRY_JOBS Worker: public Object, public Poco::Thread { public: berryObjectMacro(Worker) Worker(WeakPointer myPool); void Start(); private: /****************************** begin nested JobRunnable class ********************/ class JobRunnable: public Poco::Runnable { public: JobRunnable(Worker* currentWorker); void run(); // code that would be executed in java within a finally statement void RunMethodFinallyExecution(IStatus::Pointer sptr_result); IStatus::Pointer HandleException(InternalJob::Pointer sptr_pointer, const std::exception& exception); private: Worker* ptr_currentWorker; }; friend class JobRunnable; /***************************** end nested class JobRunnable *********************************/ private: Worker(const Self&); // worker number used for debugging purposes only static int m_nextWorkerNumber; JobRunnable m_Runnable; WeakPointer m_wpPool; InternalJob::Pointer ptr_currentJob; }; } #endif /* _BERRY_WORKER_H */ diff --git a/BlueBerry/Bundles/org.blueberry.core.runtime/CMakeLists.txt b/BlueBerry/Bundles/org.blueberry.core.runtime/CMakeLists.txt index cdf8bd4b1a..919335d647 100644 --- a/BlueBerry/Bundles/org.blueberry.core.runtime/CMakeLists.txt +++ b/BlueBerry/Bundles/org.blueberry.core.runtime/CMakeLists.txt @@ -1,3 +1,5 @@ +PROJECT(org_blueberry_core_runtime) -MACRO_CREATE_PLUGIN() +MACRO_CREATE_CTK_PLUGIN(EXPORT_DIRECTIVE BERRY_RUNTIME + EXPORTED_INCLUDE_SUFFIXES src) diff --git a/BlueBerry/Bundles/org.blueberry.core.runtime/META-INF/MANIFEST.MF b/BlueBerry/Bundles/org.blueberry.core.runtime/META-INF/MANIFEST.MF deleted file mode 100644 index e811b9adb8..0000000000 --- a/BlueBerry/Bundles/org.blueberry.core.runtime/META-INF/MANIFEST.MF +++ /dev/null @@ -1,8 +0,0 @@ -Manifest-Version: 1.0 -Bundle-Name: BlueBerry Core Runtime Plugin -Bundle-SymbolicName: org.blueberry.core.runtime -Bundle-Version: 1.0.0 -Bundle-Vendor: DKFZ, Medical and Biological Informatics -Bundle-Activator: berry::RuntimePlugin -Require-Bundle: org.blueberry.osgi -Bundle-ActivationPolicy: eager \ No newline at end of file diff --git a/BlueBerry/Bundles/org.blueberry.core.runtime/files.cmake b/BlueBerry/Bundles/org.blueberry.core.runtime/files.cmake index 4181d34394..a3453eeec4 100644 --- a/BlueBerry/Bundles/org.blueberry.core.runtime/files.cmake +++ b/BlueBerry/Bundles/org.blueberry.core.runtime/files.cmake @@ -1,26 +1,32 @@ +SET(MOC_H_FILES + src/internal/berryPluginActivator.h + src/internal/berryPreferencesService.h +) + SET(SRC_CPP_FILES berryIAdaptable.cpp berryIAdapterManager.cpp berryIPreferencesService.cpp berryPlatformObject.cpp berryRuntime.cpp berryRuntimePlugin.cpp berryBackingStoreException.cpp ) SET(INTERNAL_CPP_FILES - berryPreferencesService.cpp - berryAbstractPreferencesStorage.cpp + berryAbstractPreferencesStorage.cpp + berryPluginActivator.cpp berryPreferences.cpp + berryPreferencesService.cpp berryXMLPreferencesStorage.cpp ) -SET(CPP_FILES manifest.cpp) +SET(CPP_FILES ) foreach(file ${SRC_CPP_FILES}) SET(CPP_FILES ${CPP_FILES} src/${file}) endforeach(file ${SRC_CPP_FILES}) foreach(file ${INTERNAL_CPP_FILES}) SET(CPP_FILES ${CPP_FILES} src/internal/${file}) endforeach(file ${INTERNAL_CPP_FILES}) diff --git a/BlueBerry/Bundles/org.blueberry.core.runtime/manifest.cpp b/BlueBerry/Bundles/org.blueberry.core.runtime/manifest.cpp deleted file mode 100644 index ff7dd9266d..0000000000 --- a/BlueBerry/Bundles/org.blueberry.core.runtime/manifest.cpp +++ /dev/null @@ -1,25 +0,0 @@ -/*========================================================================= - -Program: BlueBerry Platform -Language: C++ -Date: $Date$ -Version: $Revision$ - -Copyright (c) German Cancer Research Center, Division of Medical and -Biological Informatics. All rights reserved. -See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. - -This software is distributed WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. See the above copyright notices for more information. - -=========================================================================*/ - -#include "Poco/ClassLibrary.h" - -#include -#include "src/berryRuntimePlugin.h" - -POCO_BEGIN_MANIFEST(berry::IBundleActivator) - POCO_EXPORT_CLASS(berry::RuntimePlugin) -POCO_END_MANIFEST diff --git a/BlueBerry/Bundles/org.blueberry.core.runtime/manifest_headers.cmake b/BlueBerry/Bundles/org.blueberry.core.runtime/manifest_headers.cmake new file mode 100644 index 0000000000..9fae8b61b4 --- /dev/null +++ b/BlueBerry/Bundles/org.blueberry.core.runtime/manifest_headers.cmake @@ -0,0 +1,7 @@ +set(Plugin-Name "BlueBerry Core Runtime Plugin") +set(Plugin-Version "1.0.0") +set(Plugin-Vendor "DKFZ, Medical and Biological Informatics") +set(Plugin-ContactAddress "http://www.mitk.org") +set(Plugin-ActivationPolicy "eager") +set(Require-Plugin org.blueberry.osgi) + diff --git a/BlueBerry/Bundles/org.blueberry.core.runtime/src/berryBackingStoreException.h b/BlueBerry/Bundles/org.blueberry.core.runtime/src/berryBackingStoreException.h index 85a9815a27..054ae9460b 100644 --- a/BlueBerry/Bundles/org.blueberry.core.runtime/src/berryBackingStoreException.h +++ b/BlueBerry/Bundles/org.blueberry.core.runtime/src/berryBackingStoreException.h @@ -1,18 +1,18 @@ #ifndef BERRYBACKINGSTOREEXCEPTION_H_ #define BERRYBACKINGSTOREEXCEPTION_H_ -#include "berryRuntimeDll.h" +#include #include namespace berry { /** * Thrown to indicate that a preferences operation could not complete because of * a failure in the backing store, or a failure to contact the backing store. * * @version $Revision$ */ POCO_DECLARE_EXCEPTION(BERRY_RUNTIME, BackingStoreException, Poco::RuntimeException); } #endif /* BERRYBACKINGSTOREEXCEPTION_H_ */ \ No newline at end of file diff --git a/BlueBerry/Bundles/org.blueberry.core.runtime/src/berryIAdaptable.h b/BlueBerry/Bundles/org.blueberry.core.runtime/src/berryIAdaptable.h index 493624ec74..d26f332dec 100644 --- a/BlueBerry/Bundles/org.blueberry.core.runtime/src/berryIAdaptable.h +++ b/BlueBerry/Bundles/org.blueberry.core.runtime/src/berryIAdaptable.h @@ -1,78 +1,78 @@ /*========================================================================= Program: BlueBerry Platform Language: C++ Date: $Date$ Version: $Revision$ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #ifndef _BERRY_IADAPTABLE_H_ #define _BERRY_IADAPTABLE_H_ -#include "berryRuntimeDll.h" +#include #include #include #include namespace berry { /** * An interface for an adaptable object. *

* Adaptable objects can be dynamically extended to provide different * interfaces (or "adapters"). Adapters are created by adapter * factories, which are in turn managed by type by adapter managers. *

* For example, *
  *     IAdaptable a = [some adaptable];
  *     IFoo x = (IFoo)a.getAdapter(IFoo.class);
  *     if (x != null)
  *         [do IFoo things with x]
  * 
*

* This interface can be used without OSGi running. *

* Clients may implement this interface, or obtain a default implementation * of this interface by subclassing PlatformObject. *

* @see IAdapterFactory * @see IAdapterManager * @see PlatformObject */ struct BERRY_RUNTIME IAdaptable { public: berryNameMacro(berry::IAdaptable) /** * Returns an object which is an instance of the given class * associated with this object. Returns null if * no such object can be found. * * @param adapterType the adapter class to look up * @return a object castable to the given class, * or null if this object does not * have an adapter for the given class */ virtual Poco::Any GetAdapter(const std::string& adapterType) = 0; virtual ~IAdaptable(); }; } // namespace berry #endif /*_BERRY_IADAPTABLE_H_*/ diff --git a/BlueBerry/Bundles/org.blueberry.core.runtime/src/berryIAdapterFactory.h b/BlueBerry/Bundles/org.blueberry.core.runtime/src/berryIAdapterFactory.h index 41ce40064b..6270c6da6f 100644 --- a/BlueBerry/Bundles/org.blueberry.core.runtime/src/berryIAdapterFactory.h +++ b/BlueBerry/Bundles/org.blueberry.core.runtime/src/berryIAdapterFactory.h @@ -1,92 +1,92 @@ /*========================================================================= Program: BlueBerry Platform Language: C++ Date: $Date$ Version: $Revision$ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #ifndef BERRYIADAPTERFACTORY_H_ #define BERRYIADAPTERFACTORY_H_ -#include "berryRuntimeDll.h" +#include #include #include namespace berry { /** * An adapter factory defines behavioral extensions for * one or more classes that implements the IAdaptable * interface. Adapter factories are registered with an * adapter manager. *

* This interface can be used without OSGi running. *

* Clients may implement this interface. *

* @see IAdapterManager * @see IAdaptable */ struct BERRY_RUNTIME IAdapterFactory { virtual ~IAdapterFactory() {}; /** * Returns an object which can be cast to the given adapter type and which is * associated with the given adaptable object. Returns 0 if * no such object can be found. * * A typical implementation would look like this: * * * void* GetAdapter(void* adaptableObject, const std::type_info& adaptableType, const std::string& adapterType) * { * if (Image* img = CastHelper(adaptableObject, adaptableType)) * { * if (adapterType == "berry::IResource") * { * return new IResource(img->GetPath()); * } * } * return 0; * } * * * @param adaptableObject the adaptable object being queried * (usually an instance of IAdaptable) * @param adaptableType the type information for the adaptable object * @param adapterType the type of adapter to look up * @return a object castable to the given adapter type, * or 0 if this adapter factory * does not have an adapter of the given type for the * given object */ virtual Object* GetAdapter(IAdaptable* adaptableObject, const std::string& adapterType) = 0; /** * Returns the collection of adapter types handled by this * factory. *

* This method is generally used by an adapter manager * to discover which adapter types are supported, in advance * of dispatching any actual getAdapter requests. *

* * @return the collection of adapter types */ virtual void GetAdapterList(std::vector& adapters) = 0; }; } #endif /*BERRYIADAPTERFACTORY_H_*/ diff --git a/BlueBerry/Bundles/org.blueberry.core.runtime/src/berryIAdapterManager.h b/BlueBerry/Bundles/org.blueberry.core.runtime/src/berryIAdapterManager.h index 0a21f00361..79ed09d08d 100644 --- a/BlueBerry/Bundles/org.blueberry.core.runtime/src/berryIAdapterManager.h +++ b/BlueBerry/Bundles/org.blueberry.core.runtime/src/berryIAdapterManager.h @@ -1,276 +1,279 @@ /*========================================================================= Program: BlueBerry Platform Language: C++ Date: $Date$ Version: $Revision$ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #ifndef BERRYIADAPTERMANAGER_H_ #define BERRYIADAPTERMANAGER_H_ #include -#include "berryRuntimeDll.h" +#include #include "berryPlatformObject.h" #include "berryIAdapterFactory.h" #include +#include #include namespace berry { /** * An adapter manager maintains a registry of adapter factories. Clients * directly invoke methods on an adapter manager to register and unregister * adapters. All adaptable objects (that is, objects that implement the IAdaptable * interface) tunnel IAdaptable.getAdapter invocations to their * adapter manager's IAdapterManger.getAdapter method. The * adapter manager then forwards this request unmodified to the IAdapterFactory.getAdapter * method on one of the registered adapter factories. *

* Adapter factories can be registered programmatically using the registerAdapters * method. Alternatively, they can be registered declaratively using the * org.blueberry.core.runtime.adapters extension point. Factories registered * with this extension point will not be able to provide adapters until their * corresponding plugin has been activated. *

* The following code snippet shows how one might register an adapter of type * com.example.acme.Sticky on resources in the workspace. *

* *

  *  IAdapterFactory pr = new IAdapterFactory() {
  *    public Class[] getAdapterList() {
  *      return new Class[] { com.example.acme.Sticky.class };
  *    }
  *    public Object getAdapter(Object adaptableObject, Class adapterType) {
  *      IResource res = (IResource) adaptableObject;
  *      QualifiedName key = new QualifiedName("com.example.acme", "sticky-note");
  *      try {
  *        com.example.acme.Sticky v = (com.example.acme.Sticky) res.getSessionProperty(key);
  *        if (v == null) {
  *          v = new com.example.acme.Sticky();
  *          res.setSessionProperty(key, v);
  *        }
  *      } catch (CoreException e) {
  *        // unable to access session property - ignore
  *      }
  *      return v;
  *    }
  *  }
  *  Platform.getAdapterManager().registerAdapters(pr, IResource.class);
  *   
* *

* This interface can be used without OSGi running. *

* This interface is not intended to be implemented by clients. *

* @see IAdaptable * @see IAdapterFactory */ struct BERRY_RUNTIME IAdapterManager: public Object { berryInterfaceMacro(IAdapterManager, berry) /** * This value can be returned to indicate that no applicable adapter factory * was found. * @since org.blueberry.equinox.common 3.3 */ static const int NONE; /** * This value can be returned to indicate that an adapter factory was found, * but has not been loaded. * @since org.blueberry.equinox.common 3.3 */ static const int NOT_LOADED; /** * This value can be returned to indicate that an adapter factory is loaded. * @since org.blueberry.equinox.common 3.3 */ static const int LOADED; /** * Returns the types that can be obtained by converting adaptableClass * via this manager. Converting means that subsequent calls to getAdapter() * or loadAdapter() could result in an adapted object. *

* Note that the returned types do not guarantee that * a subsequent call to getAdapter with the same type as an argument * will return a non-null result. If the factory's plug-in has not yet been * loaded, or if the factory itself returns null, then * getAdapter will still return null. *

* @param adaptableClass the adaptable class being queried * @return an array of type names that can be obtained by converting * adaptableClass via this manager. An empty array * is returned if there are none. * @since 3.1 */ virtual std::vector ComputeAdapterTypes( const std::type_info& adaptableClass) = 0; /** * Returns the class search order for a given class. The search order from a * class with the definition
* class X extends Y implements A, B
* is as follows: *
    *
  • the target's class: X *
  • X's superclasses in order to Object *
  • a breadth-first traversal of the target class's interfaces in the * order returned by getInterfaces (in the example, A and its * superinterfaces then B and its superinterfaces)
  • *
* * @param clazz the class for which to return the class order. * @return the class search order for the given class. The returned * search order will minimally contain the target class. * @since 3.1 */ //public Class[] computeClassOrder(Class clazz); /** * Returns a Poco::Any object which contains an instance of the given name associated * with the given adaptable. Returns an empty Poco::Any if no such object can * be found. *

* Note that this method will never cause plug-ins to be loaded. If the * only suitable factory is not yet loaded, this method will return an empty Poco::Any. * If activation of the plug-in providing the factory is required, use the * LoadAdapter method instead. * * @param adaptable the adaptable object being queried (usually an instance * of IAdaptable) * @param adapterTypeName the fully qualified name of the type of adapter to look up * @return a Poco::Any castable to the given adapter type, or empty * if the given adaptable object does not have an available adapter of the * given type */ template Poco::Any GetAdapter(A adaptable, const std::string& adapterTypeName) { return this->GetAdapter(Poco::Any(adaptable), adapterTypeName, false); } /** * Returns whether there is an adapter factory registered that may be able * to convert adaptable to an object of type adapterTypeName. *

* Note that a return value of true does not guarantee that * a subsequent call to GetAdapter with the same arguments * will return a non-empty result. If the factory's plug-in has not yet been * loaded, or if the factory itself returns nothing, then * GetAdapter will still return an empty Poco::Any. * * @param adaptable the adaptable object being queried (usually an instance * of IAdaptable) * @param adapterTypeName the fully qualified class name of an adapter to * look up * @return true if there is an adapter factory that claims * it can convert adaptable to an object of type adapterType, * and false otherwise. */ virtual bool HasAdapter(const std::string& adaptableType, const std::string& adapterType) = 0; /** * Returns a status of an adapter factory registered that may be able * to convert adaptable to an object of type adapterTypeName. *

* One of the following values can be returned:

    *
  • {@link berry::IAdapterManager::NONE} if no applicable adapter factory was found;
  • *
  • {@link berry::IAdapterManager::NOT_LOADED} if an adapter factory was found, but has not been loaded;
  • *
  • {@link berry::IAdapterManager::LOADED} if an adapter factory was found, and it is loaded.
  • *

* @param adaptable the adaptable object being queried (usually an instance * of IAdaptable) * @param adapterTypeName the fully qualified class name of an adapter to * look up * @return a status of the adapter */ virtual int QueryAdapter(const std::string& adaptableType, const std::string& adapterType) = 0; /** * Returns an object that is an instance of the given class name associated * with the given object. Returns an empty Poco::Any if no such object can * be found. *

* Note that unlike the GetAdapter methods, this method * will cause the plug-in that contributes the adapter factory to be loaded * if necessary. As such, this method should be used judiciously, in order * to avoid unnecessary plug-in activations. Most clients should avoid * activation by using GetAdapter instead. * * @param adaptable the adaptable object being queried (usually an instance * of IAdaptable) * @param adapterTypeName the fully qualified name of the type of adapter to look up * @return a Poco::Any castable to the given adapter type, or empty * if the given adaptable object does not have an available adapter of the * given type */ template Poco::Any LoadAdapter(A adaptable, const std::string& adapterTypeName) { return this->GetAdapter(Poco::Any(adaptable), adapterTypeName, true); } /** * Registers the given adapter factory as extending objects of the given * type. * * @param factory the adapter factory * @param adaptableTypeName the fully qualified typename being extended * @see #UnregisterAdapters(IAdapterFactory*) * @see #UnregisterAdapters(IAdapterFactory*, const std::adaptableTypeName&) */ virtual void RegisterAdapters(IAdapterFactory* factory, const std::string& adaptableTypeName) = 0; /** * Removes the given adapter factory completely from the list of registered * factories. Equivalent to calling UnregisterAdapters(IAdapterFactory*, const std::string&) * on all classes against which it had been explicitly registered. Does * nothing if the given factory is not currently registered. * * @param factory the adapter factory to remove * @see #RegisterAdapters(IAdapterFactory*, const std::string&) */ virtual void UnregisterAdapters(IAdapterFactory* factory) = 0; /** * Removes the given adapter factory from the list of factories registered * as extending the given class. Does nothing if the given factory and type * combination is not registered. * * @param factory the adapter factory to remove * @param adaptableTypeName one of the type names against which the given factory is * registered * @see #RegisterAdapters(IAdapterFactory*, const std::string&) */ virtual void UnregisterAdapters(IAdapterFactory* factory, const std::string& adaptableTypeName) = 0; protected: virtual Poco::Any GetAdapter(Poco::Any adaptable, const std::string& adapterType, bool force) = 0; }; } // namespace berry +Q_DECLARE_INTERFACE(berry::IAdapterManager, "org.blueberry.service.IAdapterManager") + #endif /*BERRYIADAPTERMANAGER_H_*/ diff --git a/BlueBerry/Bundles/org.blueberry.core.runtime/src/berryIBerryPreferences.h b/BlueBerry/Bundles/org.blueberry.core.runtime/src/berryIBerryPreferences.h index dc927e3912..7456fbe6d4 100644 --- a/BlueBerry/Bundles/org.blueberry.core.runtime/src/berryIBerryPreferences.h +++ b/BlueBerry/Bundles/org.blueberry.core.runtime/src/berryIBerryPreferences.h @@ -1,33 +1,33 @@ #ifndef BERRYIBERRYPREFERENCES_H_ #define BERRYIBERRYPREFERENCES_H_ -#include "berryRuntimeDll.h" +#include #include "berryIPreferences.h" #include "berryMessage.h" #include #include #include namespace berry { /// /// Like IEclipsePreferences an extension to the osgi-IPreferences /// to send out events when nodes or values changed in a node. /// struct BERRY_RUNTIME IBerryPreferences : virtual public IPreferences { berryInterfaceMacro(IBerryPreferences, berry) /// /// Invoked when this node was changed, that is when a property /// was changed or when a new child node was inserted. /// berry::Message1 OnChanged; }; } // namespace berry #endif /*BERRYIBERRYPREFERENCES_H_*/ diff --git a/BlueBerry/Bundles/org.blueberry.core.runtime/src/berryIPreferences.h b/BlueBerry/Bundles/org.blueberry.core.runtime/src/berryIPreferences.h index 174104835f..03d3b32c9b 100644 --- a/BlueBerry/Bundles/org.blueberry.core.runtime/src/berryIPreferences.h +++ b/BlueBerry/Bundles/org.blueberry.core.runtime/src/berryIPreferences.h @@ -1,704 +1,704 @@ #ifndef BERRYIPREFERENCES_H_ #define BERRYIPREFERENCES_H_ -#include "berryRuntimeDll.h" +#include #include "berryObject.h" #include "berryBackingStoreException.h" #include #include #include namespace berry { /** * A node in a hierarchical collection of preference data. * *

* This interface allows applications to store and retrieve user and system * preference data. This data is stored persistently in an * implementation-dependent backing store. Typical implementations include flat * files, OS-specific registries, directory servers and SQL databases. * *

* For each bundle, there is a separate tree of nodes for each user, and one for * system preferences. The precise description of "user" and "system" will vary * from one bundle to another. Typical information stored in the user preference * tree might include font choice, and color choice for a bundle which interacts * with the user via a servlet. Typical information stored in the system * preference tree might include installation data, or things like high score * information for a game program. * *

* Nodes in a preference tree are named in a similar fashion to directories in a * hierarchical file system. Every node in a preference tree has a node name * (which is not necessarily unique), a unique absolute path name , * and a path name relative to each ancestor including itself. * *

* The root node has a node name of the empty std::string object (""). * Every other node has an arbitrary node name, specified at the time it is * created. The only restrictions on this name are that it cannot be the empty * string, and it cannot contain the slash character ('/'). * *

* The root node has an absolute path name of "/". Children of the * root node have absolute path names of "/" + <node name> * . All other nodes have absolute path names of <parent's absolute * path name> + "/" + <node name> . Note that * all absolute path names begin with the slash character. * *

* A node n 's path name relative to its ancestor a is simply the * string that must be appended to a 's absolute path name in order to * form n 's absolute path name, with the initial slash character (if * present) removed. Note that: *

    *
  • No relative path names begin with the slash character. *
  • Every node's path name relative to itself is the empty string. *
  • Every node's path name relative to its parent is its node name (except * for the root node, which does not have a parent). *
  • Every node's path name relative to the root is its absolute path name * with the initial slash character removed. *
* *

* Note finally that: *

    *
  • No path name contains multiple consecutive slash characters. *
  • No path name with the exception of the root's absolute path name end in * the slash character. *
  • Any string that conforms to these two rules is a valid path name. *
* *

* Each Preference node has zero or more properties associated with * it, where a property consists of a name and a value. The bundle writer is * free to choose any appropriate names for properties. Their values can be of * type std::string,long,int,bool, * std::vector,float, or double but they can * always be accessed as if they were std::string objects. * *

* All node name and property name comparisons are case-sensitive. * *

* All of the methods that modify preference data are permitted to operate * asynchronously; they may return immediately, and changes will eventually * propagate to the persistent backing store, with an implementation-dependent * delay. The flush method may be used to synchronously force updates * to the backing store. * *

* Implementations must automatically attempt to flush to the backing store any * pending updates for a bundle's preferences when the bundle is stopped or * otherwise ungets the IPreferences Service. * *

* The methods in this class may be invoked concurrently by multiple threads in * a single Java Virtual Machine (JVM) without the need for external * synchronization, and the results will be equivalent to some serial execution. * If this class is used concurrently by multiple JVMs that store their * preference data in the same backing store, the data store will not be * corrupted, but no other guarantees are made concerning the consistency of the * preference data. * * * @version $Revision$ */ struct BERRY_RUNTIME IPreferences : virtual public Object { berryInterfaceMacro(IPreferences, berry) /** * Associates the specified value with the specified key in this node. * * @param key key with which the specified value is to be associated. * @param value value to be associated with the specified key. * @throws NullPointerException if key or value is * null. * @throws IllegalStateException if this node (or an ancestor) has been * removed with the {@link #removeNode()}method. */ virtual void Put(std::string key, std::string value) = 0; /** * Returns the value associated with the specified key in this * node. Returns the specified default if there is no value associated with * the key, or the backing store is inaccessible. * * @param key key whose associated value is to be returned. * @param def the value to be returned in the event that this node has no * value associated with key or the backing store is * inaccessible. * @return the value associated with key, or def if * no value is associated with key. * @throws IllegalStateException if this node (or an ancestor) has been * removed with the {@link #removeNode()}method. * @throws NullPointerException if key is null. (A * null default is permitted.) */ virtual std::string Get(std::string key, std::string def) const = 0; /** * Removes the value associated with the specified key in this * node, if any. * * @param key key whose mapping is to be removed from this node. * @see #get(std::string,std::string) * @throws IllegalStateException if this node (or an ancestor) has been * removed with the {@link #removeNode()}method. */ virtual void Remove(std::string key) = 0; /** * Removes all of the properties (key-value associations) in this node. This * call has no effect on any descendants of this node. * * @throws BackingStoreException if this operation cannot be completed due * to a failure in the backing store, or inability to communicate * with it. * @throws IllegalStateException if this node (or an ancestor) has been * removed with the {@link #removeNode()}method. * @see #remove(std::string) */ virtual void Clear() throw(Poco::Exception, BackingStoreException) = 0; /** * Associates a std::string object representing the specified * int value with the specified key in this node. The * associated string is the one that would be returned if the int * value were passed to Integer.toString(int). This method is * intended for use in conjunction with {@link #getInt}method. * *

* Implementor's note: it is not necessary that the property value * be represented by a std::string object in the backing store. If the * backing store supports integer values, it is not unreasonable to use * them. This implementation detail is not visible through the * IPreferences API, which allows the value to be read as an * int (with getInt or a std::string (with * get) type. * * @param key key with which the string form of value is to be associated. * @param value value whose string form is to be associated with * key. * @throws NullPointerException if key is null. * @throws IllegalStateException if this node (or an ancestor) has been * removed with the {@link #removeNode()}method. * @see #getInt(std::string,int) */ virtual void PutInt(std::string key, int value) = 0; /** * Returns the int value represented by the std::string * object associated with the specified key in this node. The * std::string object is converted to an int as by * Integer.parseInt(std::string). Returns the specified default if * there is no value associated with the key, the backing store * is inaccessible, or if Integer.parseInt(std::string) would throw a * NumberFormatException if the associated value were * passed. This method is intended for use in conjunction with the * {@link #putInt}method. * * @param key key whose associated value is to be returned as an * int. * @param def the value to be returned in the event that this node has no * value associated with key or the associated value * cannot be interpreted as an int or the backing store is * inaccessible. * @return the int value represented by the std::string * object associated with key in this node, or * def if the associated value does not exist or cannot * be interpreted as an int type. * @throws NullPointerException if key is null. * @throws IllegalStateException if this node (or an ancestor) has been * removed with the {@link #removeNode()}method. * @see #putInt(std::string,int) * @see #get(std::string,std::string) */ virtual int GetInt(std::string key, int def) const = 0; /** * Associates a std::string object representing the specified * long value with the specified key in this node. The * associated std::string object is the one that would be returned if * the long value were passed to Long.toString(long). * This method is intended for use in conjunction with the {@link #getLong} * method. * *

* Implementor's note: it is not necessary that the value * be represented by a std::string type in the backing store. If the * backing store supports long values, it is not unreasonable to * use them. This implementation detail is not visible through the * IPreferences API, which allows the value to be read as a * long (with getLong or a std::string (with * get) type. * * @param key key with which the string form of value * is to be associated. * @param value value whose string form is to be associated with * key. * @throws NullPointerException if key is null. * @throws IllegalStateException if this node (or an ancestor) has been * removed with the {@link #removeNode()}method. * @see #getLong(std::string,long) */ virtual void PutLong(std::string key, long value) = 0; /** * Returns the long value represented by the std::string * object associated with the specified key in this node. The * std::string object is converted to a long as by * Long.parseLong(std::string). Returns the specified default if * there is no value associated with the key, the backing store * is inaccessible, or if Long.parseLong(std::string) would throw a * NumberFormatException if the associated value were * passed. This method is intended for use in conjunction with the * {@link #putLong}method. * * @param key key whose associated value is to be returned as a * long value. * @param def the value to be returned in the event that this node has no * value associated with key or the associated value * cannot be interpreted as a long type or the backing * store is inaccessible. * @return the long value represented by the std::string * object associated with key in this node, or * def if the associated value does not exist or cannot * be interpreted as a long type. * @throws NullPointerException if key is null. * @throws IllegalStateException if this node (or an ancestor) has been * removed with the {@link #removeNode()}method. * @see #putLong(std::string,long) * @see #get(std::string,std::string) */ virtual long GetLong(std::string key, long def) const = 0; /** * Associates a std::string object representing the specified * bool value with the specified key in this node. The * associated string is "true" if the value is true, and "false" * if it is false. This method is intended for use in * conjunction with the {@link #getBool}method. * *

* Implementor's note: it is not necessary that the value be * represented by a string in the backing store. If the backing store * supports bool values, it is not unreasonable to use them. * This implementation detail is not visible through the IPreferences * API, which allows the value to be read as a bool * (with getBool) or a std::string (with get) * type. * * @param key key with which the string form of value is to be * associated. * @param value value whose string form is to be associated with * key. * @throws NullPointerException if key is null. * @throws IllegalStateException if this node (or an ancestor) has been * removed with the {@link #removeNode()}method. * @see #getBool(std::string,bool) * @see #get(std::string,std::string) */ virtual void PutBool(std::string key, bool value) = 0; /** * Returns the bool value represented by the std::string * object associated with the specified key in this node. Valid * strings are "true", which represents true, and "false", which * represents false. Case is ignored, so, for example, "TRUE" * and "False" are also valid. This method is intended for use in * conjunction with the {@link #putBool}method. * *

* Returns the specified default if there is no value associated with the * key, the backing store is inaccessible, or if the associated * value is something other than "true" or "false", ignoring case. * * @param key key whose associated value is to be returned as a * bool. * @param def the value to be returned in the event that this node has no * value associated with key or the associated value * cannot be interpreted as a bool or the backing store * is inaccessible. * @return the bool value represented by the std::string * object associated with key in this node, or * null if the associated value does not exist or cannot * be interpreted as a bool. * @throws NullPointerException if key is null. * @throws IllegalStateException if this node (or an ancestor) has been * removed with the {@link #removeNode()}method. * @see #get(std::string,std::string) * @see #putBool(std::string,bool) */ virtual bool GetBool(std::string key, bool def) const = 0; /** * Associates a std::string object representing the specified * float value with the specified key in this node. * The associated std::string object is the one that would be returned * if the float value were passed to * Float.toString(float). This method is intended for use in * conjunction with the {@link #getFloat}method. * *

* Implementor's note: it is not necessary that the value be * represented by a string in the backing store. If the backing store * supports float values, it is not unreasonable to use them. * This implementation detail is not visible through the IPreferences * API, which allows the value to be read as a float (with * getFloat) or a std::string (with get) type. * * @param key key with which the string form of value is to be * associated. * @param value value whose string form is to be associated with * key. * @throws NullPointerException if key is null. * @throws IllegalStateException if this node (or an ancestor) has been * removed with the {@link #removeNode()}method. * @see #getFloat(std::string,float) */ virtual void PutFloat(std::string key, float value) = 0; /** * Returns the float value represented by the std::string * object associated with the specified key in this node. The * std::string object is converted to a float value as by * Float.parseFloat(std::string). Returns the specified default if * there is no value associated with the key, the backing store * is inaccessible, or if Float.parseFloat(std::string) would throw a * NumberFormatException if the associated value were passed. * This method is intended for use in conjunction with the {@link #putFloat} * method. * * @param key key whose associated value is to be returned as a * float value. * @param def the value to be returned in the event that this node has no * value associated with key or the associated value * cannot be interpreted as a float type or the backing * store is inaccessible. * @return the float value represented by the string associated * with key in this node, or def if the * associated value does not exist or cannot be interpreted as a * float type. * @throws IllegalStateException if this node (or an ancestor) has been * removed with the {@link #removeNode()}method. * @throws NullPointerException if key is null. * @see #putFloat(std::string,float) * @see #get(std::string,std::string) */ virtual float GetFloat(std::string key, float def) const = 0; /** * Associates a std::string object representing the specified * double value with the specified key in this node. * The associated std::string object is the one that would be returned * if the double value were passed to * Double.toString(double). This method is intended for use in * conjunction with the {@link #getDouble}method * *

* Implementor's note: it is not necessary that the value be * represented by a string in the backing store. If the backing store * supports double values, it is not unreasonable to use them. * This implementation detail is not visible through the IPreferences * API, which allows the value to be read as a double (with * getDouble) or a std::string (with get) * type. * * @param key key with which the string form of value is to be * associated. * @param value value whose string form is to be associated with * key. * @throws NullPointerException if key is null. * @throws IllegalStateException if this node (or an ancestor) has been * removed with the {@link #removeNode()}method. * @see #getDouble(std::string,double) */ virtual void PutDouble(std::string key, double value) = 0; /** * Returns the double value represented by the std::string * object associated with the specified key in this node. The * std::string object is converted to a double value as by * Double.parseDouble(std::string). Returns the specified default if * there is no value associated with the key, the backing store * is inaccessible, or if Double.parseDouble(std::string) would throw * a NumberFormatException if the associated value were passed. * This method is intended for use in conjunction with the * {@link #putDouble}method. * * @param key key whose associated value is to be returned as a * double value. * @param def the value to be returned in the event that this node has no * value associated with key or the associated value * cannot be interpreted as a double type or the backing * store is inaccessible. * @return the double value represented by the std::string * object associated with key in this node, or * def if the associated value does not exist or cannot * be interpreted as a double type. * @throws IllegalStateException if this node (or an ancestor) has been * removed with the the {@link #removeNode()}method. * @throws NullPointerException if key is null. * @see #putDouble(std::string,double) * @see #get(std::string,std::string) */ virtual double GetDouble(std::string key, double def) const = 0; /** * Associates a std::string object representing the specified * std::vector with the specified key in this node. The * associated std::string object the Base64 encoding of the * std::vector, as defined in RFC 2045 , Section 6.8, * with one minor change: the string will consist solely of characters from * the Base64 Alphabet ; it will not contain any newline characters. * This method is intended for use in conjunction with the * {@link #getByteArray}method. * *

* Implementor's note: it is not necessary that the value be * represented by a std::string type in the backing store. If the * backing store supports std::vector values, it is not unreasonable * to use them. This implementation detail is not visible through the * IPreferences API, which allows the value to be read as an a * std::vector object (with getByteArray) or a * std::string object (with get). * * @param key key with which the string form of value * is to be associated. * @param value value whose string form is to be associated with * key. * @throws NullPointerException if key or value is * null. * @throws IllegalStateException if this node (or an ancestor) has been * removed with the {@link #removeNode()}method. * @see #getByteArray(std::string,std::vector) * @see #get(std::string,std::string) */ virtual void PutByteArray(std::string key, std::string value) = 0; /** * Returns the std::vector value represented by the std::string * object associated with the specified key in this node. Valid * std::string objects are Base64 encoded binary data, as * defined in RFC 2045 , * Section 6.8, with one minor change: the string must consist solely of * characters from the Base64 Alphabet ; no newline characters or * extraneous characters are permitted. This method is intended for use in * conjunction with the {@link #putByteArray}method. * *

* Returns the specified default if there is no value associated with the * key, the backing store is inaccessible, or if the associated * value is not a valid Base64 encoded byte array (as defined above). * * @param key key whose associated value is to be returned as a * std::vector object. * @param def the value to be returned in the event that this node has no * value associated with key or the associated value * cannot be interpreted as a std::vector type, or the backing * store is inaccessible. * @return the std::vector value represented by the std::string * object associated with key in this node, or * def if the associated value does not exist or cannot * be interpreted as a std::vector. * @throws NullPointerException if key is null. (A * null value for def is permitted.) * @throws IllegalStateException if this node (or an ancestor) has been * removed with the {@link #removeNode()}method. * @see #get(std::string,std::string) * @see #putByteArray(std::string,std::vector) */ virtual std::string GetByteArray(std::string key, std::string def) const = 0; /** * Returns all of the keys that have an associated value in this node. (The * returned array will be of size zero if this node has no preferences and * not null!) * * @return an array of the keys that have an associated value in this node. * @throws BackingStoreException if this operation cannot be completed due * to a failure in the backing store, or inability to communicate * with it. * @throws IllegalStateException if this node (or an ancestor) has been * removed with the {@link #removeNode()}method. */ virtual std::vector Keys() const throw(Poco::Exception, BackingStoreException) = 0; /** * Returns the names of the children of this node. (The returned array will * be of size zero if this node has no children and not null!) * * @return the names of the children of this node. * @throws BackingStoreException if this operation cannot be completed due * to a failure in the backing store, or inability to communicate * with it. * @throws IllegalStateException if this node (or an ancestor) has been * removed with the {@link #removeNode()}method. */ virtual std::vector ChildrenNames() const throw(Poco::Exception, BackingStoreException) = 0; /** * Returns the parent of this node, or null if this is the root. * * @return the parent of this node. * @throws IllegalStateException if this node (or an ancestor) has been * removed with the {@link #removeNode()}method. */ virtual IPreferences::Pointer Parent() const = 0; /** * Returns a named IPreferences object (node), creating it and any * of its ancestors if they do not already exist. Accepts a relative or * absolute pathname. Absolute pathnames (which begin with '/') * are interpreted relative to the root of this node. Relative pathnames * (which begin with any character other than '/') are * interpreted relative to this node itself. The empty string ("") * is a valid relative pathname, referring to this node itself. * *

* If the returned node did not exist prior to this call, this node and any * ancestors that were created by this call are not guaranteed to become * persistent until the flush method is called on the returned * node (or one of its descendants). * * @param pathName the path name of the IPreferences object to * return. * @return the specified IPreferences object. * @throws IllegalArgumentException if the path name is invalid. * @throws IllegalStateException if this node (or an ancestor) has been * removed with the {@link #removeNode()}method. * @throws NullPointerException if path name is null. * @see #flush() */ virtual IPreferences::Pointer Node(std::string pathName) = 0; /** * Returns true if the named node exists. Accepts a relative or absolute * pathname. Absolute pathnames (which begin with '/') are * interpreted relative to the root of this node. Relative pathnames (which * begin with any character other than '/') are interpreted * relative to this node itself. The pathname "" is valid, and * refers to this node itself. * *

* If this node (or an ancestor) has already been removed with the * {@link #removeNode()}method, it is legal to invoke this method, * but only with the pathname ""; the invocation will return * false. Thus, the idiom p.nodeExists("") may be * used to test whether p has been removed. * * @param pathName the path name of the node whose existence is to be * checked. * @return true if the specified node exists. * @throws BackingStoreException if this operation cannot be completed due * to a failure in the backing store, or inability to communicate * with it. * @throws IllegalStateException if this node (or an ancestor) has been * removed with the {@link #removeNode()}method and * pathname is not the empty string (""). * @throws IllegalArgumentException if the path name is invalid (i.e., it * contains multiple consecutive slash characters, or ends with a * slash character and is more than one character long). */ virtual bool NodeExists(std::string pathName) const throw(Poco::Exception, BackingStoreException) = 0; /** * Removes this node and all of its descendants, invalidating any properties * contained in the removed nodes. Once a node has been removed, attempting * any method other than name(),absolutePath() or * nodeExists("") on the corresponding IPreferences * instance will fail with an IllegalStateException. (The * methods defined on Object can still be invoked on a node after * it has been removed; they will not throw IllegalStateException.) * *

* The removal is not guaranteed to be persistent until the flush * method is called on the parent of this node. * * @throws IllegalStateException if this node (or an ancestor) has already * been removed with the {@link #removeNode()}method. * @throws BackingStoreException if this operation cannot be completed due * to a failure in the backing store, or inability to communicate * with it. * @see #flush() */ virtual void RemoveNode() throw(Poco::Exception, BackingStoreException) = 0; /** * Returns this node's name, relative to its parent. * * @return this node's name, relative to its parent. */ virtual std::string Name() const = 0; /** * Returns this node's absolute path name. Note that: *

    *
  • Root node - The path name of the root node is "/". *
  • Slash at end - Path names other than that of the root node may not * end in slash ('/'). *
  • Unusual names -"." and ".." have no * special significance in path names. *
  • Illegal names - The only illegal path names are those that contain * multiple consecutive slashes, or that end in slash and are not the root. *
* * @return this node's absolute path name. */ virtual std::string AbsolutePath() const = 0; /** * Forces any changes in the contents of this node and its descendants to * the persistent store. * *

* Once this method returns successfully, it is safe to assume that all * changes made in the subtree rooted at this node prior to the method * invocation have become permanent. * *

* Implementations are free to flush changes into the persistent store at * any time. They do not need to wait for this method to be called. * *

* When a flush occurs on a newly created node, it is made persistent, as * are any ancestors (and descendants) that have yet to be made persistent. * Note however that any properties value changes in ancestors are not * guaranteed to be made persistent. * * @throws BackingStoreException if this operation cannot be completed due * to a failure in the backing store, or inability to communicate * with it. * @throws IllegalStateException if this node (or an ancestor) has been * removed with the {@link #removeNode()}method. * @see #sync() */ virtual void Flush() throw(Poco::Exception, BackingStoreException) = 0; /** * Ensures that future reads from this node and its descendants reflect any * changes that were committed to the persistent store (from any VM) prior * to the sync invocation. As a side-effect, forces any changes * in the contents of this node and its descendants to the persistent store, * as if the flush method had been invoked on this node. * * @throws BackingStoreException if this operation cannot be completed due * to a failure in the backing store, or inability to communicate * with it. * @throws IllegalStateException if this node (or an ancestor) has been * removed with the {@link #removeNode()}method. * @see #flush() */ virtual void Sync() throw(Poco::Exception, BackingStoreException) = 0; }; } // namespace berry #endif /*BERRYIPREFERENCES_H_*/ diff --git a/BlueBerry/Bundles/org.blueberry.core.runtime/src/berryIPreferencesService.h b/BlueBerry/Bundles/org.blueberry.core.runtime/src/berryIPreferencesService.h index c1ae592e4a..8d490f8139 100644 --- a/BlueBerry/Bundles/org.blueberry.core.runtime/src/berryIPreferencesService.h +++ b/BlueBerry/Bundles/org.blueberry.core.runtime/src/berryIPreferencesService.h @@ -1,61 +1,65 @@ #ifndef BERRYIPREFERENCESSERVICE_H_ #define BERRYIPREFERENCESSERVICE_H_ #include "service/berryService.h" -#include "berryRuntimeDll.h" +#include #include "berryIPreferences.h" #include #include +#include + namespace berry { /** * The Preferences Service. * *

* Each bundle using this service has its own set of preference trees: one for * system preferences, and one for each user. * *

* A PreferencesService object is specific to the bundle which * obtained it from the service registry. If a bundle wishes to allow another * bundle to access its preferences, it should pass its * PreferencesService object to that bundle. * */ struct BERRY_RUNTIME IPreferencesService : public Service { /// /// A unique ID for the Service. /// static const std::string ID; - berryInterfaceMacro(IPreferencesService, berry) + berryInterfaceMacro(IPreferencesService, berry) /** * Returns the root system node for the calling bundle. * * @return The root system node for the calling bundle. */ virtual IPreferences::Pointer GetSystemPreferences() = 0; /** * Returns the root node for the specified user and the calling bundle. * * @param name The user for which to return the preference root node. * @return The root node for the specified user and the calling bundle. */ virtual IPreferences::Pointer GetUserPreferences(std::string name) = 0; /** * Returns the names of users for which node trees exist. * * @return The names of users for which node trees exist. */ virtual std::vector GetUsers() const = 0; }; } // namespace berry +Q_DECLARE_INTERFACE(berry::IPreferencesService, "org.blueberry.service.IPreferencesService") + #endif /*BERRYIPREFERENCESSERVICE_H_*/ diff --git a/BlueBerry/Bundles/org.blueberry.core.runtime/src/berryPlatformObject.h b/BlueBerry/Bundles/org.blueberry.core.runtime/src/berryPlatformObject.h index 2307c45397..6afcfc4da4 100755 --- a/BlueBerry/Bundles/org.blueberry.core.runtime/src/berryPlatformObject.h +++ b/BlueBerry/Bundles/org.blueberry.core.runtime/src/berryPlatformObject.h @@ -1,85 +1,85 @@ /*========================================================================= Program: BlueBerry Platform Language: C++ Date: $Date$ Version: $Revision$ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #ifndef BERRYPLATFORMOBJECT_H_ #define BERRYPLATFORMOBJECT_H_ -#include "berryRuntimeDll.h" +#include #include #include "berryIAdaptable.h" namespace berry { /** * An abstract superclass implementing the IAdaptable * interface. getAdapter invocations are directed * to the platform's adapter manager. *

* Note: In situations where it would be awkward to subclass this * class, the same affect can be achieved simply by implementing * the IAdaptable interface and explicitly forwarding * the getAdapter request to the platform's * adapater manager. The method would look like: *

  *     public Object getAdapter(Class adapter) {
  *         return Platform.getAdapterManager().getAdapter(this, adapter);
  *     }
  * 
*

*

* Clients may subclass. *

* * @see Platform#getAdapterManager */ class BERRY_RUNTIME PlatformObject : public Object, public IAdaptable { public: berryObjectMacro(berry::PlatformObject) /** * Constructs a new platform object. */ PlatformObject(); /** * Returns an object which is an instance of the given class * associated with this object. Returns null if * no such object can be found. *

* This implementation of the method declared by IAdaptable * passes the request along to the platform's adapter manager; roughly * Platform.getAdapterManager().getAdapter(this, adapter). * Subclasses may override this method (however, if they do so, they * should invoke the method on their superclass to ensure that the * Platform's adapter manager is consulted). *

* * @see IAdaptable#getAdapter * @see Platform#getAdapterManager */ Poco::Any GetAdapter(const std::string& adapter); }; } #endif /* BERRYPLATFORMOBJECT_H_ */ diff --git a/BlueBerry/Bundles/org.blueberry.core.runtime/src/berryRuntime.h b/BlueBerry/Bundles/org.blueberry.core.runtime/src/berryRuntime.h index 5c29b94a4c..fd7372e396 100644 --- a/BlueBerry/Bundles/org.blueberry.core.runtime/src/berryRuntime.h +++ b/BlueBerry/Bundles/org.blueberry.core.runtime/src/berryRuntime.h @@ -1,34 +1,34 @@ /*========================================================================= Program: BlueBerry Platform Language: C++ Date: $Date$ Version: $Revision$ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #ifndef BERRYRUNTIME_H_ #define BERRYRUNTIME_H_ #include -#include "berryRuntimeDll.h" +#include namespace berry { struct BERRY_RUNTIME Runtime { static const std::string ADAPTER_SERVICE_ID; }; } #endif /*BERRYRUNTIME_H_*/ diff --git a/BlueBerry/Bundles/org.blueberry.core.runtime/src/berryRuntimeDll.h b/BlueBerry/Bundles/org.blueberry.core.runtime/src/berryRuntimeDll.h deleted file mode 100644 index 6a506ebc8b..0000000000 --- a/BlueBerry/Bundles/org.blueberry.core.runtime/src/berryRuntimeDll.h +++ /dev/null @@ -1,43 +0,0 @@ -/*========================================================================= - -Program: BlueBerry Platform -Language: C++ -Date: $Date$ -Version: $Revision$ - -Copyright (c) German Cancer Research Center, Division of Medical and -Biological Informatics. All rights reserved. -See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. - -This software is distributed WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. See the above copyright notices for more information. - -=========================================================================*/ - -#ifndef BERRYRUNTIMEDLL_H_ -#define BERRYRUNTIMEDLL_H_ - - -// -// The following block is the standard way of creating macros which make exporting -// from a DLL simpler. All files within this DLL are compiled with the org_blueberry_core_runtime_EXPORTS -// symbol defined on the command line. this symbol should not be defined on any project -// that uses this DLL. This way any other project whose source files include this file see -// org_blueberry_core_runtime_EXPORTS functions as being imported from a DLL, wheras this DLL sees symbols -// defined with this macro as being exported. -// -#if defined(_WIN32) && !defined(BERRY_STATIC) - #if defined(org_blueberry_core_runtime_EXPORTS) - #define BERRY_RUNTIME __declspec(dllexport) - #else - #define BERRY_RUNTIME __declspec(dllimport) - #endif -#endif - - -#if !defined(BERRY_RUNTIME) - #define BERRY_RUNTIME -#endif - -#endif /*BERRYRUNTIMEDLL_H_*/ diff --git a/BlueBerry/Bundles/org.blueberry.core.runtime/src/berryRuntimePlugin.h b/BlueBerry/Bundles/org.blueberry.core.runtime/src/berryRuntimePlugin.h index e2397d06ad..6c6e9a0014 100644 --- a/BlueBerry/Bundles/org.blueberry.core.runtime/src/berryRuntimePlugin.h +++ b/BlueBerry/Bundles/org.blueberry.core.runtime/src/berryRuntimePlugin.h @@ -1,44 +1,44 @@ /*========================================================================= Program: BlueBerry Platform Language: C++ Date: $Date$ Version: $Revision$ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #ifndef BERRYRUNTIMEACTIVATOR_H_ #define BERRYRUNTIMEACTIVATOR_H_ #include #include #include -#include "berryRuntimeDll.h" +#include #include "internal/berryPreferencesService.h" namespace berry { class BERRY_RUNTIME RuntimePlugin : public Plugin { public: static const std::string PLUGIN_ID; void Start(IBundleContext::Pointer context); void Stop(IBundleContext::Pointer context); protected: PreferencesService::Pointer m_PreferencesService; }; } #endif /*BERRYRUNTIMEACTIVATOR_H_*/ diff --git a/BlueBerry/Bundles/org.blueberry.core.runtime/src/internal/berryAbstractPreferencesStorage.h b/BlueBerry/Bundles/org.blueberry.core.runtime/src/internal/berryAbstractPreferencesStorage.h index 5bdad095c9..d9dd4ad2b6 100644 --- a/BlueBerry/Bundles/org.blueberry.core.runtime/src/internal/berryAbstractPreferencesStorage.h +++ b/BlueBerry/Bundles/org.blueberry.core.runtime/src/internal/berryAbstractPreferencesStorage.h @@ -1,64 +1,64 @@ #ifndef BERRYABSTRACTPREFERENCESSTORAGE_H_ #define BERRYABSTRACTPREFERENCESSTORAGE_H_ -#include "../berryRuntimeDll.h" -#include "berryIPreferences.h" +#include +#include "../berryIPreferences.h" #include "Poco/File.h" namespace berry { /// /// Interface to flush Preferences. /// class BERRY_RUNTIME AbstractPreferencesStorage : public Object { public: berryObjectMacro(berry::AbstractPreferencesStorage) /// /// Saves the path, sets the root initially to 0. /// In subclasses try to read data from file here. /// AbstractPreferencesStorage(const Poco::File& _File); /// /// Pure virtual (abstract class) /// virtual ~AbstractPreferencesStorage(); /// /// Flushes the given (or all) prefs persistently /// virtual void Flush(IPreferences* prefs) throw(Poco::Exception, BackingStoreException) = 0; /// /// Returns the root prefs /// virtual IPreferences::Pointer GetRoot() const; /// /// Returns the path of the file /// virtual const Poco::File& GetFile() const; /// /// Sets the file /// virtual void SetFile(const Poco::File& f); protected: /// /// Path to the file where the data is stored /// Poco::File m_File; /// /// Pointer to the root Preferences /// IPreferences::Pointer m_Root; }; } #endif /* BERRYABSTRACTPREFERENCESSTORAGE_H_ */ diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/guitk/berryGuiTkEvent.cpp b/BlueBerry/Bundles/org.blueberry.core.runtime/src/internal/berryPluginActivator.cpp old mode 100755 new mode 100644 similarity index 50% copy from BlueBerry/Bundles/org.blueberry.ui/src/guitk/berryGuiTkEvent.cpp copy to BlueBerry/Bundles/org.blueberry.core.runtime/src/internal/berryPluginActivator.cpp index 5990a11507..ffe73f6a83 --- a/BlueBerry/Bundles/org.blueberry.ui/src/guitk/berryGuiTkEvent.cpp +++ b/BlueBerry/Bundles/org.blueberry.core.runtime/src/internal/berryPluginActivator.cpp @@ -1,48 +1,45 @@ /*========================================================================= Program: BlueBerry Platform Language: C++ Date: $Date$ Version: $Revision$ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ -#include "berryGuiTkEvent.h" -#include +#include "berryPluginActivator.h" -namespace berry { +#include -namespace GuiTk { +namespace berry { -Event::Event() : -item(0), detail(0), x(0), y(0), -width(0), height(0), button(0), -character(0), keyCode(0), stateMask(0), -text(""), doit(true) +org_blueberry_core_runtime_Activator::org_blueberry_core_runtime_Activator() { - } -std::string Event::ToString() +void org_blueberry_core_runtime_Activator::start(ctkPluginContext* context) { - std::stringstream stream; - stream << "GUI SelectionEvent: " << " item=" << item << " detail=" << detail - << " x=" << x << " y=" << y << " width=" << width << " height=" << height - << " stateMask=" << stateMask << " text=" << text << " doit=" << doit - << std::endl; - - return stream.str(); + m_PreferencesService = new PreferencesService(); + m_PrefServiceReg = context->registerService(m_PreferencesService.GetPointer()); } +void org_blueberry_core_runtime_Activator::stop(ctkPluginContext* context) +{ + m_PrefServiceReg.unregister(); + m_PreferencesService->ShutDown(); + m_PreferencesService = 0; + m_PrefServiceReg = 0; } } + +Q_EXPORT_PLUGIN2(org_blueberry_core_runtime, berry::org_blueberry_core_runtime_Activator) diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/berryFileEditorInput.h b/BlueBerry/Bundles/org.blueberry.core.runtime/src/internal/berryPluginActivator.h similarity index 52% copy from BlueBerry/Bundles/org.blueberry.ui/src/berryFileEditorInput.h copy to BlueBerry/Bundles/org.blueberry.core.runtime/src/internal/berryPluginActivator.h index 513f9f2ccb..57bfea6b49 100644 --- a/BlueBerry/Bundles/org.blueberry.ui/src/berryFileEditorInput.h +++ b/BlueBerry/Bundles/org.blueberry.core.runtime/src/internal/berryPluginActivator.h @@ -1,54 +1,51 @@ /*========================================================================= Program: BlueBerry Platform Language: C++ Date: $Date$ Version: $Revision$ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ -#ifndef BERRYFILEEDITORINPUT_H_ -#define BERRYFILEEDITORINPUT_H_ +#ifndef BERRYPLUGINACTIVATOR_H +#define BERRYPLUGINACTIVATOR_H -#include "berryIPathEditorInput.h" -#include "berryUiDll.h" +#include +#include +#include "berryPreferencesService.h" namespace berry { -class BERRY_UI FileEditorInput : public IPathEditorInput +class org_blueberry_core_runtime_Activator : + public QObject, public ctkPluginActivator { + Q_OBJECT + Q_INTERFACES(ctkPluginActivator) public: + org_blueberry_core_runtime_Activator(); - berryObjectMacro(FileEditorInput); - - FileEditorInput(const Poco::Path& path); - - Poco::Path GetPath() const; - - bool Exists() const; - - std::string GetName() const ; - - std::string GetToolTipText() const; - - bool operator==(const Object* o) const; - + void start(ctkPluginContext* context); + void stop(ctkPluginContext* context); + private: - Poco::Path m_Path; + PreferencesService::Pointer m_PreferencesService; + ctkServiceRegistration m_PrefServiceReg; }; +typedef org_blueberry_core_runtime_Activator PluginActivator; + } -#endif /* BERRYFILEEDITORINPUT_H_ */ +#endif // BERRYPLUGINACTIVATOR_H diff --git a/BlueBerry/Bundles/org.blueberry.core.runtime/src/internal/berryPreferences.h b/BlueBerry/Bundles/org.blueberry.core.runtime/src/internal/berryPreferences.h index bcc19a0885..fd52f762c9 100644 --- a/BlueBerry/Bundles/org.blueberry.core.runtime/src/internal/berryPreferences.h +++ b/BlueBerry/Bundles/org.blueberry.core.runtime/src/internal/berryPreferences.h @@ -1,327 +1,327 @@ #ifndef BERRYPREFERENCES_H_ #define BERRYPREFERENCES_H_ -#include "../berryRuntimeDll.h" -#include "berryIBerryPreferences.h" +#include +#include "../berryIBerryPreferences.h" #include #include #include #include #include "Poco/Mutex.h" namespace berry { class AbstractPreferencesStorage; /// /// Implementation of the OSGI Preferences Interface. /// Wraps a DOMNode. /// class BERRY_RUNTIME Preferences: public IBerryPreferences { public: /// /// For use with berry::SmartPtr /// berryObjectMacro(berry::Preferences) /// /// Maps a string key to a string value /// typedef std::map PropertyMap; /// /// The list of Child nodes /// typedef std::vector ChildrenList; /// /// Constructs a new preference node. /// \param _Properties the key->value pairs of this preference node /// \param _Path the absolute path to this node, e.g. "/general/editors/font" /// \param _Name the name of this node, e.g. "font" /// \param _FileName the absolute path to the file in which this preferences tree will be saved to /// \param _Parent the parent node or 0 if this is the root /// \param _Root the root of this preference tree /// Preferences(const PropertyMap& _Properties , const std::string& _Name , Preferences* _Parent , AbstractPreferencesStorage* _Storage); /// /// Nothing to do here /// virtual ~Preferences(); /// /// Prints out the absolute path of the preference node. /// std::string ToString() const; /// /// Returns if this node and his silblings have to be rewritten persistently /// bool IsDirty() const; /// /// Returns if this node is removed /// bool IsRemoved() const; /// /// Returns if this node has property with a specific key /// bool Has(std::string key) const; /// /// Returns true if the absolute paths are the same /// bool Equals(const Preferences* rhs) const; /// /// Returns all Properties as map. /// PropertyMap GetProperties() const; /// /// Returns a reference to the children list in order to add or remove nodes. /// *ATTENTION*: Should only be used /// when constructing the preferences tree from a persistent location. Normally, one would /// only use the IPreferences methods /// ChildrenList GetChildren() const; //# Begin of IPreferences methods /// /// \see IPreferences::AbsolutePath() /// virtual std::string AbsolutePath() const; /// /// \see IPreferences::ChildrenNames() /// virtual std::vector ChildrenNames() const throw(Poco::Exception, BackingStoreException); /// /// \see IPreferences::ChildrenNames() /// virtual AbstractPreferencesStorage* GetStorage() const; /// /// \see IPreferences::Clear() /// virtual void Clear() throw(Poco::Exception, BackingStoreException); /// /// \see IPreferences::Flush() /// virtual void Flush() throw(Poco::Exception, BackingStoreException); /// /// \see IPreferences::Get() /// virtual std::string Get(std::string key, std::string def) const; /// /// \see IPreferences::GetBool() /// virtual bool GetBool(std::string key, bool def) const; /// /// \see IPreferences::GetByteArray() /// virtual std::string GetByteArray(std::string key, std::string def) const; /// /// \see IPreferences::GetDouble() /// virtual double GetDouble(std::string key, double def) const; /// /// \see IPreferences::GetFloat() /// virtual float GetFloat(std::string key, float def) const; /// /// \see IPreferences::GetInt() /// virtual int GetInt(std::string key, int def) const; /// /// \see IPreferences::GetLong() /// virtual long GetLong(std::string key, long def) const; /// /// \see IPreferences::Keys() /// std::vector Keys() const throw(Poco::Exception, BackingStoreException); /// /// \see IPreferences::Name() /// virtual std::string Name() const; /// /// \see IPreferences::Node() /// virtual IPreferences::Pointer Node(std::string pathName); /// /// \see IPreferences::NodeExists() /// virtual bool NodeExists(std::string pathName) const throw(Poco::Exception, BackingStoreException); /// /// \see IPreferences::Parent() /// virtual IPreferences::Pointer Parent() const; /// /// \see IPreferences::Put() /// virtual void Put(std::string key, std::string value); /// /// \see IPreferences::PutByteArray() /// virtual void PutByteArray(std::string key, std::string value); /// /// \see IPreferences::PutBool() /// virtual void PutBool(std::string key, bool value); /// /// \see IPreferences::PutDouble() /// virtual void PutDouble(std::string key, double value); /// /// \see IPreferences::Sync() /// virtual void PutFloat(std::string key, float value); /// /// \see IPreferences::PutInt() /// virtual void PutInt(std::string key, int value); /// /// \see IPreferences::PutLong() /// virtual void PutLong(std::string key, long value); /// /// \see IPreferences::Remove() /// virtual void Remove(std::string key); /// /// \see IPreferences::RemoveNode() /// virtual void RemoveNode() throw(Poco::Exception, BackingStoreException); /// /// \see IPreferences::Sync() /// virtual void Sync() throw(Poco::Exception, BackingStoreException); //# End of IPreferences methods protected: /// /// Checks if this node is about to be removed. /// \throws IllegalStateException /// void AssertValid() const; /// /// Checks a path value for validity. /// \throws invalid_argument /// static void AssertPath(std::string pathName); /// /// Converts any value to a string (using stream operator "<<") /// template static std::string ToString(const T& obj, int precision = 12 ) { std::ostringstream s; std::locale C("C"); s.imbue(C); s.precision(precision); s << obj; return s.str(); } /// /// Sets the dirty flag recursively on all child nodes. /// void SetDirty(bool _Dirty); /// /// Sets the removed flag recursively on all child nodes. /// void SetRemoved(bool _Removed); protected: /// /// Holds all Key/Value Pairs. /// std::map m_Properties; /// /// Holds all child nodes (explicit ownership). /// std::vector m_Children; /// /// Saves the absolute path of this node (calculated in the constructor) /// std::string m_Path; /// /// Saves the name of this node (set when read from backend) /// std::string m_Name; /// /// Saves the parent of this node /// Preferences* m_Parent; /// /// Saves the root of this tree /// Preferences* m_Root; /// /// Saves if something changed on this branch. /// Meaning that you would have to rewrite it. /// bool m_Dirty; /// /// Saves if this Node is removed (will not be saved to the backend). /// bool m_Removed; /// /// A storage to call the flush method. /// AbstractPreferencesStorage* m_Storage; /// /// A mutex to avoid concurrency crashes. Mutable because we need to use Mutex::lock() in const functions /// mutable Poco::Mutex m_Mutex; }; } namespace Base64 { /// /// Encode string to base64 (needed for writing byte arrays) /// std::string encode(const std::string &sString); /// /// Decode base64 to string (needed for reading byte arrays) /// std::string decode(const std::string &sString); }; /// /// Uses Preferences::ToString to print node information /// std::ostream& operator<<(std::ostream& os,const berry::Preferences& m); /// /// Uses Preferences::ToString to print node information /// std::ostream& operator<<(std::ostream& os,const berry::Preferences* m); #endif /* BERRYPREFERENCES_H_ */ diff --git a/BlueBerry/Bundles/org.blueberry.core.runtime/src/internal/berryPreferencesService.h b/BlueBerry/Bundles/org.blueberry.core.runtime/src/internal/berryPreferencesService.h index 812f295a7c..3735ea24bb 100644 --- a/BlueBerry/Bundles/org.blueberry.core.runtime/src/internal/berryPreferencesService.h +++ b/BlueBerry/Bundles/org.blueberry.core.runtime/src/internal/berryPreferencesService.h @@ -1,99 +1,103 @@ #ifndef BERRYPREFERENCESSERVICE_H_ #define BERRYPREFERENCESSERVICE_H_ -#include "berryRuntimeDll.h" -//#include "berryService.h" -#include "berryIBerryPreferencesService.h" +#include +#include "../berryIBerryPreferencesService.h" #include "berryAbstractPreferencesStorage.h" #include #include +#include + namespace berry { /** * Implementation of the IPreferencesService Interface */ - class BERRY_RUNTIME PreferencesService : public IBerryPreferencesService + class BERRY_RUNTIME PreferencesService : public QObject, public IBerryPreferencesService { + Q_OBJECT + Q_INTERFACES(berry::IPreferencesService) + public: berryObjectMacro(PreferencesService) //# From berry::Service virtual bool IsA(const std::type_info& type) const; virtual const std::type_info& GetType() const; /// /// Returns the default name for the preferences data file /// static std::string GetDefaultPreferencesFileName(); /// /// Returns the path to the directory where all preference data is stored. /// static std::string GetDefaultPreferencesDirPath(); /// /// Reads in all users for which preferences exist. /// PreferencesService(std::string _PreferencesDir=""); /// /// Nothing to do here so far. /// virtual ~PreferencesService(); /** * If no system preference file exists create a new AbstractPreferencesStorage. * \see IPreferencesService::GetSystemPreferences() */ virtual IPreferences::Pointer GetSystemPreferences(); /** * If no user preference file exists create a new AbstractPreferencesStorage. * \see IPreferencesService::GetUserPreferences() */ virtual IPreferences::Pointer GetUserPreferences(std::string name); /** * \see IPreferencesService::GetUsers() */ virtual std::vector GetUsers() const; /// /// \see IPreferencesService::ImportPreferences() /// virtual void ImportPreferences(Poco::File f, std::string name=""); /// /// \see IPreferencesService::ExportPreferences() /// virtual void ExportPreferences(Poco::File f, std::string name=""); /// /// flushes all preferences /// virtual void ShutDown(); protected: /// /// Helper func for ImportPreferences(). Imports all nodes of an IPreferences tree recursively /// void ImportNode( IPreferences::Pointer nodeToImport , IPreferences::Pointer rootOfOldPrefs ); /// /// Holds the directory where the preferences files will be stored /// std::string m_PreferencesDir; /// /// Maps all user names to their preference storage. /// std::map m_PreferencesStorages; /// /// A mutex to avoid concurrency crashes. Mutable because we need to use Mutex::lock() in const functions /// mutable Poco::Mutex m_Mutex; }; } // namespace berry #endif /*BERRYPREFERENCESSERVICE_H_*/ diff --git a/BlueBerry/Bundles/org.blueberry.core.runtime/src/internal/berryXMLPreferencesStorage.h b/BlueBerry/Bundles/org.blueberry.core.runtime/src/internal/berryXMLPreferencesStorage.h index 057db889c3..f775de4f37 100644 --- a/BlueBerry/Bundles/org.blueberry.core.runtime/src/internal/berryXMLPreferencesStorage.h +++ b/BlueBerry/Bundles/org.blueberry.core.runtime/src/internal/berryXMLPreferencesStorage.h @@ -1,57 +1,57 @@ #ifndef BERRYXMLPREFERENCES_H_ #define BERRYXMLPREFERENCES_H_ -#include "../berryRuntimeDll.h" +#include #include "berryAbstractPreferencesStorage.h" #include "Poco/Path.h" #include "Poco/DOM/Node.h" #include "Poco/DOM/Document.h" #include "Poco/AutoPtr.h" namespace berry { class Preferences; /// /// Implementation of the OSGI Preferences Interface. /// Wraps a DOMNode. /// class BERRY_RUNTIME XMLPreferencesStorage: public AbstractPreferencesStorage { public: /// /// For use with berry::SmartPtr /// berryObjectMacro(berry::XMLPreferencesStorage) /// /// Construct a new XML-based PreferencesStorage /// XMLPreferencesStorage(const Poco::File& _File); /// /// To be implemented in the subclasses. /// virtual void Flush(IPreferences* _Preferences) throw(Poco::Exception, BackingStoreException); /// /// Nothing to do here /// virtual ~XMLPreferencesStorage(); protected: /// /// Construct Preferences tree from DOM tree (recursive) /// Construct a PreferencesNode from the DOMNode by using prefParentNode /// void ToPreferencesTree(Poco::XML::Node* DOMNode, Preferences* prefParentNode); /// /// Construct DOM tree from Preferences tree (recursive) /// Construct a DOMNode from the prefNode by using parentDOMNode /// void ToDOMTree(Preferences* prefNode, Poco::XML::Node* parentDOMNode); protected: Poco::AutoPtr m_Document; }; } #endif /* BERRYXMLPREFERENCES_H_ */ diff --git a/BlueBerry/Bundles/org.blueberry.osgi/CMakeLists.txt b/BlueBerry/Bundles/org.blueberry.osgi/CMakeLists.txt index b6422387d8..3d6783f0e6 100644 --- a/BlueBerry/Bundles/org.blueberry.osgi/CMakeLists.txt +++ b/BlueBerry/Bundles/org.blueberry.osgi/CMakeLists.txt @@ -1,27 +1,37 @@ +PROJECT(org_blueberry_osgi) -CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/src/berryConfig.h.in" "${CMAKE_CURRENT_BINARY_DIR}/berryConfig.h" @ONLY) - -MACRO_CREATE_PLUGIN() +MACRO_CREATE_CTK_PLUGIN( + EXPORT_DIRECTIVE BERRY_OSGI + EXPORTED_INCLUDE_SUFFIXES src src/application src/event src/service + ) -TARGET_LINK_LIBRARIES(${PLUGIN_TARGET} optimized PocoUtil debug PocoUtild optimized PocoXML debug PocoXMLd) ADD_EXECUTABLE(${OSGI_APP} MACOSX_BUNDLE "src/application/berryMain.cpp") -# ADD_EXECUTABLE(${OSGI_APP} "src/application/berryMain.cpp") -TARGET_LINK_LIBRARIES(${OSGI_APP} ${PLUGIN_TARGET} mbilog) -IF (BLUEBERRY_ENABLED_TEST_PLUGINS) - ADD_DEPENDENCIES(${OSGI_APP} ${BLUEBERRY_ENABLED_TEST_PLUGINS}) + +TARGET_LINK_LIBRARIES(${OSGI_APP} ${PROJECT_NAME} mbilog) +IF (_ctk_test_plugins) + ADD_DEPENDENCIES(${OSGI_APP} ${_ctk_test_plugins}) ADD_DEPENDENCIES(BlueBerry ${OSGI_APP}) SET_PROPERTY(TARGET ${OSGI_APP} APPEND PROPERTY LABELS BlueBerry) ENDIF() -SET(BLUEBERRY_PLUGIN_CACHE_DIR "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/plugin_cache") - CONFIGURE_FILE(src/application/solstice.ini ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${OSGI_APP}.ini) -SET_TARGET_PROPERTIES(${OSGI_APP} PROPERTIES INSTALL_RPATH "${CMAKE_INSTALL_RPATH};${CMAKE_INSTALL_PREFIX}/bin/BlueBerry/org.blueberry.osgi/bin") -# MITK_INSTALL_TARGETS(EXECUTABLES ${OSGI_APP} GLOB_PLUGINS ) -# MITK_INSTALL_TARGETS(EXECUTABLES ${OSGI_APP} LIBRARY_DIRS ${CMAKE_INSTALL_PREFIX}/bin) -# MITK_INSTALL_TARGETS(EXECUTABLES ${OSGI_APP} LIBRARY_DIRS ${CMAKE_INSTALL_PREFIX}/bin PLUGINS ${CMAKE_INSTALL_PREFIX}/bin/BlueBerry/org.blueberry.osgi/bin/liborg_blueberry_osgid.dylib) +ADD_EXECUTABLE(${OSGI_UI_APP} MACOSX_BUNDLE "src/application/berryMainUI.cpp") + +TARGET_LINK_LIBRARIES(${OSGI_UI_APP} ${PROJECT_NAME} mbilog) +IF (_ctk_test_plugins) + ADD_DEPENDENCIES(${OSGI_UI_APP} ${_ctk_test_plugins}) + ADD_DEPENDENCIES(BlueBerry ${OSGI_UI_APP}) + SET_PROPERTY(TARGET ${OSGI_UI_APP} APPEND PROPERTY LABELS BlueBerry) +ENDIF() + +CONFIGURE_FILE(src/application/solstice.ini + ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${OSGI_UI_APP}.ini) + +SET(BLUEBERRY_PLUGIN_CACHE_DIR "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/plugin_cache") + +CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/src/berryConfig.h.in" "${CMAKE_CURRENT_BINARY_DIR}/berryConfig.h" @ONLY) diff --git a/BlueBerry/Bundles/org.blueberry.osgi/META-INF/MANIFEST.MF b/BlueBerry/Bundles/org.blueberry.osgi/META-INF/MANIFEST.MF deleted file mode 100644 index a9925cc1e8..0000000000 --- a/BlueBerry/Bundles/org.blueberry.osgi/META-INF/MANIFEST.MF +++ /dev/null @@ -1,7 +0,0 @@ -Manifest-Version: 1.0 -Bundle-Name: BlueBerry OSGi System Bundle -Bundle-SymbolicName: org.blueberry.osgi -Bundle-Version: 1.0.0 -Bundle-Vendor: DKFZ, Medical and Biological Informatics -Bundle-Activator: berry::SystemBundleActivator -Berry-SystemBundle: true \ No newline at end of file diff --git a/BlueBerry/Bundles/org.blueberry.osgi/files.cmake b/BlueBerry/Bundles/org.blueberry.osgi/files.cmake index e59681a85d..99ffda3099 100644 --- a/BlueBerry/Bundles/org.blueberry.osgi/files.cmake +++ b/BlueBerry/Bundles/org.blueberry.osgi/files.cmake @@ -1,64 +1,77 @@ +# Files which should be processed by Qts moc +SET(MOC_H_FILES + src/internal/berryCTKPluginActivator.h + src/internal/berryExtensionPointService.h +) + +SET(CACHED_RESOURCE_FILES + plugin.xml +) + SET(EVENT_CPP_FILES berryBundleEvent.cpp berryPlatformEvent.cpp ) SET(INTERNAL_CPP_FILES berryBundle.cpp berryBundleContext.cpp berryBundleDirectory.cpp berryBundleManifest.cpp berryCodeCache.cpp + berryCTKPluginActivator.cpp berryDefaultActivator.cpp berryConfigurationElement.cpp berryExtension.cpp berryExtensionPoint.cpp berryExtensionPointService.cpp berryInternalPlatform.cpp berryPlatformLogChannel.cpp + berryProvisioningInfo.cpp berrySystemBundle.cpp berrySystemBundleActivator.cpp + berrySystemBundleManifest.cpp ) SET(SERVICE_CPP_FILES berryIExtensionPointService.cpp berryService.cpp berryServiceRegistry.cpp ) SET(SRC_CPP_FILES berryDebugBreakpointManager.cpp berryException.cpp berryIBundleManifest.cpp berryIDebugObjectListener.cpp berryBundleLoader.cpp berryDebugUtil.cpp berryObject.cpp berryObjects.cpp berryPlatform.cpp berryPlatformException.cpp berryPlugin.cpp berryStackTrace.cpp # application application/berryIApplication.cpp application/berryStarter.cpp ) SET(CPP_FILES manifest.cpp) foreach(file ${SRC_CPP_FILES}) SET(CPP_FILES ${CPP_FILES} src/${file}) endforeach(file ${SRC_CPP_FILES}) foreach(file ${EVENT_CPP_FILES}) SET(CPP_FILES ${CPP_FILES} src/event/${file}) endforeach(file ${EVENT_CPP_FILES}) foreach(file ${INTERNAL_CPP_FILES}) SET(CPP_FILES ${CPP_FILES} src/internal/${file}) endforeach(file ${INTERNAL_CPP_FILES}) foreach(file ${SERVICE_CPP_FILES}) SET(CPP_FILES ${CPP_FILES} src/service/${file}) -endforeach(file ${SERVICE_CPP_FILES}) \ No newline at end of file +endforeach(file ${SERVICE_CPP_FILES}) diff --git a/BlueBerry/Bundles/org.blueberry.osgi/includes.cmake b/BlueBerry/Bundles/org.blueberry.osgi/includes.cmake deleted file mode 100755 index 2926e3aee3..0000000000 --- a/BlueBerry/Bundles/org.blueberry.osgi/includes.cmake +++ /dev/null @@ -1,5 +0,0 @@ -SET(ADDITIONAL_INCLUDE_DIRECTORIES - src/application - src/event - src/service -) \ No newline at end of file diff --git a/BlueBerry/Bundles/org.blueberry.osgi/manifest_headers.cmake b/BlueBerry/Bundles/org.blueberry.osgi/manifest_headers.cmake new file mode 100644 index 0000000000..23e275811f --- /dev/null +++ b/BlueBerry/Bundles/org.blueberry.osgi/manifest_headers.cmake @@ -0,0 +1,6 @@ +set(Plugin-Name "BlueBerry OSGi System Bundle") +set(Plugin-Version "1.0.0") +set(Plugin-Vendor "DKFZ, Medical and Biological Informatics") +set(Plugin-ContactAddress "http://www.mitk.org") +set(Plugin-ActivationPolicy "eager") + diff --git a/BlueBerry/Bundles/org.blueberry.osgi/src/application/berryIApplication.h b/BlueBerry/Bundles/org.blueberry.osgi/src/application/berryIApplication.h index 0b09dede6d..1f8083b40b 100644 --- a/BlueBerry/Bundles/org.blueberry.osgi/src/application/berryIApplication.h +++ b/BlueBerry/Bundles/org.blueberry.osgi/src/application/berryIApplication.h @@ -1,99 +1,103 @@ /*========================================================================= Program: BlueBerry Platform Language: C++ Date: $Date$ Version: $Revision$ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #ifndef BERRYIAPPLICATION_H_ #define BERRYIAPPLICATION_H_ -#include "../berryOSGiDll.h" +#include #include "../berryMacros.h" +#include + namespace berry { /** * Bootstrap type for an application. An IApplication represent executable * entry points into an application. An IApplication can be configured into * the Platform's org.blueberry.osgi.applications extension-point. * *

* Clients may implement this interface. *

* * @since 1.0 */ struct BERRY_OSGI IApplication { berryManifestMacro(IApplication, berry); /** * Exit object indicating normal termination */ static const int EXIT_OK; /** * Exit object requesting platform restart */ static const int EXIT_RESTART; /** * Exit object requesting that the command passed back be executed. Typically * this is used to relaunch BlueBerry with different command line arguments. When the executable is * relaunched the command line will be retrieved from the BlueBerry.exitdata system property. */ static const int EXIT_RELAUNCH; virtual ~IApplication(); /** * Starts this application with the given context and returns a result. This * method must not exit until the application is finished and is ready to exit. * The content of the context is unchecked and should conform to the expectations of * the application being invoked.

* * Applications can return any object they like. If an Integer is returned * it is treated as the program exit code if BlueBerry is exiting. *

* Note: This method is called by the platform; it is not intended * to be called directly by clients. *

* @return the return value of the application * @see #EXIT_OK * @see #EXIT_RESTART * @see #EXIT_RELAUNCH * @param context the application context to pass to the application * @exception Exception if there is a problem running this application. */ virtual int Start() = 0; /** * Forces this running application to exit. This method should wait until the * running application is ready to exit. The {@link #start()} * should already have exited or should exit very soon after this method exits

* * This method is only called to force an application to exit. * This method will not be called if an application exits normally from * the {@link #start()} method. *

* Note: This method is called by the platform; it is not intended * to be called directly by clients. *

*/ virtual void Stop() = 0; }; } +Q_DECLARE_INTERFACE(berry::IApplication, "org.blueberry.IApplication") + #endif /*BERRYIAPPLICATION_H_*/ diff --git a/BlueBerry/Bundles/org.blueberry.osgi/src/application/berryMain.cpp b/BlueBerry/Bundles/org.blueberry.osgi/src/application/berryMain.cpp index e227f1bf27..db25ddf227 100644 --- a/BlueBerry/Bundles/org.blueberry.osgi/src/application/berryMain.cpp +++ b/BlueBerry/Bundles/org.blueberry.osgi/src/application/berryMain.cpp @@ -1,23 +1,30 @@ /*========================================================================= Program: BlueBerry Platform Language: C++ Date: $Date$ Version: $Revision$ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #include "berryStarter.h" +#include + int main(int argc, char** argv) { + // Create a QCoreApplication instance first + QCoreApplication app(argc, argv); + app.setApplicationName("solstice"); + app.setOrganizationName("DKFZ"); + return berry::Starter::Run(argc, argv, 0); } diff --git a/BlueBerry/Bundles/org.blueberry.osgi/src/application/berryMain.cpp b/BlueBerry/Bundles/org.blueberry.osgi/src/application/berryMainUI.cpp similarity index 80% copy from BlueBerry/Bundles/org.blueberry.osgi/src/application/berryMain.cpp copy to BlueBerry/Bundles/org.blueberry.osgi/src/application/berryMainUI.cpp index e227f1bf27..5790615a92 100644 --- a/BlueBerry/Bundles/org.blueberry.osgi/src/application/berryMain.cpp +++ b/BlueBerry/Bundles/org.blueberry.osgi/src/application/berryMainUI.cpp @@ -1,23 +1,30 @@ /*========================================================================= Program: BlueBerry Platform Language: C++ Date: $Date$ Version: $Revision$ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #include "berryStarter.h" +#include + int main(int argc, char** argv) { + // Create a QCoreApplication instance first + QApplication app(argc, argv); + app.setApplicationName("solstice_ui"); + app.setOrganizationName("DKFZ"); + return berry::Starter::Run(argc, argv, 0); } diff --git a/BlueBerry/Bundles/org.blueberry.osgi/src/application/berryStarter.cpp b/BlueBerry/Bundles/org.blueberry.osgi/src/application/berryStarter.cpp index ecdcaa5449..838b716a52 100644 --- a/BlueBerry/Bundles/org.blueberry.osgi/src/application/berryStarter.cpp +++ b/BlueBerry/Bundles/org.blueberry.osgi/src/application/berryStarter.cpp @@ -1,158 +1,176 @@ /*========================================================================= Program: BlueBerry Platform Language: C++ Date: $Date$ Version: $Revision$ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #include "berryLog.h" #include "berryStarter.h" #include "../berryPlatform.h" #include "../internal/berryInternalPlatform.h" #include "../service/berryIExtensionPointService.h" #include "../service/berryIConfigurationElement.h" #include "berryIApplication.h" #include +#include + namespace berry { const std::string Starter::XP_APPLICATIONS = "org.blueberry.osgi.applications"; int Starter::Run(int& argc, char** argv, Poco::Util::AbstractConfiguration* config) { + // The CTK PluginFramework needs a QCoreApplication + if (!qApp) + { + BERRY_FATAL << "No QCoreApplication instance found. You need to create one prior to calling Starter::Run()"; + } + InternalPlatform* platform = InternalPlatform::GetInstance(); int returnCode = 0; // startup the internal platform platform->Initialize(argc, argv, config); platform->Launch(); bool consoleLog = platform->ConsoleLog(); // run the application IExtensionPointService::Pointer service = platform->GetExtensionPointService(); if (service == 0) { platform->GetLogger()->log( Poco::Message( "Starter", "The extension point service could not be retrieved. This usually indicates that the BlueBerry OSGi plug-in could not be loaded.", Poco::Message::PRIO_FATAL)); std::unexpected(); returnCode = 1; } else { IConfigurationElement::vector extensions( service->GetConfigurationElementsFor(Starter::XP_APPLICATIONS)); IConfigurationElement::vector::iterator iter; for (iter = extensions.begin(); iter != extensions.end();) { if ((*iter)->GetName() != "application") iter = extensions.erase(iter); else ++iter; } std::string argApplication = Platform::GetConfiguration().getString( Platform::ARG_APPLICATION, ""); IApplication* app = 0; if (extensions.size() == 0) { BERRY_FATAL - << "No extensions configured into extension-point 'org.blueberry.core.runtime.applications' found. Aborting.\n"; + << "No extensions configured into extension-point '" << Starter::XP_APPLICATIONS << "' found. Aborting.\n"; returnCode = 0; } else if (extensions.size() == 1) { if (!argApplication.empty()) BERRY_INFO(consoleLog) - << "One 'org.blueberry.core.runtime.applications' extension found, ignoring " + << "One '" << Starter::XP_APPLICATIONS << "' extension found, ignoring " << Platform::ARG_APPLICATION << " argument.\n"; std::vector runs( extensions[0]->GetChildren("run")); app = runs.front()->CreateExecutableExtension ("class"); + if (app == 0) + { + // support legacy BlueBerry extensions + app = runs.front()->CreateExecutableExtension ("class", IApplication::GetManifestName()); + } } else { if (argApplication.empty()) { BERRY_WARN << "You must provide an application id via \"" << Platform::ARG_APPLICATION << "=\""; BERRY_INFO << "Possible application ids are:"; for (iter = extensions.begin(); iter != extensions.end(); ++iter) { std::string appid; if ((*iter)->GetAttribute("id", appid) && !appid.empty()) { BERRY_INFO << appid; } } returnCode = 0; } else { for (iter = extensions.begin(); iter != extensions.end(); ++iter) { BERRY_INFO(consoleLog) << "Checking applications extension from: " << (*iter)->GetContributor() << std::endl; std::string appid; if ((*iter)->GetAttribute("id", appid)) { BERRY_INFO(consoleLog) << "Found id: " << appid << std::endl; if (appid.size() > 0 && appid == argApplication) { std::vector runs( (*iter)->GetChildren("run")); - app = runs.front()->CreateExecutableExtension ( - "class"); + app = runs.front()->CreateExecutableExtension ("class"); + if (app == 0) + { + // try legacy BlueBerry extensions + app = runs.front()->CreateExecutableExtension ( + "class", IApplication::GetManifestName()); + } break; } } else throw CoreException("missing attribute", "id"); } } } if (app == 0) { BERRY_ERROR << "Could not create executable application extension for id: " << argApplication << std::endl; returnCode = 1; } else { returnCode = app->Start(); } } platform->Shutdown(); return returnCode; } } diff --git a/BlueBerry/Bundles/org.blueberry.osgi/src/application/berryStarter.h b/BlueBerry/Bundles/org.blueberry.osgi/src/application/berryStarter.h index c98a74ef53..519cb8f3d1 100644 --- a/BlueBerry/Bundles/org.blueberry.osgi/src/application/berryStarter.h +++ b/BlueBerry/Bundles/org.blueberry.osgi/src/application/berryStarter.h @@ -1,41 +1,41 @@ /*========================================================================= Program: BlueBerry Platform Language: C++ Date: $Date$ Version: $Revision$ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #ifndef BERRYSTARTER_H_ #define BERRYSTARTER_H_ -#include "../berryOSGiDll.h" +#include #include "../berryPlatform.h" #include namespace berry { class BERRY_OSGI Starter { public: static const std::string XP_APPLICATIONS; static int Run(int& argc, char** argv, Poco::Util::AbstractConfiguration* config = 0); }; } #endif /*BERRYSTARTER_H_*/ diff --git a/BlueBerry/Bundles/org.blueberry.osgi/src/application/solstice.ini b/BlueBerry/Bundles/org.blueberry.osgi/src/application/solstice.ini index 1cc07fb99a..30c36eee76 100644 --- a/BlueBerry/Bundles/org.blueberry.osgi/src/application/solstice.ini +++ b/BlueBerry/Bundles/org.blueberry.osgi/src/application/solstice.ini @@ -1,3 +1,2 @@ BlueBerry.home=@BLUEBERRY_BINARY_DIR@ -BlueBerry.plugin_cache_dir=@BLUEBERRY_PLUGIN_CACHE_DIR@ -BlueBerry.plugin_dirs=@BLUEBERRY_PLUGINS_OUTPUT_DIR@;@BLUEBERRY_TEST_PLUGINS_OUTPUT_DIR@ \ No newline at end of file +BlueBerry.provisioning=@BLUEBERRY_TESTING_PROVISIONING_FILE@ diff --git a/BlueBerry/Bundles/org.blueberry.osgi/src/berryBundleLoader.cpp b/BlueBerry/Bundles/org.blueberry.osgi/src/berryBundleLoader.cpp index 2285256389..c9364ac473 100644 --- a/BlueBerry/Bundles/org.blueberry.osgi/src/berryBundleLoader.cpp +++ b/BlueBerry/Bundles/org.blueberry.osgi/src/berryBundleLoader.cpp @@ -1,454 +1,505 @@ /*========================================================================= Program: BlueBerry Platform Language: C++ Date: $Date$ Version: $Revision$ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #include "berryLog.h" #include "berryBundleLoader.h" #include "internal/berryBundleContext.h" #include "internal/berryBundleDirectory.h" #include "event/berryBundleEvents.h" #include "internal/berryDefaultActivator.h" #include "internal/berrySystemBundleActivator.h" #include "internal/berryCodeCache.h" #include "internal/berryInternalPlatform.h" #include "berryPlugin.h" #include "berryPlatform.h" #include "berryPlatformException.h" #include "service/berryIExtensionPointService.h" #include namespace berry { BundleLoader::BundleLoader(CodeCache* codeCache, Poco::Logger& logger) //, BundleFactory* bundleFactory, BundleContextFactory* bundleContextFactory); : m_CodeCache(codeCache), m_Logger(logger), m_ConsoleLog(false) { m_ConsoleLog = InternalPlatform::GetInstance()->ConsoleLog(); } BundleLoader::~BundleLoader() { } +void BundleLoader::SetCTKPlugins(const QStringList& installedCTKPlugins) +{ + this->installedCTKPlugins = installedCTKPlugins; +} + Poco::Logger& BundleLoader::GetLogger() const { return m_Logger; } IBundleContext::Pointer BundleLoader::GetContextForBundle(IBundle::ConstPointer bundle) { Poco::Mutex::ScopedLock lock(m_Mutex); return m_BundleMap[bundle->GetSymbolicName()].m_Context; } Bundle::Pointer BundleLoader::CreateBundle(const Poco::Path& path) { BundleDirectory::Pointer bundleStorage(new BundleDirectory(path)); Bundle::Pointer bundle(new Bundle(*this, bundleStorage)); + if (bundle->GetState() == IBundle::BUNDLE_INSTALLED && + installedCTKPlugins.contains(QString::fromStdString(bundle->GetSymbolicName()))) + { + BERRY_WARN << "Ignoring legacy BlueBerry bundle " << bundle->GetSymbolicName() + << " because a CTK plug-in with the same name already exists."; + return Bundle::Pointer(0); + } + if (bundle->GetState() == IBundle::BUNDLE_INSTALLED && bundle->IsSystemBundle()) { bundle = new SystemBundle(*this, bundleStorage); m_SystemBundle = bundle; } //BundleEvent event(bundle, BundleEvent::EV_BUNDLE_INSTALLED); //m_BundleEvents.bundleInstalled(this, event); return bundle; } BundleEvents& BundleLoader::GetEvents() { return m_BundleEvents; } IBundle::Pointer BundleLoader::FindBundle(const std::string& symbolicName) { if (symbolicName == "system.bundle") return m_SystemBundle; Poco::Mutex::ScopedLock lock(m_Mutex); BundleMap::const_iterator iter; iter = m_BundleMap.find(symbolicName); if (iter == m_BundleMap.end()) return IBundle::Pointer(); return iter->second.m_Bundle; } +std::vector BundleLoader::GetBundles() const +{ + std::vector result; + BundleMap::const_iterator end = m_BundleMap.end(); + for (BundleMap::const_iterator it = m_BundleMap.begin(); it != end; ++it) + { + result.push_back(it->second.m_Bundle); + } + return result; +} + Bundle::Pointer BundleLoader::LoadBundle(const Poco::Path& path) { Bundle::Pointer bundle = this->CreateBundle(path); - this->LoadBundle(bundle); + if (bundle) this->LoadBundle(bundle); return bundle; } void BundleLoader::LoadBundle(Bundle::Pointer bundle) { if (bundle->GetState() == IBundle::BUNDLE_INSTALLED || bundle->GetState() == IBundle::BUNDLE_RESOLVED) { Poco::Mutex::ScopedLock lock(m_Mutex); if (m_BundleMap[bundle->GetSymbolicName()].m_Bundle.IsNull()) { BundleInfo bundleInfo; bundleInfo.m_Bundle = bundle; bundleInfo.m_ClassLoader = new ActivatorClassLoader(); Poco::Path path; Platform::GetStatePath(path, bundle); bundleInfo.m_Context = new BundleContext(*this, bundle, path); m_BundleMap[bundle->GetSymbolicName()] = bundleInfo; this->InstallLibraries(bundle); //BundleEvent event(bundle, BundleEvent::EV_BUNDLE_LOADED); //m_BundleEvents.bundleLoaded(this, event); } else { //TODO version conflict check } } else { throw BundleStateException("The bundle must be in state INSTALLED in order to be loaded."); } } Poco::Path BundleLoader::GetPathForLibrary(const std::string& libraryName) { return m_CodeCache->GetPathForLibrary(libraryName); } Poco::Path BundleLoader::GetLibraryPathFor(IBundle::Pointer bundle) { std::string libName = bundle->GetActivatorLibrary(); if (libName.empty()) libName = "lib" + bundle->GetSymbolicName(); return this->GetPathForLibrary(libName); } std::string BundleLoader::GetContributionsPathFor(IBundle::Pointer /*bundle*/) { return "plugin.xml"; } void BundleLoader::ResolveBundle(IBundle::Pointer bundle) { try { BERRY_INFO(m_ConsoleLog) << "Trying to resolve bundle " << bundle->GetSymbolicName(); bundle->Resolve(); BERRY_INFO(m_ConsoleLog) << "Bundle " << bundle->GetSymbolicName() << ": " << bundle->GetStateString(); } catch (BundleResolveException exc) { BERRY_ERROR << "Bundle resolve failed: " << exc.displayText(); } // if (bundle->IsResolved()) // { // BundleEvent event(bundle, BundleEvent::EV_BUNDLE_RESOLVED); // m_BundleEvents.bundleResolved(this, event); // } } void BundleLoader::ResolveAllBundles() { Poco::Mutex::ScopedLock lock(m_Mutex); BundleMap::iterator iter; for (iter = m_BundleMap.begin(); iter != m_BundleMap.end(); iter++) { this->ResolveBundle(iter->second.m_Bundle); } } void BundleLoader::ListLibraries(IBundle::Pointer bundle, std::vector& list) { ListLibraries(bundle, list, "bin/"); #ifdef CMAKE_INTDIR ListLibraries(bundle, list, "bin/" CMAKE_INTDIR "/"); #endif } void BundleLoader::ListLibraries(IBundle::Pointer bundle, std::vector& list, const std::string& baseDir) { std::vector tmpList; bundle->GetStorage().List(baseDir, tmpList); std::string::size_type suf = Poco::SharedLibrary::suffix().size(); std::vector::iterator iter; for (iter = tmpList.begin(); iter != tmpList.end(); ) { if (bundle->GetStorage().IsDirectory(baseDir + *iter)) { // uncomment the following line for a recursive lookup //this->ListLibraries(bundle, list, baseDir + *iter + "/"); iter = tmpList.erase(iter); } else { if (iter->substr(iter->size() - suf) == Poco::SharedLibrary::suffix()) { iter->erase(iter->size() - suf); iter->insert(0, baseDir); ++iter; } else { iter = tmpList.erase(iter); } } } list.insert(list.end(), tmpList.begin(), tmpList.end()); } void BundleLoader::InstallLibraries(IBundle::Pointer bundle, bool copy) { std::vector libraries; this->ListLibraries(bundle, libraries); std::vector::iterator iter; for (iter = libraries.begin(); iter != libraries.end(); ++iter) { if (iter->empty()) continue; //BERRY_INFO << "Testing CodeCache for: " << *iter << std::endl; std::size_t separator = iter->find_last_of("/"); std::string libFileName = *iter; if (separator != std::string::npos) libFileName = iter->substr(separator+1); if (!m_CodeCache->HasLibrary(libFileName)) { std::string libDir = ""; if (separator != std::string::npos) libDir += iter->substr(0, separator); // Check if we should copy the dll (from a ZIP file for example) if (copy) { //TODO This copies all files which start with *iter to the // plugin cache. This is necessary for Windows, for example, // where a .dll file is accompanied by a set of other files. // This should be extended to check for the right dll files, since // it would be possible (and a good idea anyway) to put multiple // versions of the same library in the ZIP file, targeting different // compilers for example. std::vector files; bundle->GetStorage().List(libDir, files); for (std::vector::iterator fileName = files.begin(); fileName != files.end(); ++fileName) { std::size_t size = std::min(libFileName.size(), fileName->size()); if (fileName->compare(0, size, libFileName) != 0) continue; std::istream* istr = bundle->GetResource(libDir + *fileName); m_CodeCache->InstallLibrary(*iter, *istr); delete istr; } } else { Poco::Path bundlePath = bundle->GetStorage().GetPath(); bundlePath.append(Poco::Path::forDirectory(libDir)); // On Windows, we set the path environment variable to include // the path to the library, so the loader can find it. We do this // programmatically because otherwise, a user would have to edit // a batch file every time he adds a new plugin from outside the // build system. #ifdef BERRY_OS_FAMILY_WINDOWS std::string pathEnv = Poco::Environment::get("PATH", ""); if (!pathEnv.empty()) pathEnv += ";"; pathEnv += bundlePath.toString(); Poco::Environment::set("PATH", pathEnv); #endif m_CodeCache->InstallLibrary(libFileName, bundlePath); } } } } void BundleLoader::ReadAllContributions() { Poco::Mutex::ScopedLock lock(m_Mutex); BundleMap::iterator iter; for (iter = m_BundleMap.begin(); iter != m_BundleMap.end(); ++iter) { - if (iter->second.m_Bundle->IsResolved()) + if (iter->second.m_Bundle && iter->second.m_Bundle->IsResolved()) this->ReadContributions(iter->second.m_Bundle); } } void BundleLoader::ReadContributions(IBundle::Pointer bundle) { this->ReadDependentContributions(bundle); IExtensionPointService::Pointer service = Platform::GetExtensionPointService(); if (service->HasContributionFrom(bundle->GetSymbolicName())) return; std::istream* istr = bundle->GetResource(this->GetContributionsPathFor(bundle)); if (istr) { service->AddContribution(*istr, bundle->GetSymbolicName()); delete istr; } } void BundleLoader::ReadDependentContributions(IBundle::Pointer bundle) { Poco::Mutex::ScopedLock lock(m_Mutex); const IBundleManifest::Dependencies& deps = bundle->GetRequiredBundles(); IBundleManifest::Dependencies::const_iterator iter; for (iter = deps.begin(); iter != deps.end(); ++iter) { - this->ReadContributions(m_BundleMap[iter->symbolicName].m_Bundle); + BundleMap::const_iterator depIter = m_BundleMap.find(iter->symbolicName); + if (depIter != m_BundleMap.end()) + { + // only read contributions from legacy BlueBerry bundles + if (IBundle::Pointer depBundle = depIter->second.m_Bundle) + { + this->ReadContributions(depBundle); + } + } } } void BundleLoader::StartAllBundles() { Poco::Mutex::ScopedLock lock(m_Mutex); BundleMap::iterator iter; for (iter = m_BundleMap.begin(); iter != m_BundleMap.end(); ++iter) { try { - if (iter->second.m_Bundle->GetActivationPolicy() == IBundleManifest::EAGER && + if (iter->second.m_Bundle && iter->second.m_Bundle->GetActivationPolicy() == IBundleManifest::EAGER && !iter->second.m_Bundle->IsSystemBundle()) this->StartBundle(iter->second.m_Bundle); } catch (Poco::Exception exc) { BERRY_ERROR << exc.displayText() << std::endl; } } } void BundleLoader::StartBundle(Bundle::Pointer bundle) { Poco::Mutex::ScopedLock lock(m_Mutex); if (bundle->GetState() != IBundle::BUNDLE_RESOLVED) return; this->StartDependencies(bundle); BundleInfo info = m_BundleMap[bundle->GetSymbolicName()]; IBundleActivator* activator = this->LoadActivator(info); Plugin* plugin = dynamic_cast(activator); if (plugin) plugin->m_Bundle = bundle; bundle->SetActivator(activator); bundle->Start(); } void BundleLoader::StartSystemBundle(SystemBundle::Pointer bundle) { Poco::Mutex::ScopedLock lock(m_Mutex); if (bundle->IsStarted()) return; BundleInfo info = m_BundleMap[bundle->GetSymbolicName()]; //IBundleActivator* activator = this->LoadActivator(info); IBundleActivator* activator = new SystemBundleActivator(); bundle->SetActivator(activator); activator->Start(info.m_Context); } void BundleLoader::StartDependencies(Bundle::Pointer bundle) { Poco::Mutex::ScopedLock lock(m_Mutex); const IBundleManifest::Dependencies& deps = bundle->GetRequiredBundles(); IBundleManifest::Dependencies::const_iterator iter; + QList > ctkPlugins = CTKPluginActivator::getPluginContext()->getPlugins(); for (iter = deps.begin(); iter != deps.end(); ++iter) { - this->StartBundle(m_BundleMap[iter->symbolicName].m_Bundle); + BundleMap::const_iterator depIter = m_BundleMap.find(iter->symbolicName); + if (depIter != m_BundleMap.end()) + { + if (Bundle::Pointer depBundle = depIter->second.m_Bundle) + { + this->StartBundle(depBundle); + } + } + else + { + foreach (QSharedPointer ctkPlugin, ctkPlugins) + { + if (ctkPlugin->getSymbolicName() == QString::fromStdString(iter->symbolicName)) + { + ctkPlugin->start(0); + break; + } + } + } } } IBundleActivator* BundleLoader::LoadActivator(BundleInfo& bundleInfo) { Poco::Mutex::ScopedLock lock(m_Mutex); std::string activator = bundleInfo.m_Bundle->GetActivatorClass(); if (activator == "") return new DefaultActivator(); Poco::Path libPath = this->GetLibraryPathFor(bundleInfo.m_Bundle); std::string strLibPath(libPath.toString()); BERRY_INFO(m_ConsoleLog) << "Loading activator library: " << strLibPath; try { /* retrieves only an empty string and its not required #ifdef BERRY_OS_FAMILY_WINDOWS char cDllPath[512]; GetDllDirectory(512, cDllPath); BERRY_INFO << "Dll Path: " << cDllPath << std::endl; #endif */ bundleInfo.m_ClassLoader->loadLibrary(strLibPath); return bundleInfo.m_ClassLoader->create(activator); } catch (Poco::LibraryLoadException exc) { BERRY_ERROR << "Could not create Plugin activator. Did you export the class \"" << activator << "\" ?\n" << " Exception displayText(): " << exc.displayText(); exc.rethrow(); } return 0; } } // namespace berry diff --git a/BlueBerry/Bundles/org.blueberry.osgi/src/berryBundleLoader.h b/BlueBerry/Bundles/org.blueberry.osgi/src/berryBundleLoader.h index 0dd5d58f00..5960af7996 100644 --- a/BlueBerry/Bundles/org.blueberry.osgi/src/berryBundleLoader.h +++ b/BlueBerry/Bundles/org.blueberry.osgi/src/berryBundleLoader.h @@ -1,130 +1,138 @@ /*========================================================================= Program: BlueBerry Platform Language: C++ Date: $Date$ Version: $Revision$ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #ifndef BERRYBUNDLELOADER_H_ #define BERRYBUNDLELOADER_H_ #include "Poco/ClassLoader.h" #include "Poco/Mutex.h" #include "Poco/Path.h" #include "Poco/Any.h" #include "Poco/SharedPtr.h" #include "Poco/Logger.h" #include #include +#include + #include "event/berryBundleEvents.h" #include "berryIBundleActivator.h" #include "internal/berryBundle.h" #include "internal/berrySystemBundle.h" namespace berry { class CodeCache; struct IBundleContext; /** * Intentionally no BERRY_OSGI macro. This class belongs into "internal" but * needs to stay here. */ class BERRY_OSGI BundleLoader { private: typedef Poco::ClassLoader ActivatorClassLoader; typedef Poco::SharedPtr ActivatorClassLoaderPtr; struct BundleInfo { Bundle::Pointer m_Bundle; ActivatorClassLoaderPtr m_ClassLoader; std::map m_ClassLoaderMap; SmartPointer m_Context; }; typedef std::map BundleMap; BundleMap m_BundleMap; BundleEvents m_BundleEvents; CodeCache* m_CodeCache; mutable Poco::Logger& m_Logger; Bundle::Pointer m_SystemBundle; mutable Poco::Mutex m_Mutex; bool m_ConsoleLog; + QStringList installedCTKPlugins; + IBundleActivator* LoadActivator(BundleInfo& bundleInfo); friend class InternalPlatform; friend class BundleContext; void StartSystemBundle(SmartPointer bundle); void ListLibraries(SmartPointer bundle, std::vector& list, const std::string& baseDir); public: BundleLoader(CodeCache* codeCache, Poco::Logger& logger); //, BundleFactory* bundleFactory, BundleContextFactory* bundleContextFactory); virtual ~BundleLoader(); + void SetCTKPlugins(const QStringList& installedCTKPlugins); + SmartPointer GetContextForBundle(IBundle::ConstPointer bundle); Bundle::Pointer CreateBundle(const Poco::Path& path); BundleEvents& GetEvents(); IBundle::Pointer FindBundle(const std::string& symbolicName); + std::vector GetBundles() const; + Bundle::Pointer LoadBundle(const Poco::Path& path); void LoadBundle(Bundle::Pointer bundle); Poco::Path GetPathForLibrary(const std::string& libraryName); Poco::Path GetLibraryPathFor(SmartPointer bundle); std::string GetContributionsPathFor(SmartPointer bundle); Poco::Logger& GetLogger() const; void ResolveBundle(SmartPointer bundle); void ResolveAllBundles(); void ReadAllContributions(); void ReadContributions(SmartPointer bundle); void ReadDependentContributions(SmartPointer bundle); void ListLibraries(SmartPointer bundle, std::vector& list); void InstallLibraries(SmartPointer bundle, bool copy = false); // start all resolved bundles, except the system bundle // (it is assumed, that the system bundle has already // been started) void StartAllBundles(); void StartBundle(SmartPointer bundle); void StartDependencies(SmartPointer bundle); template C* LoadClass(const std::string& bundleName, const std::string& className); template C* LoadClass(const std::string& bundleName, const std::string& className, const std::string& manifestName); }; } // namespace berry #include "berryBundleLoader.txx" #endif /*BERRYBUNDLELOADER_H_*/ diff --git a/BlueBerry/Bundles/org.blueberry.osgi/src/berryBundleLoader.txx b/BlueBerry/Bundles/org.blueberry.osgi/src/berryBundleLoader.txx index b7faae926f..a83a309822 100644 --- a/BlueBerry/Bundles/org.blueberry.osgi/src/berryBundleLoader.txx +++ b/BlueBerry/Bundles/org.blueberry.osgi/src/berryBundleLoader.txx @@ -1,77 +1,86 @@ /*========================================================================= Program: BlueBerry Platform Language: C++ Date: $Date$ Version: $Revision$ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #ifndef __BERRY_BUNDLE_LOADER_TXX__ #define __BERRY_BUNDLE_LOADER_TXX__ #include #include "berryLog.h" #include "berryIBundleContext.h" namespace berry { template C* BundleLoader::LoadClass(const std::string& bundleName, const std::string& className) { return LoadClass(bundleName, className, C::GetManifestName()); } template C* BundleLoader::LoadClass(const std::string& bundleName, const std::string& className, const std::string& manifestName) { BERRY_INFO(m_ConsoleLog) << "Trying to load class " << className << " with manifest name " << manifestName << " from bundle " << bundleName; - BundleInfo& bundleInfo = m_BundleMap[bundleName]; + + BundleMap::iterator bundleIter = m_BundleMap.find(bundleName); + + if (bundleIter == m_BundleMap.end()) + { + BERRY_INFO(m_ConsoleLog) << "This bundle is not a legacy BlueBerry bundle. Cannot load classes from it."; + return 0; + } + + BundleInfo& bundleInfo = bundleIter->second; // check that bundle is started if (!bundleInfo.m_Bundle->IsStarted()) this->StartBundle(bundleInfo.m_Bundle); Poco::Any* any = bundleInfo.m_ClassLoaderMap[typeid(C).name()]; if (any == 0) { BERRY_INFO(m_ConsoleLog) << "Creating new classloader for type: " << typeid(C).name() << std::endl; any = new Poco::Any(Poco::SharedPtr >(new Poco::ClassLoader())); bundleInfo.m_ClassLoaderMap[typeid(C).name()] = any; } Poco::SharedPtr >& cl = Poco::RefAnyCast > >(*any); std::string libName = "lib" + bundleInfo.m_Bundle->GetSymbolicName(); Poco::Path libPath(bundleInfo.m_Context->GetPathForLibrary(libName)); if (!cl->isLibraryLoaded(libPath.toString())) { BERRY_INFO(m_ConsoleLog) << "Loading library: " << libPath.toString(); - + try { cl->loadLibrary(libPath.toString(), manifestName); } catch (const Poco::LibraryLoadException& e){ BERRY_ERROR << e.displayText(); } } else { BERRY_INFO(m_ConsoleLog) << "Library " << libPath.toString() << " already loaded"; } return cl->create(className); } } #endif // __BERRY_BUNDLE_LOADER_TXX__ diff --git a/BlueBerry/Bundles/org.blueberry.osgi/src/berryDebugBreakpointManager.h b/BlueBerry/Bundles/org.blueberry.osgi/src/berryDebugBreakpointManager.h index 8e94be315d..cfd170d6ee 100644 --- a/BlueBerry/Bundles/org.blueberry.osgi/src/berryDebugBreakpointManager.h +++ b/BlueBerry/Bundles/org.blueberry.osgi/src/berryDebugBreakpointManager.h @@ -1,75 +1,75 @@ /*========================================================================= Program: BlueBerry Platform Language: C++ Date: $Date$ Version: $Revision$ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #ifndef BERRYDEBUGBREAKPOINTMANAGER_H_ #define BERRYDEBUGBREAKPOINTMANAGER_H_ #include #include #include -#include "berryOSGiDll.h" +#include namespace berry { class Object; class BERRY_OSGI DebugBreakpointManager { public: static const std::string BREAKPOINTS_XML; void AddSmartpointerBreakpoint(int smartPointerId, const Object* obj = 0); void AddObjectBreakpoint(unsigned long objectTraceId); void RemoveSmartpointerBreakpoint(int smartPointerId); void RemoveObjectBreakpoint(unsigned long objectTraceId); const std::set& GetObjectBreakpoints() const; const Poco::HashMap& GetSmartPointerBreakpoints() const; bool BreakAtObject(unsigned long traceId) const; bool BreakAtSmartpointer(int spId) const; void SaveState(const Poco::Path& path) const; void RestoreState(const Poco::Path& path); private: friend class DebugUtil; DebugBreakpointManager() {} DebugBreakpointManager(const DebugBreakpointManager&) {} static const std::string BREAKPOINTS_TAG; static const std::string OBJECT_TAG; static const std::string SMARTPOINTER_TAG; static const std::string ID_ATTR; static const std::string CLASSNAME_ATTR; static const std::string OBJECTID_ATTR; static const std::string ENABLED_ATTR; std::set m_ObjectBreakpoints; Poco::HashMap m_SmartPointerBreakpoints; }; } #endif /* BERRYDEBUGBREAKPOINTMANAGER_H_ */ diff --git a/BlueBerry/Bundles/org.blueberry.osgi/src/berryDebugUtil.h b/BlueBerry/Bundles/org.blueberry.osgi/src/berryDebugUtil.h index 876309136c..a99b650755 100755 --- a/BlueBerry/Bundles/org.blueberry.osgi/src/berryDebugUtil.h +++ b/BlueBerry/Bundles/org.blueberry.osgi/src/berryDebugUtil.h @@ -1,108 +1,108 @@ /*========================================================================= Program: BlueBerry Platform Language: C++ Date: $Date$ Version: $Revision$ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #ifndef BERRYDEBUGUTIL_H_ #define BERRYDEBUGUTIL_H_ #include #include #include #include #include #include -#include "berryOSGiDll.h" +#include namespace berry { class Object; class DebugBreakpointManager; struct IDebugObjectListener; template class SmartPointer; class BERRY_OSGI DebugUtil { public: static DebugBreakpointManager* GetBreakpointManager(); static void TraceObject(const Object*); static void TraceObject(unsigned int traceId); static void TraceClass(const std::string& className); static void StopTracing(unsigned int traceId); static void StopTracing(const Object* obj); static void StopTracing(const std::string& className); static bool IsTraced(const Object* object); static bool IsTraced(unsigned int traceId); static bool IsTraced(const std::string& className); static const std::set& GetTracedObjects(); static const Object* GetObject(unsigned int traceId); static std::list GetSmartPointerIDs(const Object* objectPointer, const std::list& excludeList = std::list()); static void GetRegisteredObjects(std::vector& list); static void PrintSmartPointerIDs(const Object* objectPointer, std::ostream& = std::cout, const std::list& excludeList = std::list()); static void ResetObjectSummary(); static bool PrintObjectSummary(bool details = false); static bool PrintObjectSummary(const std::string& className, bool details = false); static void AddObjectListener(SmartPointer listener); static void RemoveObjectListener(SmartPointer listener); static void SaveState(); static void RestoreState(); // ******* for internal use only ************* static unsigned int& GetSmartPointerCounter(); static void RegisterSmartPointer(unsigned int smartPointerId, const Object* objectPointer, bool recordStack = false); static void UnregisterSmartPointer(unsigned int smartPointerId, const Object* objectPointer); static void RegisterObject(const Object* objectPointer); static void UnregisterObject(const Object* objectPointer); // ******************************************* private: static const std::string DEBUG_UTIL_XML; static const std::string DEBUGUTIL_TAG; static const std::string TRACEOBJECT_TAG; static const std::string TRACECLASS_TAG; static const std::string ID_ATTR; static const std::string NAME_ATTR; static bool GetPersistencePath(Poco::Path& path); static Poco::HashMap > m_TraceIdToSmartPointerMap; typedef Poco::HashMap TraceIdToObjectType; static TraceIdToObjectType m_TraceIdToObjectMap; static std::set m_TracedObjects; static std::set m_TracedClasses; }; } #endif /* BERRYDEBUGUTIL_H_ */ diff --git a/BlueBerry/Bundles/org.blueberry.osgi/src/berryException.h b/BlueBerry/Bundles/org.blueberry.osgi/src/berryException.h index 6efca0c2e5..0d594ddb2d 100755 --- a/BlueBerry/Bundles/org.blueberry.osgi/src/berryException.h +++ b/BlueBerry/Bundles/org.blueberry.osgi/src/berryException.h @@ -1,31 +1,31 @@ /*========================================================================= Program: BlueBerry Platform Language: C++ Date: $Date$ Version: $Revision$ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #ifndef BERRYEXCEPTION_H_ #define BERRYEXCEPTION_H_ -#include "berryOSGiDll.h" +#include #include namespace berry { POCO_DECLARE_EXCEPTION(BERRY_OSGI, BadWeakPointerException, Poco::Exception) } #endif /* BERRYEXCEPTION_H_ */ diff --git a/BlueBerry/Bundles/org.blueberry.osgi/src/berryFlags.h b/BlueBerry/Bundles/org.blueberry.osgi/src/berryFlags.h index f7ff4cde22..0ac251e568 100755 --- a/BlueBerry/Bundles/org.blueberry.osgi/src/berryFlags.h +++ b/BlueBerry/Bundles/org.blueberry.osgi/src/berryFlags.h @@ -1,86 +1,86 @@ /*========================================================================= Program: BlueBerry Platform Language: C++ Date: $Date$ Version: $Revision$ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #ifndef BERRYFLAGS_H_ #define BERRYFLAGS_H_ -#include "berryOSGiDll.h" +#include namespace berry { class BERRY_OSGI Flag { int i; public: inline Flag(int i); inline operator int() const { return i; } }; inline Flag::Flag(int ai) : i(ai) {} class BERRY_OSGI IncompatibleFlag { int i; public: inline explicit IncompatibleFlag(int i); inline operator int() const { return i; } }; inline IncompatibleFlag::IncompatibleFlag(int ai) : i(ai) {} template class Flags { typedef void **Zero; int i; public: typedef Enum enum_type; inline Flags(const Flags &f) : i(f.i) {} inline Flags(Enum f) : i(f) {} inline Flags(Zero = 0) : i(0) {} inline Flags(Flag f) : i(f) {} inline Flags &operator=(const Flags &f) { i = f.i; return *this; } inline Flags &operator&=(int mask) { i &= mask; return *this; } inline Flags &operator&=(unsigned int mask) { i &= mask; return *this; } inline Flags &operator|=(Flags f) { i |= f.i; return *this; } inline Flags &operator|=(Enum f) { i |= f; return *this; } inline Flags &operator^=(Flags f) { i ^= f.i; return *this; } inline Flags &operator^=(Enum f) { i ^= f; return *this; } inline operator int() const { return i; } inline Flags operator|(Flags f) const { Flags g; g.i = i | f.i; return g; } inline Flags operator|(Enum f) const { Flags g; g.i = i | f; return g; } inline Flags operator^(Flags f) const { Flags g; g.i = i ^ f.i; return g; } inline Flags operator^(Enum f) const { Flags g; g.i = i ^ f; return g; } inline Flags operator&(int mask) const { Flags g; g.i = i & mask; return g; } inline Flags operator&(unsigned int mask) const { Flags g; g.i = i & mask; return g; } inline Flags operator&(Enum f) const { Flags g; g.i = i & f; return g; } inline Flags operator~() const { Flags g; g.i = ~i; return g; } inline bool operator!() const { return !i; } inline bool TestFlag(Enum f) const { return (i & f) == f; } }; } // namespace berry #endif /* BERRYFLAGS_H_ */ diff --git a/BlueBerry/Bundles/org.blueberry.osgi/src/berryIBundleActivator.h b/BlueBerry/Bundles/org.blueberry.osgi/src/berryIBundleActivator.h index 6b2cbc5e61..ac963da864 100644 --- a/BlueBerry/Bundles/org.blueberry.osgi/src/berryIBundleActivator.h +++ b/BlueBerry/Bundles/org.blueberry.osgi/src/berryIBundleActivator.h @@ -1,39 +1,39 @@ /*========================================================================= Program: BlueBerry Platform Language: C++ Date: $Date$ Version: $Revision$ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #ifndef BERRYIBUNDLEACTIVATOR_ #define BERRYIBUNDLEACTIVATOR_ -#include "berryOSGiDll.h" +#include #include "berrySmartPointer.h" namespace berry { struct IBundleContext; struct BERRY_OSGI IBundleActivator { virtual void Start(SmartPointer context) = 0; virtual void Stop(SmartPointer context) = 0; virtual ~IBundleActivator() {}; }; } // namespace berry #endif /*BERRYIBUNDLEACTIVATOR_*/ diff --git a/BlueBerry/Bundles/org.blueberry.osgi/src/berryIDebugObjectListener.h b/BlueBerry/Bundles/org.blueberry.osgi/src/berryIDebugObjectListener.h index 46adc7223d..55e0929371 100644 --- a/BlueBerry/Bundles/org.blueberry.osgi/src/berryIDebugObjectListener.h +++ b/BlueBerry/Bundles/org.blueberry.osgi/src/berryIDebugObjectListener.h @@ -1,100 +1,100 @@ /*========================================================================= Program: BlueBerry Platform Language: C++ Date: $Date$ Version: $Revision$ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #ifndef BERRYIDEBUGOBJECTLISTENER_H_ #define BERRYIDEBUGOBJECTLISTENER_H_ #include #include -#include "berryOSGiDll.h" +#include namespace berry { struct BERRY_OSGI IDebugObjectListener: public Object { berryInterfaceMacro(IDebugObjectListener, berry); struct BERRY_OSGI Events { enum Type { NONE = 0x00000000, OBJECT_CREATED = 0x00000001, OBJECT_DESTROYED = 0x00000002, OBJECT_TRACING = 0x00000004, SMARTPOINTER_CREATED = 0x00000008, SMARTPOINTER_DESTROYED = 0x00000010, ALL = 0xffffffff }; BERRY_DECLARE_FLAGS(Types, Type) typedef Message1 ObjectEventType; typedef Message3 TracingEventType; typedef Message2 SmartPointerEventType; ObjectEventType objCreatedEvent; ObjectEventType objDestroyedEvent; TracingEventType objTracingEvent; SmartPointerEventType spCreatedEvent; SmartPointerEventType spDestroyedEvent; void AddListener(IDebugObjectListener::Pointer listener); void RemoveListener(IDebugObjectListener::Pointer listener); typedef MessageDelegate1 ObjDelegate; typedef MessageDelegate3 TraceDelegate; typedef MessageDelegate2 SPDelegate; }; virtual ~IDebugObjectListener() { } virtual Events::Types GetEventTypes() const = 0; virtual void ObjectCreated(const Object* /*obj*/) { } virtual void ObjectDestroyed(const Object* /*obj*/) { } virtual void ObjectTracingChanged(unsigned int /*traceId*/, bool /*enabled*/ = true, const Object* /*obj*/ = 0) { } virtual void SmartPointerCreated(unsigned int /*id*/, const Object* /*obj*/) { } virtual void SmartPointerDestroyed(unsigned int /*id*/, const Object* /*obj*/) { } }; } BERRY_DECLARE_OPERATORS_FOR_FLAGS(berry::IDebugObjectListener::Events::Types) #endif /* BERRYIDEBUGOBJECTLISTENER_H_ */ diff --git a/BlueBerry/Bundles/org.blueberry.osgi/src/berryMacros.h b/BlueBerry/Bundles/org.blueberry.osgi/src/berryMacros.h index cefed94049..932bc53afa 100644 --- a/BlueBerry/Bundles/org.blueberry.osgi/src/berryMacros.h +++ b/BlueBerry/Bundles/org.blueberry.osgi/src/berryMacros.h @@ -1,111 +1,117 @@ /*========================================================================= Program: BlueBerry Platform Language: C++ Date: $Date$ Version: $Revision$ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #ifndef __BERRY_MACROS_H__ #define __BERRY_MACROS_H__ #include "berryWeakPointer.h" #define berryNameMacro(className) \ virtual const char* GetClassName() const \ { return #className; }\ static const char* GetStaticClassName() \ { return #className; }\ #define berryManifestMacro(className, namespaze) \ static const char* GetManifestName() \ { return #namespaze #className; } \ #define berryObjectMacro(className) \ typedef className Self; \ typedef berry::SmartPointer Pointer; \ typedef berry::SmartPointer ConstPointer; \ typedef berry::WeakPointer WeakPtr; \ typedef berry::WeakPointer ConstWeakPtr; \ berryNameMacro(className) \ #define berryInterfaceMacro(className, namespaze) \ public: \ berryObjectMacro(className) \ berryManifestMacro(className, namespaze) \ #define berrySimpleInterfaceMacro(className, namespaze) \ protected: className() {} \ public: \ berryNameMacro(className) \ berryManifestMacro(className, namespaze) \ #define berryNewMacro(x) \ static Pointer New(void) \ { \ Pointer smartPtr(new x); \ return smartPtr; \ } \ #define berryNewMacro1Param(x, type1) \ static Pointer New(type1 param1) \ { \ Pointer smartPtr(new x(param1)); \ return smartPtr; \ } \ #define berryNewMacro2Param(x, type1, type2) \ static Pointer New(type1 param1, type2 param2) \ { \ Pointer smartPtr(new x(param1, param2)); \ return smartPtr; \ } \ #define berryNewMacro3Param(x, type1, type2, type3) \ static Pointer New(type1 param1, type2 param2, type3 param3) \ { \ Pointer smartPtr (new x(param1, param2, param3)); \ return smartPtr; \ } \ #ifndef BERRY_NO_TYPESAFE_FLAGS #include "berryFlags.h" #define BERRY_DECLARE_FLAGS(_Flags, _Enum)\ typedef berry::Flags<_Enum> _Flags; #if defined _MSC_VER && _MSC_VER < 1300 # define BERRY_DECLARE_INCOMPATIBLE_FLAGS(_Flags) #else # define BERRY_DECLARE_INCOMPATIBLE_FLAGS(_Flags) \ inline berry::IncompatibleFlag operator|(_Flags::enum_type f1, int f2) \ { return berry::IncompatibleFlag(int(f1) | f2); } #endif #define BERRY_DECLARE_OPERATORS_FOR_FLAGS(_Flags) \ inline berry::Flags<_Flags::enum_type> operator|(_Flags::enum_type f1, _Flags::enum_type f2) \ { return berry::Flags<_Flags::enum_type>(f1) | f2; } \ inline berry::Flags<_Flags::enum_type> operator|(_Flags::enum_type f1, berry::Flags<_Flags::enum_type> f2) \ { return f2 | f1; } BERRY_DECLARE_INCOMPATIBLE_FLAGS(_Flags) #else /* BERRY_NO_TYPESAFE_FLAGS */ #define BERRY_DECLARE_FLAGS(_Flags, _Enum)\ typedef uint _Flags; #define BERRY_DECLARE_OPERATORS_FOR_FLAGS(_Flags) #endif /* BERRY_NO_TYPESAFE_FLAGS */ +#define BERRY_REGISTER_EXTENSION_CLASS(_ClassType, _PluginContext)\ +{\ + QString typeName = _PluginContext->getPlugin()->getSymbolicName();\ + typeName = (typeName + "_") + _ClassType::staticMetaObject.className();\ + qRegisterMetaType<_ClassType>(typeName.toAscii().data());\ +} #endif /*__BERRY_MACROS_H__*/ diff --git a/BlueBerry/Bundles/org.blueberry.osgi/src/berryOSGiDll.h b/BlueBerry/Bundles/org.blueberry.osgi/src/berryOSGiDll.h deleted file mode 100644 index f4a6cf5929..0000000000 --- a/BlueBerry/Bundles/org.blueberry.osgi/src/berryOSGiDll.h +++ /dev/null @@ -1,43 +0,0 @@ -/*========================================================================= - -Program: BlueBerry Platform -Language: C++ -Date: $Date$ -Version: $Revision$ - -Copyright (c) German Cancer Research Center, Division of Medical and -Biological Informatics. All rights reserved. -See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. - -This software is distributed WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. See the above copyright notices for more information. - -=========================================================================*/ - -#ifndef BERRYOSGIDLL_H_ -#define BERRYOSGIDLL_H_ - - -// -// The following block is the standard way of creating macros which make exporting -// from a DLL simpler. All files within this DLL are compiled with the MITK_EXPORTS -// symbol defined on the command line. this symbol should not be defined on any project -// that uses this DLL. This way any other project whose source files include this file see -// MITK_API functions as being imported from a DLL, wheras this DLL sees symbols -// defined with this macro as being exported. -// -#if defined(_WIN32) && !defined(BERRY_STATIC) - #if defined(org_blueberry_osgi_EXPORTS) - #define BERRY_OSGI __declspec(dllexport) - #else - #define BERRY_OSGI __declspec(dllimport) - #endif -#endif - - -#if !defined(BERRY_OSGI) - #define BERRY_OSGI -#endif - -#endif /*BERRYOSGIDLL_H_*/ diff --git a/BlueBerry/Bundles/org.blueberry.osgi/src/berryObject.h b/BlueBerry/Bundles/org.blueberry.osgi/src/berryObject.h index 7e66bdabde..7eb32b3486 100644 --- a/BlueBerry/Bundles/org.blueberry.osgi/src/berryObject.h +++ b/BlueBerry/Bundles/org.blueberry.osgi/src/berryObject.h @@ -1,219 +1,219 @@ /*========================================================================= Program: BlueBerry Platform Language: C++ Date: $Date$ Version: $Revision$ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #ifndef BERRYOSGILIGHTOBJECT_H_ #define BERRYOSGILIGHTOBJECT_H_ #include #include -#include "berryOSGiDll.h" +#include #include "berryMacros.h" #include "berryMessage.h" #include #ifdef _MSC_VER // disable inheritance by dominance warnings #pragma warning( disable : 4250 4275 4251 ) // disable warning: C++ exception specification ignored except to indicate a function is not __declspec(nothrow) #pragma warning( disable : 4290 ) #endif namespace berry { class BERRY_OSGI Indent { public: /** Standard class typedefs. */ typedef Indent Self; /** Method for creation through the object factory. */ static Self* New(); /** Destroy this instance. */ void Delete() {delete this;} /** Construct the object with an initial Indentation level. */ Indent(int ind=0) {m_Indent=ind;} /** Return the name of the class. */ static const char *GetClassName() {return "Indent";} /** Determine the next Indentation level. Keep Indenting by two until the * a maximum of forty spaces is reached. */ Indent GetNextIndent(); /** Print out the Indentation. Basically output a bunch of spaces. */ friend BERRY_OSGI std::ostream& operator<<(std::ostream& os, const Indent& o); private: int m_Indent; }; BERRY_OSGI std::ostream& operator<<(std::ostream& os, const Indent& o); /** \class Object * \brief Light weight base class for most BlueBerry classes. * * Object is copied from itk::LightObject and is the highest * level base class for most BlueBerry objects. It * implements reference counting and the API for object printing. * */ class BERRY_OSGI Object { /** * The message macro is used to create a message object as well as add / remove functions * (AddDestroyListener, RemoveDestroyListener) * in order to register functions which will be called when the object is destroyed. * More information about the NewMessageMacro can be found in @see berryMessage.h * */ berryNewMessageMacro(Destroy) public: berryObjectMacro(Object) struct Hash { inline std::size_t operator()(const Self* value) const { return value->HashCode(); } inline std::size_t operator()(Self::ConstPointer value) const { return value->HashCode(); } inline std::size_t operator()(Self::WeakPtr value) const { try { const Self::ConstPointer sv(value.Lock()); return sv->HashCode(); } catch (BadWeakPointerException& /*e*/) { return 0; } } }; /** Delete an BlueBerry object. This method should always be used to delete an * object when the new operator was used to create it. Using the C * delete method will not work with reference counting. */ virtual void Delete(); #ifdef _WIN32 /** Used to avoid dll boundary problems. */ void* operator new(size_t); void* operator new[](size_t); void operator delete(void*); void operator delete[](void*, size_t); #endif /** Cause the object to print itself out. This is usually used to provide * detailed information about the object's state. It just calls the * header/self/trailer virtual print methods, which can be overriden by * subclasses. */ void Print(std::ostream& os, Indent Indent=0) const; /** Returns a string representation of this object. */ virtual std::string ToString() const; /** Returns a hash code value for the object. Use the Object::Hash functor * together with hashtable implementations. */ virtual std::size_t HashCode() const; /** * Override this method to implement a specific "less than" operator * for associative STL containers. */ virtual bool operator<(const Object*) const; /** Increase the reference count (mark as used by another object). */ void Register() const; /** Decrease the reference count (release by another object). * Set del to false if you do not want the object to be deleted if * the reference count is zero (use with care!) */ void UnRegister(bool del = true) const; /** Gets the reference count on this object. */ int GetReferenceCount() const {return m_ReferenceCount;} /** Sets the reference count on this object. This is a dangerous * method, use it with care. */ void SetReferenceCount(int); /** A generic comparison method. Override this method in subclasses and * cast to your derived class to provide a more detailed comparison. */ virtual bool operator==(const Object*) const; #ifdef BLUEBERRY_DEBUG_SMARTPOINTER unsigned int GetTraceId() const; private: unsigned int m_TraceId; unsigned int& GetTraceIdCounter() const; public: #endif protected: Object(); virtual ~Object(); /** Methods invoked by Print() to print information about the object * including superclasses. Typically not called by the user (use Print() * instead) but used in the hierarchical print process to combine the * output of several classes. */ virtual void PrintSelf(std::ostream& os, Indent indent) const; virtual void PrintHeader(std::ostream& os, Indent indent) const; virtual void PrintTrailer(std::ostream& os, Indent indent) const; /** Number of uses of this object by other objects. */ mutable volatile int m_ReferenceCount; /** Mutex lock to protect modification to the reference count */ mutable Poco::Mutex m_ReferenceCountLock; private: Object(const Self&); //purposely not implemented void operator=(const Self&); //purposely not implemented }; /** * This operator allows all subclasses of Object to be printed via <<. * It in turn invokes the Print method, which in turn will invoke the * PrintSelf method that all objects should define, if they have anything * interesting to print out. */ BERRY_OSGI std::ostream& operator<<(std::ostream& os, const Object& o); } #endif /*BERRYOSGILIGHTOBJECT_H_*/ diff --git a/BlueBerry/Bundles/org.blueberry.osgi/src/berryObjectGeneric.h b/BlueBerry/Bundles/org.blueberry.osgi/src/berryObjectGeneric.h index 3778768646..95e8b40ecc 100755 --- a/BlueBerry/Bundles/org.blueberry.osgi/src/berryObjectGeneric.h +++ b/BlueBerry/Bundles/org.blueberry.osgi/src/berryObjectGeneric.h @@ -1,114 +1,114 @@ /*========================================================================= Program: BlueBerry Platform Language: C++ Date: $Date$ Version: $Revision$ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #ifndef BERRYOBJECTGENERIC_H_ #define BERRYOBJECTGENERIC_H_ #include -#include "berryOSGiDll.h" +#include #include "berryMacros.h" #include "berryObject.h" namespace berry { template class BERRY_OSGI ObjectGeneric : public Object { public: berryObjectMacro(ObjectGeneric); typedef T ValueType; ObjectGeneric() : m_Value(0) {} ObjectGeneric(T x) : m_Value(x) {} //ObjectGeneric(const Self& o) { m_Value = o.m_Value; } virtual ~ObjectGeneric() { } void SetValue(T val) { m_Value = val; } T GetValue() const { return m_Value; } bool operator==(const Object* o) const { if(const Self* other = dynamic_cast(o)) return (this->m_Value == other->m_Value); return false; } virtual std::string GetValueAsString() const { std::stringstream myStr; std::locale originalLocale = myStr.getloc(); std::locale C("C"); myStr.imbue(C); myStr << GetValue() ; myStr.imbue(originalLocale); return myStr.str(); } virtual bool Assignable(Object::ConstPointer other) const { return other.Cast() != 0; } virtual void Assign(Object::ConstPointer other) { ConstPointer specOther = other.Cast(); if (specOther && this->m_Value != specOther->m_Value) { this->m_Value = specOther->m_Value; } } protected: T m_Value; }; } // namespace berry /** * Generates a specialized subclass of berry::ObjectGeneric. * This way, GetClassName() returns the value provided by ObjectName. * Please see berryObjects.h for examples * @param ObjectName the name of the instantiation of ObjectGeneric * @param Type the value type */ #define berrySpecializeGenericObject(ObjectName,Type,DefaultValue) \ class BERRY_OSGI ObjectName: public ::berry::ObjectGeneric< Type > \ { \ public: \ berryObjectMacro(ObjectName); \ ObjectName() : ::berry::ObjectGeneric< Type >(DefaultValue) { } \ ObjectName(Type x) : ::berry::ObjectGeneric(x) {} \ /*ObjectName(const ObjectName& o) : ObjectGeneric< Type >(o) {} */ \ }; #endif /* BERRYOBJECTGENERIC_H_ */ diff --git a/BlueBerry/Bundles/org.blueberry.osgi/src/berryPlatform.cpp b/BlueBerry/Bundles/org.blueberry.osgi/src/berryPlatform.cpp index bd1229473d..dfaad0c512 100644 --- a/BlueBerry/Bundles/org.blueberry.osgi/src/berryPlatform.cpp +++ b/BlueBerry/Bundles/org.blueberry.osgi/src/berryPlatform.cpp @@ -1,190 +1,209 @@ /*========================================================================= Program: BlueBerry Platform Language: C++ Date: $Date$ Version: $Revision$ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #include #include "berryPlatform.h" #include "service/berryIExtensionPointService.h" #include "internal/berryInternalPlatform.h" namespace berry { int Platform::OS_FREE_BSD = BERRY_OS_FREE_BSD; int Platform::OS_AIX = BERRY_OS_AIX; int Platform::OS_HPUX = BERRY_OS_HPUX; int Platform::OS_TRU64 = BERRY_OS_TRU64; int Platform::OS_LINUX = BERRY_OS_LINUX; int Platform::OS_MAC_OS_X = BERRY_OS_MAC_OS_X; int Platform::OS_NET_BSD = BERRY_OS_NET_BSD; int Platform::OS_OPEN_BSD = BERRY_OS_OPEN_BSD; int Platform::OS_IRIX = BERRY_OS_IRIX; int Platform::OS_SOLARIS = BERRY_OS_SOLARIS; int Platform::OS_QNX = BERRY_OS_QNX; int Platform::OS_VXWORKS = BERRY_OS_VXWORKS; int Platform::OS_CYGWIN = BERRY_OS_CYGWIN; int Platform::OS_UNKNOWN_UNIX = BERRY_OS_UNKNOWN_UNIX; int Platform::OS_WINDOWS_NT = BERRY_OS_WINDOWS_NT; int Platform::OS_WINDOWS_CE = BERRY_OS_WINDOWS_CE; int Platform::OS_VMS = BERRY_OS_VMS; int Platform::ARCH_ALPHA = BERRY_ARCH_ALPHA; int Platform::ARCH_IA32 = BERRY_ARCH_IA32; int Platform::ARCH_IA64 = BERRY_ARCH_IA64; int Platform::ARCH_MIPS = BERRY_ARCH_MIPS; int Platform::ARCH_HPPA = BERRY_ARCH_HPPA; int Platform::ARCH_PPC = BERRY_ARCH_PPC; int Platform::ARCH_POWER = BERRY_ARCH_POWER; int Platform::ARCH_SPARC = BERRY_ARCH_SPARC; int Platform::ARCH_AMD64 = BERRY_ARCH_AMD64; int Platform::ARCH_ARM = BERRY_ARCH_ARM; std::string Platform::ARG_CLEAN = "BlueBerry.clean"; std::string Platform::ARG_APPLICATION = "BlueBerry.application"; std::string Platform::ARG_HOME = "BlueBerry.home"; std::string Platform::ARG_PLUGIN_CACHE = "BlueBerry.plugin_cache_dir"; std::string Platform::ARG_PLUGIN_DIRS = "BlueBerry.plugin_dirs"; +std::string Platform::ARG_PROVISIONING = "BlueBerry.provisioning"; std::string Platform::ARG_CONSOLELOG = "BlueBerry.consoleLog"; std::string Platform::ARG_TESTPLUGIN = "BlueBerry.testplugin"; std::string Platform::ARG_TESTAPPLICATION = "BlueBerry.testapplication"; const Poco::Path& Platform::GetConfigurationPath() { return InternalPlatform::GetInstance()->GetConfigurationPath(); } SmartPointer Platform::GetExtensionPointService() { return InternalPlatform::GetInstance()->GetExtensionPointService(); } PlatformEvents& Platform::GetEvents() { return InternalPlatform::GetInstance()->GetEvents(); } const Poco::Path& Platform::GetInstallPath() { return InternalPlatform::GetInstance()->GetInstallPath(); } const Poco::Path& Platform::GetInstancePath() { return InternalPlatform::GetInstance()->GetInstancePath(); } int Platform::GetOS() { return BERRY_OS; } int Platform::GetOSArch() { return BERRY_ARCH; } bool Platform::IsUnix() { #ifdef BERRY_OS_FAMILY_UNIX return true; #else return false; #endif } bool Platform::IsWindows() { #ifdef BERRY_OS_FAMILY_WINDOWS return true; #else return false; #endif } bool Platform::IsBSD() { #ifdef BERRY_OS_FAMILY_BSD return true; #else return false; #endif } bool Platform::IsLinux() { #ifdef BERRY_OS_FAMILY_LINUX return true; #else return false; #endif } bool Platform::IsVMS() { #ifdef BERRY_OS_FAMILY_VMS return true; #else return false; #endif } bool Platform::GetStatePath(Poco::Path& statePath, IBundle::Pointer bundle, bool create) { return InternalPlatform::GetInstance()->GetStatePath(statePath, bundle, create); } const Poco::Path& Platform::GetUserPath() { return InternalPlatform::GetInstance()->GetUserPath(); } std::string Platform::GetProperty(const std::string& /*key*/) { return ""; } bool Platform::IsRunning() { return InternalPlatform::GetInstance()->IsRunning(); } int& Platform::GetRawApplicationArgs(char**& argv) { return InternalPlatform::GetInstance()->GetRawApplicationArgs(argv); } std::vector Platform::GetApplicationArgs() { return InternalPlatform::GetInstance()->GetApplicationArgs(); } Poco::Util::LayeredConfiguration& Platform::GetConfiguration() { return InternalPlatform::GetInstance()->GetConfiguration(); } ServiceRegistry& Platform::GetServiceRegistry() { return InternalPlatform::GetInstance()->GetServiceRegistry(); } IBundle::Pointer Platform::GetBundle(const std::string& id) { return InternalPlatform::GetInstance()->GetBundle(id); } +std::vector Platform::GetBundles() +{ + return InternalPlatform::GetInstance()->GetBundles(); +} + +QSharedPointer Platform::GetCTKPlugin(const QString& symbolicName) +{ + QList > plugins = + InternalPlatform::GetInstance()->GetCTKPluginFrameworkContext()->getPlugins(); + + foreach(QSharedPointer plugin, plugins) + { + if (plugin->getSymbolicName() == symbolicName) + return plugin; + } + return QSharedPointer(0); +} + } diff --git a/BlueBerry/Bundles/org.blueberry.osgi/src/berryPlatform.h b/BlueBerry/Bundles/org.blueberry.osgi/src/berryPlatform.h index 89f06b7643..8a063d9b84 100644 --- a/BlueBerry/Bundles/org.blueberry.osgi/src/berryPlatform.h +++ b/BlueBerry/Bundles/org.blueberry.osgi/src/berryPlatform.h @@ -1,339 +1,344 @@ /*========================================================================= Program: BlueBerry Platform Language: C++ Date: $Date$ Version: $Revision$ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #ifndef BERRY_Platform_INCLUDED #define BERRY_Platform_INCLUDED // // Platform Identification // #define BERRY_OS_FREE_BSD 0x0001 #define BERRY_OS_AIX 0x0002 #define BERRY_OS_HPUX 0x0003 #define BERRY_OS_TRU64 0x0004 #define BERRY_OS_LINUX 0x0005 #define BERRY_OS_MAC_OS_X 0x0006 #define BERRY_OS_NET_BSD 0x0007 #define BERRY_OS_OPEN_BSD 0x0008 #define BERRY_OS_IRIX 0x0009 #define BERRY_OS_SOLARIS 0x000a #define BERRY_OS_QNX 0x000b #define BERRY_OS_VXWORKS 0x000c #define BERRY_OS_CYGWIN 0x000d #define BERRY_OS_UNKNOWN_UNIX 0x00ff #define BERRY_OS_WINDOWS_NT 0x1001 #define BERRY_OS_WINDOWS_CE 0x1011 #define BERRY_OS_VMS 0x2001 #if defined(__FreeBSD__) #define BERRY_OS_FAMILY_UNIX 1 #define BERRY_OS_FAMILY_BSD 1 #define BERRY_OS BERRY_OS_FREE_BSD #elif defined(_AIX) || defined(__TOS_AIX__) #define BERRY_OS_FAMILY_UNIX 1 #define BERRY_OS BERRY_OS_AIX #elif defined(hpux) || defined(_hpux) #define BERRY_OS_FAMILY_UNIX 1 #define BERRY_OS BERRY_OS_HPUX #elif defined(__digital__) || defined(__osf__) #define BERRY_OS_FAMILY_UNIX 1 #define BERRY_OS BERRY_OS_TRU64 #elif defined(linux) || defined(__linux) || defined(__linux__) || defined(__TOS_LINUX__) #define BERRY_OS_FAMILY_UNIX 1 #define BERRY_OS BERRY_OS_LINUX #elif defined(__APPLE__) || defined(__TOS_MACOS__) #define BERRY_OS_FAMILY_UNIX 1 #define BERRY_OS_FAMILY_BSD 1 #define BERRY_OS BERRY_OS_MAC_OS_X #elif defined(__NetBSD__) #define BERRY_OS_FAMILY_UNIX 1 #define BERRY_OS_FAMILY_BSD 1 #define BERRY_OS BERRY_OS_NET_BSD #elif defined(__OpenBSD__) #define BERRY_OS_FAMILY_UNIX 1 #define BERRY_OS_FAMILY_BSD 1 #define BERRY_OS BERRY_OS_OPEN_BSD #elif defined(sgi) || defined(__sgi) #define BERRY_OS_FAMILY_UNIX 1 #define BERRY_OS BERRY_OS_IRIX #elif defined(sun) || defined(__sun) #define BERRY_OS_FAMILY_UNIX 1 #define BERRY_OS BERRY_OS_SOLARIS #elif defined(__QNX__) #define BERRY_OS_FAMILY_UNIX 1 #define BERRY_OS BERRY_OS_QNX #elif defined(unix) || defined(__unix) || defined(__unix__) #define BERRY_OS_FAMILY_UNIX 1 #define BERRY_OS BERRY_OS_UNKNOWN_UNIX #elif defined(_WIN32_WCE) #define BERRY_OS_FAMILY_WINDOWS 1 #define BERRY_OS BERRY_OS_WINDOWS_CE #elif defined(_WIN32) || defined(_WIN64) #define BERRY_OS_FAMILY_WINDOWS 1 #define BERRY_OS BERRY_OS_WINDOWS_NT #elif defined(__CYGWIN__) #define BERRY_OS_FAMILY_UNIX 1 #define BERRY_OS BERRY_OS_CYGWIN #elif defined(__VMS) #define BERRY_OS_FAMILY_VMS 1 #define BERRY_OS BERRY_OS_VMS #endif // // Hardware Architecture and Byte Order // #define BERRY_ARCH_ALPHA 0x01 #define BERRY_ARCH_IA32 0x02 #define BERRY_ARCH_IA64 0x03 #define BERRY_ARCH_MIPS 0x04 #define BERRY_ARCH_HPPA 0x05 #define BERRY_ARCH_PPC 0x06 #define BERRY_ARCH_POWER 0x07 #define BERRY_ARCH_SPARC 0x08 #define BERRY_ARCH_AMD64 0x09 #define BERRY_ARCH_ARM 0x0a #if defined(__ALPHA) || defined(__alpha) || defined(__alpha__) || defined(_M_ALPHA) #define BERRY_ARCH BERRY_ARCH_ALPHA #define BERRY_ARCH_LITTLE_ENDIAN 1 #elif defined(i386) || defined(__i386) || defined(__i386__) || defined(_M_IX86) #define BERRY_ARCH BERRY_ARCH_IA32 #define BERRY_ARCH_LITTLE_ENDIAN 1 #elif defined(_IA64) || defined(__IA64__) || defined(__ia64__) || defined(__ia64) || defined(_M_IA64) #define BERRY_ARCH BERRY_ARCH_IA64 #if defined(hpux) || defined(_hpux) #define BERRY_ARCH_BIG_ENDIAN 1 #else #define BERRY_ARCH_LITTLE_ENDIAN 1 #endif #elif defined(__x86_64__) #define BERRY_ARCH BERRY_ARCH_AMD64 #define BERRY_ARCH_LITTLE_ENDIAN 1 #elif defined(_M_X64) #define BERRY_ARCH BERRY_ARCH_AMD64 #define BERRY_ARCH_LITTLE_ENDIAN 1 #elif defined(__mips__) || defined(__mips) || defined(__MIPS__) || defined(_M_MRX000) #define BERRY_ARCH BERRY_ARCH_MIPS #define BERRY_ARCH_BIG_ENDIAN 1 #elif defined(__hppa) || defined(__hppa__) #define BERRY_ARCH BERRY_ARCH_HPPA #define BERRY_ARCH_BIG_ENDIAN 1 #elif defined(__PPC) || defined(__POWERPC__) || defined(__powerpc) || defined(__PPC__) || \ defined(__powerpc__) || defined(__ppc__) || defined(_ARCH_PPC) || defined(_M_PPC) #define BERRY_ARCH BERRY_ARCH_PPC #define BERRY_ARCH_BIG_ENDIAN 1 #elif defined(_POWER) || defined(_ARCH_PWR) || defined(_ARCH_PWR2) || defined(_ARCH_PWR3) || \ defined(_ARCH_PWR4) || defined(__THW_RS6000) #define BERRY_ARCH BERRY_ARCH_POWER #define BERRY_ARCH_BIG_ENDIAN 1 #elif defined(__sparc__) || defined(__sparc) || defined(sparc) #define BERRY_ARCH BERRY_ARCH_SPARC #define BERRY_ARCH_BIG_ENDIAN 1 #elif defined(__arm__) || defined(__arm) || defined(ARM) || defined(_ARM_) || defined(__ARM__) || defined(_M_ARM) #define BERRY_ARCH BERRY_ARCH_ARM #if defined(__ARMEB__) #define BERRY_ARCH_BIG_ENDIAN 1 #else #define BERRY_ARCH_LITTLE_ENDIAN 1 #endif #endif -#include "berryOSGiDll.h" +#include #include "event/berryPlatformEvents.h" #include "service/berryServiceRegistry.h" #include namespace berry { struct IExtensionPointService; /** * The central class of the BlueBerry Platform Runtime. This class cannot * be instantiated or subclassed by clients; all functionality is provided * by static methods. Features include: *
    *
  • the platform registry of installed plug-ins
  • *
  • the platform adapter manager
  • *
  • the platform log
  • *
*

* Most users don't have to worry about Platform's lifecycle. However, if your * code can call methods of this class when Platform is not running, it becomes * necessary to check {@link #IsRunning()} before making the call. A runtime * exception might be thrown or incorrect result might be returned if a method * from this class is called while Platform is not running. *

*/ class BERRY_OSGI Platform { public: static int OS_FREE_BSD; static int OS_AIX; static int OS_HPUX; static int OS_TRU64; static int OS_LINUX; static int OS_MAC_OS_X; static int OS_NET_BSD; static int OS_OPEN_BSD; static int OS_IRIX; static int OS_SOLARIS; static int OS_QNX; static int OS_VXWORKS; static int OS_CYGWIN; static int OS_UNKNOWN_UNIX; static int OS_WINDOWS_NT; static int OS_WINDOWS_CE; static int OS_VMS; static int ARCH_ALPHA; static int ARCH_IA32; static int ARCH_IA64; static int ARCH_MIPS; static int ARCH_HPPA; static int ARCH_PPC; static int ARCH_POWER; static int ARCH_SPARC; static int ARCH_AMD64; static int ARCH_ARM; static std::string ARG_CLEAN; static std::string ARG_APPLICATION; static std::string ARG_HOME; static std::string ARG_PLUGIN_CACHE; static std::string ARG_PLUGIN_DIRS; + static std::string ARG_PROVISIONING; static std::string ARG_CONSOLELOG; static std::string ARG_TESTPLUGIN; static std::string ARG_TESTAPPLICATION; static SmartPointer GetExtensionPointService(); // static IPreferenceService GetPreferenceService(); static PlatformEvents& GetEvents(); /** * Returns the path of the configuration information * used to run this instance of the BlueBerry platform. * The configuration area typically * contains the list of plug-ins available for use, various settings * (those shared across different instances of the same configuration) * and any other such data needed by plug-ins. * An empty path is returned if the platform is running without a configuration location. * * @return the location of the platform's configuration data area */ static const Poco::Path& GetConfigurationPath(); /** * Returns the path of the base installation for the running platform * * @return the location of the platform's installation area or null if none */ static const Poco::Path& GetInstallPath(); /** * Returns the path of the platform's working directory (also known as the instance data area). * An empty path is returned if the platform is running without an instance location. * * @return the location of the platform's instance data area or null if none */ static const Poco::Path& GetInstancePath(); /** * Returns the path in the local file system of the * plug-in state area for the given bundle. * If the plug-in state area did not exist prior to this call, * it is created. *

* The plug-in state area is a file directory within the * platform's metadata area where a plug-in is free to create files. * The content and structure of this area is defined by the plug-in, * and the particular plug-in is solely responsible for any files * it puts there. It is recommended for plug-in preference settings and * other configuration parameters. *

* * @param bundle the bundle whose state location is returned * @return a local file system path * TODO Investigate the usage of a service factory */ static bool GetStatePath(Poco::Path& statePath, SmartPointer bundle, bool create = true); /** * Returns the path of the platform's user data area. The user data area is a location on the system * which is specific to the system's current user. By default it is located relative to the * location given by the System property "user.home". * An empty path is returned if the platform is running without an user location. * * @return the location of the platform's user data area or null if none */ static const Poco::Path& GetUserPath(); static int GetOS(); static int GetOSArch(); static bool IsUnix(); static bool IsWindows(); static bool IsBSD(); static bool IsLinux(); static bool IsVMS(); static std::string GetProperty(const std::string& key); static bool IsRunning(); static Poco::Util::LayeredConfiguration& GetConfiguration(); /** * Returns the unmodified, original command line arguments * */ static int& GetRawApplicationArgs(char**& argv); /** * Returns the applications command line arguments which * have not been consumed by the platform. The first * argument still is the application name */ static std::vector GetApplicationArgs(); static ServiceRegistry& GetServiceRegistry(); /** * Returns the resolved bundle with the specified symbolic name that has the * highest version. If no resolved bundles are installed that have the * specified symbolic name then null is returned. * * @param id the symbolic name of the bundle to be returned. * @return the bundle that has the specified symbolic name with the * highest version, or null if no bundle is found. */ static IBundle::Pointer GetBundle(const std::string& id); + static std::vector GetBundles(); + + static QSharedPointer GetCTKPlugin(const QString& symbolicName); + private: Platform(); }; } // namespace #endif // BERRY_Platform_INCLUDED diff --git a/BlueBerry/Bundles/org.blueberry.osgi/src/berryPlatformException.h b/BlueBerry/Bundles/org.blueberry.osgi/src/berryPlatformException.h index b6f27e7495..22f96a5fd2 100644 --- a/BlueBerry/Bundles/org.blueberry.osgi/src/berryPlatformException.h +++ b/BlueBerry/Bundles/org.blueberry.osgi/src/berryPlatformException.h @@ -1,40 +1,40 @@ /*========================================================================= Program: BlueBerry Platform Language: C++ Date: $Date$ Version: $Revision$ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #ifndef BERRYPLATFORMEXCEPTION_H_ #define BERRYPLATFORMEXCEPTION_H_ -#include "berryOSGiDll.h" +#include #include "Poco/Exception.h" namespace berry { POCO_DECLARE_EXCEPTION(BERRY_OSGI, PlatformException, Poco::RuntimeException); POCO_DECLARE_EXCEPTION(BERRY_OSGI, ManifestException, PlatformException); POCO_DECLARE_EXCEPTION(BERRY_OSGI, BundleException, PlatformException); POCO_DECLARE_EXCEPTION(BERRY_OSGI, BundleStateException, PlatformException); POCO_DECLARE_EXCEPTION(BERRY_OSGI, BundleVersionConflictException, PlatformException); POCO_DECLARE_EXCEPTION(BERRY_OSGI, BundleLoadException, PlatformException); POCO_DECLARE_EXCEPTION(BERRY_OSGI, BundleResolveException, PlatformException); POCO_DECLARE_EXCEPTION(BERRY_OSGI, CoreException, PlatformException); POCO_DECLARE_EXCEPTION(BERRY_OSGI, InvalidServiceObjectException, CoreException); } #endif /*BERRYPLATFORMEXCEPTION_H_*/ diff --git a/BlueBerry/Bundles/org.blueberry.osgi/src/berryPlugin.h b/BlueBerry/Bundles/org.blueberry.osgi/src/berryPlugin.h index 81297f3e01..e003c24791 100644 --- a/BlueBerry/Bundles/org.blueberry.osgi/src/berryPlugin.h +++ b/BlueBerry/Bundles/org.blueberry.osgi/src/berryPlugin.h @@ -1,56 +1,56 @@ /*========================================================================= Program: BlueBerry Platform Language: C++ Date: $Date$ Version: $Revision$ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #ifndef BERRYPLUGIN_H_ #define BERRYPLUGIN_H_ -#include "berryOSGiDll.h" +#include #include "berryIBundleActivator.h" #include "berryIBundleContext.h" #include "Poco/Logger.h" #include "Poco/Path.h" struct IBundle; class BundleLoader; namespace berry { class BERRY_OSGI Plugin : public IBundleActivator { public: void Start(IBundleContext::Pointer context); void Stop(IBundleContext::Pointer context); SmartPointer GetBundle(); //Poco::Logger& GetLog(); bool GetStatePath(Poco::Path& path); protected: friend class BundleLoader; //TODO WeakPointer!!! SmartPointer m_Bundle; }; } #endif /*BERRYPLUGIN_H_*/ diff --git a/BlueBerry/Bundles/org.blueberry.osgi/src/berrySmartPointer.h b/BlueBerry/Bundles/org.blueberry.osgi/src/berrySmartPointer.h index 70a2c1c88a..0d5802ae1e 100644 --- a/BlueBerry/Bundles/org.blueberry.osgi/src/berrySmartPointer.h +++ b/BlueBerry/Bundles/org.blueberry.osgi/src/berrySmartPointer.h @@ -1,384 +1,384 @@ /*========================================================================= Program: BlueBerry Platform Language: C++ Date: $Date$ Version: $Revision$ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #ifndef BERRYOSGISMARTPOINTER_H_ #define BERRYOSGISMARTPOINTER_H_ #include #include -#include "berryOSGiDll.h" +#include #include "berryException.h" #include #if defined(BLUEBERRY_DEBUG_SMARTPOINTER) #include "berryDebugUtil.h" #include #endif namespace berry { template class WeakPointer; /** \class SmartPointer * \brief Implements transparent reference counting. * * SmartPointer is a copy of itk::SmartPointer. * It implements reference counting by overloading * operator -> (and *) among others. This allows natural interface * to the class referred to by the pointer without having to invoke * special Register()/UnRegister() methods directly. * */ template class SmartPointer { public: typedef TObjectType ObjectType; typedef SmartPointer Self; /** Constructor */ SmartPointer() : m_Pointer(0) { #if defined(BLUEBERRY_DEBUG_SMARTPOINTER) DebugInitSmartPointer(); #endif } /** Constructor to pointer p */ explicit SmartPointer(ObjectType *p) : m_Pointer(p) { if (m_Pointer) this->Register(); #if defined(BLUEBERRY_DEBUG_SMARTPOINTER) DebugInitSmartPointer(); #endif } /** Copy constructor */ SmartPointer(const SmartPointer &p) : m_Pointer(p.m_Pointer) { this->Register(); #if defined(BLUEBERRY_DEBUG_SMARTPOINTER) DebugInitSmartPointer(); #endif } template SmartPointer(const SmartPointer& ptr) : m_Pointer(const_cast (ptr.GetPointer())) { if (m_Pointer) this->Register(); #if defined(BLUEBERRY_DEBUG_SMARTPOINTER) DebugInitSmartPointer(); #endif } template explicit SmartPointer(const WeakPointer& wp) { if (wp.m_Pointer) { this->m_Pointer = wp.m_Pointer; this->Register(); #if defined(BLUEBERRY_DEBUG_SMARTPOINTER) DebugInitSmartPointer(); #endif } else { throw BadWeakPointerException(); } } /** Destructor */ ~SmartPointer() { #if defined(BLUEBERRY_DEBUG_SMARTPOINTER) if (m_Pointer) DebugRemoveSmartPointer(); #endif this->UnRegister(); m_Pointer = 0; } template SmartPointer Cast() const { Other* pOther = dynamic_cast (m_Pointer); return SmartPointer (pOther); } /** Overload operator -> */ ObjectType *operator ->() const { return m_Pointer; } // /** Return pointer to object. */ // operator ObjectType *() const // { // return m_Pointer; // } ObjectType & operator*() const { poco_assert( m_Pointer != 0 ); return *m_Pointer; } /** Test if the pointer has been initialized */ bool IsNotNull() const { return m_Pointer != 0; } bool IsNull() const { return m_Pointer == 0; } typedef ObjectType * Self::*unspecified_bool_type; operator unspecified_bool_type () const { return m_Pointer == 0 ? 0: &Self::m_Pointer; } /** Template comparison operators. */ template bool operator ==(const R* o) const { return (m_Pointer == 0 ? o == 0 : (o && m_Pointer->operator==(o))); } template bool operator ==(const SmartPointer& r) const { const R* o = r.GetPointer(); return (m_Pointer == 0 ? o == 0 : (o && m_Pointer->operator==(o))); } bool operator ==(int r) const { if (r == 0) return m_Pointer == 0; throw std::invalid_argument("Can only compare to 0"); } template bool operator !=(const R* r) const { return !(this->operator==(r)); } template bool operator !=(const SmartPointer& r) const { return !(this->operator==(r)); } bool operator !=(int r) const { if (r == 0) return m_Pointer != 0; throw std::invalid_argument("Can only compare to 0"); } // /** Template comparison operators using operator==. */ // template // bool CompareTo(const SmartPointer& r) const // { // return m_Pointer == 0 ? r == 0 : r.GetPointer() && m_Pointer->operator==(r.GetPointer()); // } // template // bool CompareTo(R r) const // { // //const ObjectType* o = static_cast (r); // return m_Pointer == 0 ? r == 0 : (r && m_Pointer->operator==(r)); // } /** Access function to pointer. */ ObjectType *GetPointer() const { return m_Pointer; } /** Comparison of pointers. Less than comparison. */ bool operator <(const SmartPointer &r) const { return (void*) m_Pointer < (void*) r.m_Pointer; } /** Comparison of pointers. Greater than comparison. */ bool operator>(const SmartPointer &r) const { return (void*) m_Pointer > (void*) r.m_Pointer; } /** Comparison of pointers. Less than or equal to comparison. */ bool operator <=(const SmartPointer &r) const { return (void*) m_Pointer <= (void*) r.m_Pointer; } /** Comparison of pointers. Greater than or equal to comparison. */ bool operator >=(const SmartPointer &r) const { return (void*) m_Pointer >= (void*) r.m_Pointer; } /** Overload operator assignment. */ SmartPointer &operator =(const SmartPointer &r) { return this->operator =(r.GetPointer()); } /** Overload operator assignment. */ template SmartPointer &operator =(const SmartPointer& r) { return this->operator =(r.GetPointer()); } /** Overload operator assignment. */ SmartPointer &operator =(ObjectType *r) { if (m_Pointer != r) { #if defined(BLUEBERRY_DEBUG_SMARTPOINTER) DebugAssignSmartPointer(r, m_Pointer); #endif ObjectType* tmp = m_Pointer; //avoid recursive unregisters by retaining temporarily m_Pointer = r; this->Register(); if (tmp) { tmp->UnRegister(); } } return *this; } /** Function to print object pointed to */ ObjectType *Print(std::ostream& os) const { // This prints the object pointed to by the pointer (*m_Pointer).Print(os); return m_Pointer; } private: /** The pointer to the object referred to by this smart pointer. */ ObjectType* m_Pointer; void Register() { if (m_Pointer) { m_Pointer->Register(); } } void UnRegister() { if (m_Pointer) { m_Pointer->UnRegister(); } } #if defined(BLUEBERRY_DEBUG_SMARTPOINTER) unsigned int m_Id; Poco::FastMutex m_Mutex; void DebugInitSmartPointer() { { Poco::FastMutex::ScopedLock lock(m_Mutex); if (m_Pointer) { unsigned int& counter = DebugUtil::GetSmartPointerCounter(); m_Id = ++counter; DebugUtil::RegisterSmartPointer(m_Id, m_Pointer); } else m_Id = 0; } //if (DebugUtil::GetSmartPointerCounter() == Platform::GetConfiguration().getInt(Platform::DEBUG_ARG_SMARTPOINTER_ID)) //throw 1; } void DebugRemoveSmartPointer() { Poco::FastMutex::ScopedLock lock(m_Mutex); DebugUtil::UnregisterSmartPointer(m_Id, m_Pointer); } void DebugAssignSmartPointer(const ObjectType* newObject, const ObjectType* oldObject) { Poco::FastMutex::ScopedLock lock(m_Mutex); if (oldObject) DebugUtil::UnregisterSmartPointer(m_Id, oldObject); if (newObject) { if (m_Id < 1) { unsigned int& counter = DebugUtil::GetSmartPointerCounter(); m_Id = ++counter; } DebugUtil::RegisterSmartPointer(m_Id, newObject); } } public: int GetId() { return m_Id; } private: #endif }; template std::ostream& operator<<(std::ostream& os, SmartPointer p) { p.Print(os); return os; } } #endif /*BERRYOSGISMARTPOINTER_H_*/ diff --git a/BlueBerry/Bundles/org.blueberry.osgi/src/event/berryBundleEvent.h b/BlueBerry/Bundles/org.blueberry.osgi/src/event/berryBundleEvent.h index 4bfd61fd2a..e662eac89a 100644 --- a/BlueBerry/Bundles/org.blueberry.osgi/src/event/berryBundleEvent.h +++ b/BlueBerry/Bundles/org.blueberry.osgi/src/event/berryBundleEvent.h @@ -1,57 +1,57 @@ /*========================================================================= Program: BlueBerry Platform Language: C++ Date: $Date$ Version: $Revision$ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #ifndef BERRYBUNDLEEVENT_H_ #define BERRYBUNDLEEVENT_H_ -#include "../berryOSGiDll.h" +#include #include "../berrySmartPointer.h" namespace berry { struct IBundle; class BERRY_OSGI BundleEvent { public: enum EventKind { EV_BUNDLE_INSTALLED, EV_BUNDLE_LOADED, EV_BUNDLE_RESOLVING, EV_BUNDLE_RESOLVED, EV_BUNDLE_STARTING, EV_BUNDLE_STARTED, EV_BUNDLE_STOPPING, EV_BUNDLE_STOPPED, EV_BUNDLE_UNINSTALLING, EV_BUNDLE_UNINSTALLED, EV_BUNDLE_UNLOADED }; BundleEvent(SmartPointer bundle, EventKind what); BundleEvent(IBundle* bundle, EventKind what); BundleEvent(const BundleEvent& event); virtual ~BundleEvent(); BundleEvent& operator= (const BundleEvent& event); SmartPointer GetBundle() const; EventKind What() const; private: SmartPointer m_Bundle; EventKind m_What; }; } // namespace berry #endif /*BERRYBUNDLEEVENT_H_*/ diff --git a/BlueBerry/Bundles/org.blueberry.osgi/src/event/berryBundleEvents.h b/BlueBerry/Bundles/org.blueberry.osgi/src/event/berryBundleEvents.h index 69cde437ed..400ac5f89a 100644 --- a/BlueBerry/Bundles/org.blueberry.osgi/src/event/berryBundleEvents.h +++ b/BlueBerry/Bundles/org.blueberry.osgi/src/event/berryBundleEvents.h @@ -1,46 +1,46 @@ /*========================================================================= Program: BlueBerry Platform Language: C++ Date: $Date$ Version: $Revision$ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #ifndef BERRYBUNDLEEVENTS_H_ #define BERRYBUNDLEEVENTS_H_ -#include "../berryOSGiDll.h" +#include #include "../berryMessage.h" #include "berryBundleEvent.h" namespace berry { struct BERRY_OSGI BundleEvents { Message1 bundleInstalled; Message1 bundleLoaded; Message1 bundleResolved; Message1 bundleResolving; Message1 bundleStarted; Message1 bundleStarting; Message1 bundleStopped; Message1 bundleStopping; Message1 bundleUninstalled; Message1 bundleUninstalling; Message1 bundleUnloaded; }; } // namespace berry #endif /*BERRYBUNDLEEVENTS_H_*/ diff --git a/BlueBerry/Bundles/org.blueberry.osgi/src/event/berryPlatformEvent.h b/BlueBerry/Bundles/org.blueberry.osgi/src/event/berryPlatformEvent.h index d955a5ad5f..f3f3b0c7e7 100644 --- a/BlueBerry/Bundles/org.blueberry.osgi/src/event/berryPlatformEvent.h +++ b/BlueBerry/Bundles/org.blueberry.osgi/src/event/berryPlatformEvent.h @@ -1,62 +1,62 @@ /*========================================================================= Program: BlueBerry Platform Language: C++ Date: $Date$ Version: $Revision$ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #ifndef BERRYPLATFORMEVENT_H_ #define BERRYPLATFORMEVENT_H_ -#include "../berryOSGiDll.h" +#include #include "../berryIBundle.h" #include "Poco/Any.h" #include namespace berry { class BERRY_OSGI PlatformEvent { public: enum EventKind { EV_PLATFORM_STARTED, EV_PLATFORM_ERROR, EV_PLATFORM_WARNING, EV_LOGGED}; PlatformEvent(EventKind what); PlatformEvent(EventKind what, IBundle::Pointer bundle); PlatformEvent(EventKind what, IBundle::Pointer bundle, std::exception exc); EventKind What() const; const std::exception* GetException() const; IBundle::Pointer GetBundle(); void SetData(Poco::Any* data); Poco::Any* GetData(); const Poco::Any* GetData() const; private: IBundle::Pointer m_Bundle; std::exception m_Exception; EventKind m_What; bool m_HasException; Poco::Any* m_Data; }; } #endif /*BERRYPLATFORMEVENT_H_*/ diff --git a/BlueBerry/Bundles/org.blueberry.osgi/src/event/berryPlatformEvents.h b/BlueBerry/Bundles/org.blueberry.osgi/src/event/berryPlatformEvents.h index 1434add9bd..4103a7671a 100644 --- a/BlueBerry/Bundles/org.blueberry.osgi/src/event/berryPlatformEvents.h +++ b/BlueBerry/Bundles/org.blueberry.osgi/src/event/berryPlatformEvents.h @@ -1,42 +1,42 @@ /*========================================================================= Program: BlueBerry Platform Language: C++ Date: $Date$ Version: $Revision$ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #ifndef BERRYPLATFORMEVENTS_H_ #define BERRYPLATFORMEVENTS_H_ -#include "../berryOSGiDll.h" +#include #include "../berryMessage.h" #include "berryPlatformEvent.h" namespace berry { struct BERRY_OSGI PlatformEvents { typedef Message1 EventType; EventType platformStarted; EventType platformError; EventType platformWarning; EventType logged; }; } #endif /*BERRYPLATFORMEVENTS_H_*/ diff --git a/BlueBerry/Bundles/org.blueberry.osgi/src/internal/berryBundle.cpp b/BlueBerry/Bundles/org.blueberry.osgi/src/internal/berryBundle.cpp index 57e4cdcf7f..41f4b08f05 100644 --- a/BlueBerry/Bundles/org.blueberry.osgi/src/internal/berryBundle.cpp +++ b/BlueBerry/Bundles/org.blueberry.osgi/src/internal/berryBundle.cpp @@ -1,285 +1,319 @@ /*========================================================================= Program: BlueBerry Platform Language: C++ Date: $Date$ Version: $Revision$ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #include "berryLog.h" #include "Poco/Exception.h" #include "berryBundle.h" #include "berryInternalPlatform.h" #include "../berryBundleLoader.h" #include "berryBundleManifest.h" #include "../berryIBundleActivator.h" #include "../berryIBundleContext.h" #include "../berryPlatformException.h" +#include + #include namespace berry { -Bundle::Bundle(BundleLoader& loader, IBundleStorage::Pointer storage) : +Bundle::Bundle(BundleLoader& loader, IBundleStorage::Pointer storage, bool initialize) : m_BundleLoader(loader) { + { + Poco::Mutex::ScopedLock lock(m_Mutex); + m_Storage = storage; + } - Poco::Mutex::ScopedLock lock(m_Mutex); - m_Storage = storage; + if (initialize) + { + init(); + } +} +void Bundle::init() +{ + Poco::Mutex::ScopedLock lock(m_Mutex); try { this->LoadManifest(); m_State = BUNDLE_INSTALLED; } catch (Poco::FileException& exc) { BERRY_ERROR << "Exception: " << exc.displayText() << std::endl; m_State = BUNDLE_UNINSTALLED; } } Bundle::~Bundle() { } bool Bundle::operator==(const Object* o) const { if (const IBundle* bundle = dynamic_cast(o)) return this->GetSymbolicName() == bundle->GetSymbolicName(); return false; } IBundleActivator* Bundle::GetActivator() const { Poco::Mutex::ScopedLock lock(m_Mutex); if (m_State == BUNDLE_ACTIVE) return m_Activator; return 0; } const std::string& Bundle::GetActivatorClass() const { return m_Manifest->GetActivatorClass(); } const std::string& Bundle::GetActivatorLibrary() const { return m_Manifest->GetActivatorLibrary(); } const std::string& Bundle::GetCopyright() const { return m_Manifest->GetCopyright(); } const std::string& Bundle::GetVendor() const { return m_Manifest->GetVendor(); } IBundleManifest::ActivationPolicy Bundle::GetActivationPolicy() const { return m_Manifest->GetActivationPolicy(); } std::istream* Bundle::GetLocalizedResource(const std::string& name) const { return m_Storage->GetResource(name); } std::istream* Bundle::GetResource(const std::string& name) const { return m_Storage->GetResource(name); } bool Bundle::IsActive() const { return m_State == BUNDLE_ACTIVE; } bool Bundle::IsResolved() const { return m_State == BUNDLE_RESOLVED || m_State == BUNDLE_STARTING || m_State == BUNDLE_ACTIVE || m_State == BUNDLE_STOPPING; } bool Bundle::IsStarted() const { return m_State == BUNDLE_STARTING || m_State == BUNDLE_ACTIVE || m_State == BUNDLE_STOPPING; } bool Bundle::IsSystemBundle() const { return m_Manifest->IsSystemBundle(); } const IBundleManifest& Bundle::GetManifest() const { return *m_Manifest; } const std::string& Bundle::GetName() const { return m_Manifest->GetName(); } const Poco::Path Bundle::GetPath() const { return m_Storage->GetPath(); } IBundleStorage& Bundle::GetStorage() { return *m_Storage; } // const Version& GetVersion() const; const IBundleManifest::Dependencies& Bundle::GetRequiredBundles() const { return m_Manifest->GetRequiredBundles(); } void Bundle::Resolve() { if (m_State == BUNDLE_INSTALLED) { + ctkPluginContext* context = InternalPlatform::GetInstance()->GetCTKPluginFrameworkContext(); + //const BundleManifest::Dependencies& dependencies =; IBundleManifest::Dependencies::const_iterator iter; for (iter = this->GetRequiredBundles().begin(); iter != this->GetRequiredBundles().end(); ++iter) { //BERRY_INFO << "Checking dependency:" << iter->symbolicName << ";\n"; IBundle::Pointer bundle = m_BundleLoader.FindBundle(iter->symbolicName); if (bundle.IsNull()) - throw BundleResolveException("The bundle " + this->GetSymbolicName() + " depends on missing bundle:", iter->symbolicName); + { + // Check if we have a CTK Plugin dependency + bool resolved = false; + if (context) + { + QString symbolicName = QString::fromStdString(iter->symbolicName); + foreach (QSharedPointer plugin, context->getPlugins()) + { + if (plugin->getSymbolicName() == symbolicName) + { + resolved = true; + break; + } + } + } + + if (!resolved) + { + throw BundleResolveException("The bundle " + this->GetSymbolicName() + " depends on missing bundle:", iter->symbolicName); + } + } else if (!bundle->IsResolved()) { bundle->Resolve(); } } m_State = BUNDLE_RESOLVED; } } void Bundle::Start() { if (m_State == BUNDLE_RESOLVED) { Poco::Mutex::ScopedLock lock(m_Mutex); m_State = BUNDLE_STARTING; // BundleEvent starting(this, BundleEvent::EV_BUNDLE_STARTING); // this->GetEvents().bundleStarting(this, starting); BERRY_INFO(InternalPlatform::GetInstance()->ConsoleLog()) << "Bundle " << this->GetSymbolicName() << " is starting"; m_Activator->Start(m_BundleLoader.GetContextForBundle(IBundle::Pointer(this))); m_State = BUNDLE_ACTIVE; // BundleEvent started(this, BundleEvent::EV_BUNDLE_STARTED); // this->GetEvents().bundleStarted(this, started); // BERRY_INFO << "Bundle " << this->GetSymbolicName() << " is active"; } else { throw BundleStateException("Bundle " + this->GetSymbolicName() + " could not be started, because it is not in state RESOLVED."); } } void Bundle::Stop() { throw Poco::NotImplementedException("Bundle::Stop() not implemented yet"); } Bundle::State Bundle::GetState() const { return m_State; } std::string Bundle::GetStateString() const { switch (this->GetState()) { case BUNDLE_INSTALLED: return "Installed"; case BUNDLE_UNINSTALLED: return "Uninstalled"; case BUNDLE_RESOLVED: return "Resolved"; case BUNDLE_STARTING: return "Starting"; case BUNDLE_ACTIVE: return "Active"; case BUNDLE_STOPPING: return "Stopping"; default: throw BundleStateException("The bundle is not in a valid state"); } } BundleEvents& Bundle::GetEvents() { return m_BundleLoader.GetEvents(); } const std::string& Bundle::GetSymbolicName() const { return m_Manifest->GetSymbolicName(); } void Bundle::LoadManifest() { std::istream* istr = m_Storage->GetResource("META-INF/MANIFEST.MF"); if (!istr) throw Poco::FileNotFoundException("Could not load META-INF/MANIFEST.MF from " + m_Storage->GetPath().toString()); m_Manifest = new BundleManifest(istr); delete istr; } void Bundle::SetActivator(IBundleActivator* activator) { Poco::Mutex::ScopedLock lock(m_Mutex); m_Activator = activator; } } diff --git a/BlueBerry/Bundles/org.blueberry.osgi/src/internal/berryBundle.h b/BlueBerry/Bundles/org.blueberry.osgi/src/internal/berryBundle.h index 4a4a07ce77..a9c3ee0f5c 100644 --- a/BlueBerry/Bundles/org.blueberry.osgi/src/internal/berryBundle.h +++ b/BlueBerry/Bundles/org.blueberry.osgi/src/internal/berryBundle.h @@ -1,97 +1,99 @@ /*========================================================================= Program: BlueBerry Platform Language: C++ Date: $Date$ Version: $Revision$ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #ifndef BERRYBUNDLE_H_ #define BERRYBUNDLE_H_ #include "Poco/Path.h" #include "Poco/Mutex.h" #include "../berryIBundle.h" #include "../berryIBundleStorage.h" namespace berry { class BundleLoader; class Bundle : public IBundle { public: berryObjectMacro(Bundle); - Bundle(BundleLoader& loader, IBundleStorage::Pointer storage); + Bundle(BundleLoader& loader, IBundleStorage::Pointer storage, bool init = true); ~Bundle(); + + void init(); IBundleActivator* GetActivator() const; const std::string& GetActivatorClass() const; const std::string& GetActivatorLibrary() const; const std::string& GetCopyright() const; const std::string& GetVendor() const; IBundleManifest::ActivationPolicy GetActivationPolicy() const; std::istream* GetLocalizedResource(const std::string& name) const; std::istream* GetResource(const std::string& name) const; bool IsActive() const; bool IsResolved() const; bool IsStarted() const; bool IsSystemBundle() const; const IBundleManifest& GetManifest() const; const std::string& GetName() const; const Poco::Path GetPath() const; IBundleStorage& GetStorage(); // const Version& GetVersion() const; const IBundleManifest::Dependencies& GetRequiredBundles() const; void Resolve(); void Start(); void Stop(); State GetState() const; std::string GetStateString() const; BundleEvents& GetEvents(); const std::string& GetSymbolicName() const; - void LoadManifest(); + virtual void LoadManifest(); void SetActivator(IBundleActivator* activator); bool operator==(const Object* o) const; protected: IBundleManifest::Pointer m_Manifest; IBundleStorage::Pointer m_Storage; BundleLoader& m_BundleLoader; IBundleActivator* m_Activator; State m_State; mutable Poco::Mutex m_Mutex; }; } // namespace berry #endif /*BERRYBUNDLE_H_*/ diff --git a/BlueBerry/Bundles/org.blueberry.osgi/src/internal/berryCTKPluginActivator.cpp b/BlueBerry/Bundles/org.blueberry.osgi/src/internal/berryCTKPluginActivator.cpp new file mode 100755 index 0000000000..7ee8640d93 --- /dev/null +++ b/BlueBerry/Bundles/org.blueberry.osgi/src/internal/berryCTKPluginActivator.cpp @@ -0,0 +1,66 @@ +/*========================================================================= + + Program: BlueBerry Platform + Language: C++ + Date: $Date$ + Version: $Revision$ + + Copyright (c) German Cancer Research Center, Division of Medical and + Biological Informatics. All rights reserved. + See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. + + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the above copyright notices for more information. + + =========================================================================*/ + +#include "berryCTKPluginActivator.h" + +#include "berrySystemBundle.h" +#include "berryInternalPlatform.h" + +#include + +#include +#include + +#include + +namespace berry { + +ctkPluginContext* org_blueberry_osgi_Activator::context = 0; + +void org_blueberry_osgi_Activator::start(ctkPluginContext* context) +{ + this->context = context; + + SystemBundle::Pointer systemBundle = InternalPlatform::GetInstance()->GetBundle("system.bundle").Cast(); + ExtensionPointService::Pointer service(new ExtensionPointService(&systemBundle->GetBundleLoader())); + + // register the service in the legacy BlueBerry service registry + Platform::GetServiceRegistry().RegisterService(IExtensionPointService::SERVICE_ID, service); + + // register the service in the CTK service registry + context->registerService(service.GetPointer()); +} + +void org_blueberry_osgi_Activator::stop(ctkPluginContext* context) +{ + Q_UNUSED(context) + + Platform::GetServiceRegistry().UnRegisterService(IExtensionPointService::SERVICE_ID); + + this->context = 0; + + // TODO stop framework +} + +ctkPluginContext* org_blueberry_osgi_Activator::getPluginContext() +{ + return context; +} + +} + +Q_EXPORT_PLUGIN2(org_blueberry_osgi, berry::org_blueberry_osgi_Activator) diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/berryFileEditorInput.h b/BlueBerry/Bundles/org.blueberry.osgi/src/internal/berryCTKPluginActivator.h old mode 100644 new mode 100755 similarity index 50% copy from BlueBerry/Bundles/org.blueberry.ui/src/berryFileEditorInput.h copy to BlueBerry/Bundles/org.blueberry.osgi/src/internal/berryCTKPluginActivator.h index 513f9f2ccb..5d23b6406a --- a/BlueBerry/Bundles/org.blueberry.ui/src/berryFileEditorInput.h +++ b/BlueBerry/Bundles/org.blueberry.osgi/src/internal/berryCTKPluginActivator.h @@ -1,54 +1,52 @@ /*========================================================================= Program: BlueBerry Platform Language: C++ Date: $Date$ Version: $Revision$ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ +#ifndef BERRYCTKPLUGINACTIVATOR_H +#define BERRYCTKPLUGINACTIVATOR_H -#ifndef BERRYFILEEDITORINPUT_H_ -#define BERRYFILEEDITORINPUT_H_ - -#include "berryIPathEditorInput.h" -#include "berryUiDll.h" +#include +#include +#include namespace berry { -class BERRY_UI FileEditorInput : public IPathEditorInput +// We need to export this activator, because it is referenced +// in the templated method berry::ServiceRegistry::GetServiceById<>(...) +class BERRY_OSGI org_blueberry_osgi_Activator : public QObject, public ctkPluginActivator { + Q_OBJECT + Q_INTERFACES(ctkPluginActivator) public: - berryObjectMacro(FileEditorInput); - - FileEditorInput(const Poco::Path& path); - - Poco::Path GetPath() const; - - bool Exists() const; + void start(ctkPluginContext* context); + void stop(ctkPluginContext* context); - std::string GetName() const ; - - std::string GetToolTipText() const; - - bool operator==(const Object* o) const; + static ctkPluginContext* getPluginContext(); private: - Poco::Path m_Path; + static ctkPluginContext* context; + }; +typedef org_blueberry_osgi_Activator CTKPluginActivator; + } -#endif /* BERRYFILEEDITORINPUT_H_ */ +#endif // BERRYCTKPLUGINACTIVATOR_H diff --git a/BlueBerry/Bundles/org.blueberry.osgi/src/internal/berryExtensionPointService.h b/BlueBerry/Bundles/org.blueberry.osgi/src/internal/berryExtensionPointService.h index c1f6a6f9a3..147b051996 100644 --- a/BlueBerry/Bundles/org.blueberry.osgi/src/internal/berryExtensionPointService.h +++ b/BlueBerry/Bundles/org.blueberry.osgi/src/internal/berryExtensionPointService.h @@ -1,78 +1,83 @@ /*========================================================================= Program: BlueBerry Platform Language: C++ Date: $Date$ Version: $Revision$ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #ifndef BERRYEXTENSIONPOINTSERVICE_H_ #define BERRYEXTENSIONPOINTSERVICE_H_ #include "../berryMacros.h" #include "Poco/SAX/InputSource.h" #include "Poco/DOM/DOMParser.h" #include "../service/berryIConfigurationElement.h" #include "berryExtensionPoint.h" #include "../service/berryIExtensionPointService.h" #include +#include + namespace berry { class Bundle; class BundleLoader; -class ExtensionPointService : public IExtensionPointService +class ExtensionPointService : public QObject, public IExtensionPointService { - berryObjectMacro(ExtensionPointService); + Q_OBJECT + Q_INTERFACES(berry::IExtensionPointService) public: + + berryObjectMacro(ExtensionPointService); bool IsA(const std::type_info& type); const std::type_info& GetType() const; ExtensionPointService(BundleLoader* loader); void AddContribution(std::istream& istr, const std::string& contributor); const std::vector GetConfigurationElementsFor(const std::string& extensionPointId) const; const IExtension* GetExtension(const std::string& extensionPointId, const std::string& extensionId) const; const IExtensionPoint* GetExtensionPoint(const std::string& id) const; const std::vector GetExtensions(const std::string& contributor) const; const std::vector GetExtensionPoints() const; const std::vector GetExtensionPoints(const std::string& contributor) const; bool HasContributionFrom(const std::string& name) const; private: typedef std::map ExtensionPointMap; std::set m_Contributors; BundleLoader* m_BundleLoader; ExtensionPointMap m_ExtensionPointMap; Poco::XML::DOMParser m_DOMParser; Poco::XML::InputSource m_XMLInputSource; bool m_ConsoleLog; }; } // namespace berry #endif /*BERRYEXTENSIONPOINTSERVICE_H_*/ diff --git a/BlueBerry/Bundles/org.blueberry.osgi/src/internal/berryInternalPlatform.cpp b/BlueBerry/Bundles/org.blueberry.osgi/src/internal/berryInternalPlatform.cpp index f3e5b8bba9..5b57acb790 100644 --- a/BlueBerry/Bundles/org.blueberry.osgi/src/internal/berryInternalPlatform.cpp +++ b/BlueBerry/Bundles/org.blueberry.osgi/src/internal/berryInternalPlatform.cpp @@ -1,407 +1,483 @@ /*========================================================================= Program: BlueBerry Platform Language: C++ Date: $Date$ Version: $Revision$ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #include "berryInternalPlatform.h" #include "berryLog.h" #include #include #include #include #include #include #include #include +#include +#include +#include +#include +#include + #include #include "../berryPlatform.h" #include "../berryPlatformException.h" #include "../berryDebugUtil.h" #include "../event/berryPlatformEvents.h" #include "berryPlatformLogChannel.h" #include "../berryIBundle.h" #include "berryCodeCache.h" #include "../berryBundleLoader.h" #include "berrySystemBundle.h" +#include "berryBundleDirectory.h" +#include "berryProvisioningInfo.h" + +#include namespace berry { Poco::Mutex InternalPlatform::m_Mutex; InternalPlatform::InternalPlatform() : m_Initialized(false), m_Running(false), m_ConsoleLog(false), m_ServiceRegistry(0), m_CodeCache(0), m_BundleLoader(0), m_SystemBundle(0), m_PlatformLogger(0), + m_ctkPluginFrameworkFactory(0), m_EventStarted(PlatformEvent::EV_PLATFORM_STARTED) { } InternalPlatform::~InternalPlatform() { } InternalPlatform* InternalPlatform::GetInstance() { Poco::Mutex::ScopedLock lock(m_Mutex); static InternalPlatform instance; return &instance; } bool InternalPlatform::ConsoleLog() const { return m_ConsoleLog; } +ctkPluginContext* InternalPlatform::GetCTKPluginFrameworkContext() const +{ + if (m_ctkPluginFrameworkFactory) + { + return m_ctkPluginFrameworkFactory->getFramework()->getPluginContext(); + } + return 0; +} + ServiceRegistry& InternalPlatform::GetServiceRegistry() { AssertInitialized(); return *m_ServiceRegistry; } void InternalPlatform::Initialize(int& argc, char** argv, Poco::Util::AbstractConfiguration* config) { // initialization Poco::Mutex::ScopedLock lock(m_Mutex); m_Argc = &argc; m_Argv = argv; try { this->init(argc, argv); } catch (const Poco::Util::UnknownOptionException& e) { BERRY_WARN << e.displayText(); } this->loadConfiguration(); if (config) { this->config().add(config, 50, false); } m_ServiceRegistry = new ServiceRegistry(); m_ConsoleLog = this->GetConfiguration().hasProperty(Platform::ARG_CONSOLELOG); m_ConfigPath.assign(this->GetConfiguration().getString("application.configDir")); m_InstancePath.assign(this->GetConfiguration().getString("application.dir")); try { m_InstallPath.assign(this->GetConfiguration().getString(Platform::ARG_HOME)); } catch (Poco::NotFoundException& ) { m_InstallPath.assign(m_InstancePath); } m_UserPath.assign(Poco::Path::home()); m_UserPath.pushDirectory("." + this->commandName()); Poco::File userFile(m_UserPath); try { userFile.createDirectory(); userFile.canWrite(); } catch(const Poco::IOException& e) { BERRY_WARN << e.displayText(); m_UserPath.assign(Poco::Path::temp()); m_UserPath.pushDirectory("." + this->commandName()); userFile = m_UserPath; } m_BaseStatePath = m_UserPath; m_BaseStatePath.pushDirectory(".metadata"); m_BaseStatePath.pushDirectory(".plugins"); Poco::Path logPath(m_UserPath); logPath.setFileName(this->commandName() + ".log"); m_PlatformLogChannel = new PlatformLogChannel(logPath.toString()); m_PlatformLogger = &Poco::Logger::create("PlatformLogger", m_PlatformLogChannel, Poco::Message::PRIO_TRACE); try { m_CodeCache = new CodeCache(this->GetConfiguration().getString(Platform::ARG_PLUGIN_CACHE)); } catch (Poco::NotFoundException&) { Poco::Path cachePath(m_UserPath); cachePath.pushDirectory("plugin_cache"); m_CodeCache = new CodeCache(cachePath.toString()); } m_BundleLoader = new BundleLoader(m_CodeCache, *m_PlatformLogger); + // Initialize the CTK Plugin Framework + ctkProperties fwProps; + fwProps.insert(ctkPluginConstants::FRAMEWORK_STORAGE, QString::fromStdString(userFile.path())); + m_ctkPluginFrameworkFactory = new ctkPluginFrameworkFactory(fwProps); + QSharedPointer pfw = m_ctkPluginFrameworkFactory->getFramework(); + pfw->init(); + ctkPluginContext* pfwContext = pfw->getPluginContext(); + + std::string provisioningFile = this->GetConfiguration().getString(Platform::ARG_PROVISIONING); + if (!provisioningFile.empty()) + { + ProvisioningInfo provInfo(QString::fromStdString(provisioningFile)); + foreach(QString pluginPath, provInfo.getPluginDirs()) + { + ctkPluginFrameworkLauncher::addSearchPath(pluginPath); + } + + QList pluginsToStart = provInfo.getPluginsToStart(); + foreach(QUrl pluginUrl, provInfo.getPluginsToInstall()) + { + QSharedPointer plugin = pfwContext->installPlugin(pluginUrl); + if (pluginsToStart.contains(pluginUrl)) + { + m_CTKPluginsToStart << plugin->getPluginId(); + } + } + } + + // tell the BundleLoader about the installed CTK plug-ins + QStringList installedCTKPlugins; + foreach(QSharedPointer plugin, pfwContext->getPlugins()) + { + installedCTKPlugins << plugin->getSymbolicName(); + } + m_BundleLoader->SetCTKPlugins(installedCTKPlugins); m_Initialized = true; // Clear the CodeCache if (this->GetConfiguration().hasProperty(Platform::ARG_CLEAN)) m_CodeCache->Clear(); try { // assemble a list of base plugin-directories (which contain // the real plugins as directories) std::vector pluginBaseDirs; - Poco::StringTokenizer tokenizer(this->GetConfiguration().getString(Platform::ARG_PLUGIN_DIRS), ";", + Poco::StringTokenizer tokenizer(this->GetConfiguration().getString(Platform::ARG_PLUGIN_DIRS, ""), ";", Poco::StringTokenizer::TOK_IGNORE_EMPTY | Poco::StringTokenizer::TOK_TRIM); for (Poco::StringTokenizer::Iterator token = tokenizer.begin(); token != tokenizer.end(); ++token) { pluginBaseDirs.push_back(*token); } std::vector pluginPaths; for (std::vector::iterator pluginBaseDir = pluginBaseDirs.begin(); pluginBaseDir != pluginBaseDirs.end(); ++pluginBaseDir) { BERRY_INFO(m_ConsoleLog) << "Plugin base directory: " << *pluginBaseDir; Poco::File pluginDir(*pluginBaseDir); if (!pluginDir.exists() || !pluginDir.isDirectory()) { BERRY_WARN(m_ConsoleLog) << *pluginBaseDir << " is not a direcotry or does not exist. SKIPPED.\n"; continue; } std::vector pluginList; pluginDir.list(pluginList); std::vector::iterator iter; for (iter = pluginList.begin(); iter != pluginList.end(); iter++) { Poco::Path pluginPath = Poco::Path::forDirectory(*pluginBaseDir); pluginPath.pushDirectory(*iter); Poco::File file(pluginPath); if (file.exists() && file.isDirectory()) { pluginPaths.push_back(pluginPath); } } } std::vector::iterator pathIter; for (pathIter = pluginPaths.begin(); pathIter != pluginPaths.end(); pathIter++) { try { Bundle::Pointer bundle = m_BundleLoader->LoadBundle(*pathIter); - BERRY_INFO(m_ConsoleLog) << "Bundle state (" << pathIter->toString() << "): " << bundle->GetStateString() << std::endl; + if (bundle) + { + BERRY_INFO(m_ConsoleLog) << "Bundle state (" << pathIter->toString() << "): " << bundle->GetStateString() << std::endl; + } } catch (const BundleStateException& exc) { BERRY_WARN << exc.displayText() << std::endl; } } // resolve plugins m_BundleLoader->ResolveAllBundles(); } catch (Poco::Exception& exc) { this->logger().log(exc); } #ifdef BLUEBERRY_DEBUG_SMARTPOINTER DebugUtil::RestoreState(); #endif } void InternalPlatform::Launch() { AssertInitialized(); if (m_Running) return; m_Running = true; this->run(); } void InternalPlatform::Shutdown() { Poco::Mutex::ScopedLock lock(m_Mutex); AssertInitialized(); DebugUtil::SaveState(); m_Initialized = false; this->uninitialize(); delete m_ServiceRegistry; delete m_BundleLoader; delete m_CodeCache; } void InternalPlatform::AssertInitialized() { if (!m_Initialized) throw Poco::SystemException("The Platform has not been initialized yet!"); } IExtensionPointService::Pointer InternalPlatform::GetExtensionPointService() { Poco::Mutex::ScopedLock lock(m_Mutex); this->AssertInitialized(); return m_ServiceRegistry->GetServiceById(IExtensionPointService::SERVICE_ID); } const Poco::Path& InternalPlatform::GetConfigurationPath() { return m_ConfigPath; } const Poco::Path& InternalPlatform::GetInstallPath() { return m_InstallPath; } const Poco::Path& InternalPlatform::GetInstancePath() { return m_InstancePath; } bool InternalPlatform::GetStatePath(Poco::Path& statePath, IBundle::Pointer bundle, bool create) { statePath = m_BaseStatePath; statePath.pushDirectory(bundle->GetSymbolicName()); try { Poco::File stateFile(statePath); if (!stateFile.exists() && create) stateFile.createDirectories(); } catch (Poco::FileException&) { return false; } return true; } PlatformEvents& InternalPlatform::GetEvents() { return m_Events; } const Poco::Path& InternalPlatform::GetUserPath() { return m_UserPath; } bool InternalPlatform::IsRunning() const { Poco::Mutex::ScopedLock lock(m_Mutex); return (m_Initialized && m_Running); } IBundle::Pointer InternalPlatform::GetBundle(const std::string& id) { Poco::Mutex::ScopedLock lock(m_Mutex); AssertInitialized(); return m_BundleLoader->FindBundle(id); } +std::vector InternalPlatform::GetBundles() const +{ + return m_BundleLoader->GetBundles(); +} + Poco::Logger* InternalPlatform::GetLogger() { return m_PlatformLogger; } Poco::Util::LayeredConfiguration& InternalPlatform::GetConfiguration() const { return this->config(); } std::vector InternalPlatform::GetApplicationArgs() const { return m_FilteredArgs; } int& InternalPlatform::GetRawApplicationArgs(char**& argv) { argv = m_Argv; return *m_Argc; } void InternalPlatform::defineOptions(Poco::Util::OptionSet& options) { Poco::Util::Option helpOption("help", "h", "print this help text"); helpOption.callback(Poco::Util::OptionCallback(this, &InternalPlatform::PrintHelp)); options.addOption(helpOption); Poco::Util::Option cleanOption(Platform::ARG_CLEAN, "", "cleans the plugin cache"); cleanOption.binding(Platform::ARG_CLEAN); options.addOption(cleanOption); Poco::Util::Option appOption(Platform::ARG_APPLICATION, "", "the id of the application extension to be executed"); appOption.argument("").binding(Platform::ARG_APPLICATION); options.addOption(appOption); Poco::Util::Option consoleLogOption(Platform::ARG_CONSOLELOG, "", "log messages to the console"); consoleLogOption.binding(Platform::ARG_CONSOLELOG); options.addOption(consoleLogOption); Poco::Util::Option testPluginOption(Platform::ARG_TESTPLUGIN, "", "the plug-in to be tested"); testPluginOption.argument("").binding(Platform::ARG_TESTPLUGIN); options.addOption(testPluginOption); Poco::Util::Option testAppOption(Platform::ARG_TESTAPPLICATION, "", "the application to be tested"); testAppOption.argument("").binding(Platform::ARG_TESTAPPLICATION); options.addOption(testAppOption); Poco::Util::Application::defineOptions(options); } int InternalPlatform::main(const std::vector& args) { m_FilteredArgs = args; m_FilteredArgs.insert(m_FilteredArgs.begin(), this->config().getString("application.argv[0]")); - SystemBundle::Pointer systemBundle = m_BundleLoader->FindBundle("system.bundle").Cast(); + ctkPluginContext* context = GetCTKPluginFrameworkContext(); + QFileInfo storageDir = context->getDataFile(""); + BundleDirectory::Pointer bundleStorage(new BundleDirectory(Poco::Path(storageDir.absolutePath().toStdString()))); + SystemBundle::Pointer systemBundle(new SystemBundle(*m_BundleLoader, bundleStorage)); if (systemBundle == 0) throw PlatformException("Could not find the system bundle"); + m_BundleLoader->m_SystemBundle = systemBundle; + m_BundleLoader->LoadBundle(systemBundle); + + m_ctkPluginFrameworkFactory->getFramework()->start(); + foreach(long pluginId, m_CTKPluginsToStart) + { + // do not change the autostart setting of this plugin + context->getPlugin(pluginId)->start(ctkPlugin::START_TRANSIENT | ctkPlugin::START_ACTIVATION_POLICY); + } + m_BundleLoader->StartSystemBundle(systemBundle); systemBundle->Resume(); return EXIT_OK; } void InternalPlatform::PrintHelp(const std::string&, const std::string&) { Poco::Util::HelpFormatter help(this->options()); help.setAutoIndent(); help.setCommand(this->commandName()); help.format(std::cout); exit(EXIT_OK); } } diff --git a/BlueBerry/Bundles/org.blueberry.osgi/src/internal/berryInternalPlatform.h b/BlueBerry/Bundles/org.blueberry.osgi/src/internal/berryInternalPlatform.h index 488a3faa89..12094e9814 100644 --- a/BlueBerry/Bundles/org.blueberry.osgi/src/internal/berryInternalPlatform.h +++ b/BlueBerry/Bundles/org.blueberry.osgi/src/internal/berryInternalPlatform.h @@ -1,136 +1,146 @@ /*========================================================================= Program: BlueBerry Platform Language: C++ Date: $Date$ Version: $Revision$ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #ifndef BERRYINTERNALPLATFORM_H_ #define BERRYINTERNALPLATFORM_H_ #include #include #include #include #include #include "../event/berryPlatformEvents.h" #include "../service/berryServiceRegistry.h" #include "berryExtensionPointService.h" #include +class ctkPluginFrameworkFactory; +class ctkPluginContext; + namespace berry { struct IBundle; class CodeCache; class BundleLoader; class PlatformLogChannel; class SystemBundle; class BERRY_OSGI InternalPlatform : private Poco::Util::Application { private: static Poco::Mutex m_Mutex; bool m_Initialized; bool m_Running; bool m_ConsoleLog; ServiceRegistry* m_ServiceRegistry; Poco::Path m_BaseStatePath; Poco::Path m_InstallPath; Poco::Path m_InstancePath; Poco::Path m_UserPath; Poco::Path m_ConfigPath; std::vector m_FilteredArgs; CodeCache* m_CodeCache; BundleLoader* m_BundleLoader; SystemBundle* m_SystemBundle; Poco::AutoPtr m_PlatformLogChannel; Poco::Logger* m_PlatformLogger; + ctkPluginFrameworkFactory* m_ctkPluginFrameworkFactory; + QList m_CTKPluginsToStart; + PlatformEvents m_Events; PlatformEvent m_EventStarted; int* m_Argc; char** m_Argv; //std::map m_ArgMap; InternalPlatform(); //InternalPlatform(const InternalPlatform&) : m_EventStarted(PlatformEvent::EV_PLATFORM_STARTED) {}; void AssertInitialized(); // Poco::Application method overrides void defineOptions(Poco::Util::OptionSet& options); int main(const std::vector& args); public: virtual ~InternalPlatform(); void PrintHelp(const std::string& name, const std::string& value); static InternalPlatform* GetInstance(); void Initialize(int& argc, char** argv, Poco::Util::AbstractConfiguration* config = 0); void Launch(); void Shutdown(); + ctkPluginContext* GetCTKPluginFrameworkContext() const; + /// Returns a ServiceRegistry object for registering /// and accessing services from different plugins ServiceRegistry& GetServiceRegistry(); /// Convenience method to quickly get the extension /// point service, which is automatically started /// by the platform IExtensionPointService::Pointer GetExtensionPointService(); bool ConsoleLog() const; const Poco::Path& GetConfigurationPath(); const Poco::Path& GetInstallPath(); const Poco::Path& GetInstancePath(); bool GetStatePath(Poco::Path& statePath, SmartPointer bundle, bool create = true); const Poco::Path& GetUserPath(); PlatformEvents& GetEvents(); bool IsRunning() const; Poco::Util::LayeredConfiguration& GetConfiguration() const; std::vector GetApplicationArgs() const; int& GetRawApplicationArgs(char**& argv); IBundle::Pointer GetBundle(const std::string& id); + std::vector GetBundles() const; + Poco::Logger* GetLogger(); }; } // namespace berry #endif /*BERRYINTERNALPLATFORM_H_*/ diff --git a/BlueBerry/Bundles/org.blueberry.osgi/src/internal/berryProvisioningInfo.cpp b/BlueBerry/Bundles/org.blueberry.osgi/src/internal/berryProvisioningInfo.cpp new file mode 100644 index 0000000000..2bd12dd0f5 --- /dev/null +++ b/BlueBerry/Bundles/org.blueberry.osgi/src/internal/berryProvisioningInfo.cpp @@ -0,0 +1,229 @@ +/*========================================================================= + +Program: BlueBerry Platform +Language: C++ +Date: $Date$ +Version: $Revision$ + +Copyright (c) German Cancer Research Center, Division of Medical and +Biological Informatics. All rights reserved. +See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. + +This software is distributed WITHOUT ANY WARRANTY; without even +the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ + + +#include "berryProvisioningInfo.h" + +#include + +#include +#include +#include +#include + +namespace berry { + +#ifdef CMAKE_INTDIR +const QString ProvisioningInfo::intermediateOutDir = QString(CMAKE_INTDIR); +#else +const QString ProvisioningInfo::intermediateOutDir = QString(); +#endif + +ProvisioningInfo::ProvisioningInfo(const QString& file) +{ + this->readProvisioningFile(file); +} + +QStringList ProvisioningInfo::getPluginDirs() const +{ + return pluginDirs.toList(); +} + +QList ProvisioningInfo::getPluginsToInstall() const +{ + return pluginsToInstall; +} + +QList ProvisioningInfo::getPluginsToStart() const +{ + return pluginsToStart; +} + +void ProvisioningInfo::readProvisioningFile(const QString& filePath) +{ + QFile file(filePath); + file.open(QFile::ReadOnly); + QTextStream fileStream(&file); + QRegExp sep("\\s+"); + QString line; + int count = 1; + do { + line = fileStream.readLine().trimmed(); + if (!line.isEmpty() && !line.startsWith('#')) + { + QString keyword = line.section(sep, 0, 0); + QString value = line.mid(keyword.size()).trimmed(); + value = substituteKeywords(value); + + if (keyword.isEmpty()) + { + BERRY_WARN << "Keyword missing in line " << count + << " of provisioning file " << filePath.toStdString(); + continue; + } + + Keyword key = UNKNOWN; + if (keyword.compare("READ", Qt::CaseInsensitive) == 0) + { + key = READ; + } + else if (keyword.compare("INSTALL", Qt::CaseInsensitive) == 0) + { + key = INSTALL; + } + else if (keyword.compare("START", Qt::CaseInsensitive) == 0) + { + key = START; + } + else if (keyword.compare("STOP", Qt::CaseInsensitive) == 0) + { + key = STOP; + } + + if (key == UNKNOWN) + { + BERRY_WARN << "Keyword " << keyword.toStdString() << " in line " + << count << " of provisioning file " + << filePath.toStdString() << " unknown"; + continue; + } + + if (value.isEmpty()) + { + BERRY_WARN << "Value after keyword " << keyword.toStdString() + << " missing in line " << count + << " of provisioning file " << filePath.toStdString(); + continue; + } + + switch (key) + { + case READ: + { + QUrl readFileUrl(value); + if (!readFileUrl.isValid()) + { + BERRY_WARN << "The READ URL " << value.toStdString() + << "is invalid: " << readFileUrl.errorString().toStdString(); + break; + } + this->readProvisioningFile(readFileUrl.toLocalFile()); + break; + } + case INSTALL: + { + this->addPluginToInstall(value); + break; + } + case START: + { + this->addPluginToStart(value); + break; + } + case STOP: + { + break; + } + } + } + ++count; + } while (!line.isNull()); +} + +QUrl ProvisioningInfo::addPluginToInstall(const QString& file) +{ + QUrl pluginUrl(file); + if (!pluginUrl.isValid()) + { + BERRY_WARN << "The plugin URL " << file.toStdString() << " is invalid:" + << pluginUrl.errorString().toStdString(); + return QUrl(); + } + + QFileInfo fileInfo(pluginUrl.toLocalFile()); + if (!fileInfo.exists()) + { + QString fileName = fileInfo.fileName(); + QString filePath = fileInfo.absolutePath(); + if (!intermediateOutDir.isEmpty()) + { + // search in the intermediate output dir + QString filePath2 = filePath + "/" + intermediateOutDir; + fileInfo = QFileInfo(filePath2 + "/" + fileName); + if (!fileInfo.exists()) + { + BERRY_WARN << "The plugin " << fileName.toStdString() << " was not found in " + << filePath.toStdString() << " or " << filePath2.toStdString(); + return QUrl(); + } + pluginUrl = QUrl::fromLocalFile(fileInfo.canonicalFilePath()); + pluginDirs.insert(fileInfo.canonicalPath()); + } + else + { + BERRY_WARN << "The plugin " << fileName.toStdString() << " was not found in " + << filePath.toStdString(); + return QUrl(); + } + } + else + { + pluginDirs.insert(fileInfo.canonicalPath()); + } + + pluginsToInstall.append(pluginUrl); + return pluginUrl; +} + +void ProvisioningInfo::addPluginToStart(const QString& file) +{ + QUrl pluginUrl = this->addPluginToInstall(file); + if (!pluginUrl.isEmpty()) + { + pluginsToStart.append(pluginUrl); + } +} + +QString ProvisioningInfo::substituteKeywords(const QString& value) const +{ + QString appPath = QCoreApplication::applicationDirPath(); + if (appPath.endsWith('/')) + { + appPath.chop(1); + } + +#ifdef CMAKE_INTDIR + // Strip the intermediate dir from the application path + QString intDir(CMAKE_INTDIR); + if (appPath.endsWith(intDir)) + { + appPath.chop(intDir.size()+1); + } +#endif + +#ifdef _WIN32 + if (value.contains("@EXECUTABLE_DIR") && value.contains("blueberry_osgi")) + { + // special case for org_blueberry_osgi in install trees for Windows + return QString(value).replace("@EXECUTABLE_DIR", appPath, Qt::CaseInsensitive).replace("plugins/", ""); + } +#endif + + return QString(value).replace("@EXECUTABLE_DIR", appPath, Qt::CaseInsensitive); +} + +} diff --git a/BlueBerry/Bundles/org.blueberry.osgi/src/internal/berryProvisioningInfo.h b/BlueBerry/Bundles/org.blueberry.osgi/src/internal/berryProvisioningInfo.h new file mode 100644 index 0000000000..18715c8770 --- /dev/null +++ b/BlueBerry/Bundles/org.blueberry.osgi/src/internal/berryProvisioningInfo.h @@ -0,0 +1,63 @@ +/*========================================================================= + +Program: BlueBerry Platform +Language: C++ +Date: $Date$ +Version: $Revision$ + +Copyright (c) German Cancer Research Center, Division of Medical and +Biological Informatics. All rights reserved. +See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. + +This software is distributed WITHOUT ANY WARRANTY; without even +the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ + + +#ifndef BERRYPROVISIONINGINFO_H +#define BERRYPROVISIONINGINFO_H + +#include +#include +#include +#include + +namespace berry { + +class ProvisioningInfo +{ +public: + ProvisioningInfo(const QString& file); + + QStringList getPluginDirs() const; + QList getPluginsToInstall() const; + QList getPluginsToStart() const; + +private: + + enum Keyword { + UNKNOWN, + READ, + INSTALL, + START, + STOP + }; + + QSet pluginDirs; + QList pluginsToInstall; + QList pluginsToStart; + + static const QString intermediateOutDir; + + void readProvisioningFile(const QString& file); + QUrl addPluginToInstall(const QString& file); + void addPluginToStart(const QString& file); + + QString substituteKeywords(const QString& value) const; +}; + +} + +#endif // BERRYPROVISIONINGINFO_H diff --git a/BlueBerry/Bundles/org.blueberry.osgi/src/internal/berrySystemBundle.cpp b/BlueBerry/Bundles/org.blueberry.osgi/src/internal/berrySystemBundle.cpp index 7d4c3059d6..39cdcd9703 100644 --- a/BlueBerry/Bundles/org.blueberry.osgi/src/internal/berrySystemBundle.cpp +++ b/BlueBerry/Bundles/org.blueberry.osgi/src/internal/berrySystemBundle.cpp @@ -1,70 +1,77 @@ /*========================================================================= Program: BlueBerry Platform Language: C++ Date: $Date$ Version: $Revision$ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #include "berryLog.h" #include "berrySystemBundle.h" +#include "berrySystemBundleManifest.h" #include "Poco/Exception.h" #include "../berryBundleLoader.h" namespace berry { SystemBundle::SystemBundle(BundleLoader& loader, IBundleStorage::Pointer storage) - : Bundle(loader, storage) + : Bundle(loader, storage, false) { + this->init(); m_State = BUNDLE_RESOLVED; } void SystemBundle::Start() { } void SystemBundle::Resume() { m_State = BUNDLE_ACTIVE; // read the plugin.xml file from the resolved plugins try { m_BundleLoader.ReadAllContributions(); } catch (Poco::Exception exc) { BERRY_ERROR << exc.displayText() << std::endl; } // start all plugins with lazy-start: false try { m_BundleLoader.StartAllBundles(); } catch (Poco::Exception exc) { BERRY_ERROR << exc.displayText() << std::endl; } } BundleLoader& SystemBundle::GetBundleLoader() { return m_BundleLoader; } +void SystemBundle::LoadManifest() +{ + m_Manifest = new SystemBundleManifest(); +} + } diff --git a/BlueBerry/Bundles/org.blueberry.osgi/src/internal/berrySystemBundle.h b/BlueBerry/Bundles/org.blueberry.osgi/src/internal/berrySystemBundle.h index c1cac42844..1e21322adb 100644 --- a/BlueBerry/Bundles/org.blueberry.osgi/src/internal/berrySystemBundle.h +++ b/BlueBerry/Bundles/org.blueberry.osgi/src/internal/berrySystemBundle.h @@ -1,45 +1,49 @@ /*========================================================================= Program: BlueBerry Platform Language: C++ Date: $Date$ Version: $Revision$ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #ifndef BERRYSYSTEMBUNDLE_H_ #define BERRYSYSTEMBUNDLE_H_ #include "berryBundle.h" namespace berry { class BundleLoader; class SystemBundle : public Bundle { public: berryObjectMacro(SystemBundle) SystemBundle(BundleLoader& loader, IBundleStorage::Pointer storage); void Start(); void Resume(); BundleLoader& GetBundleLoader(); + +protected: + + void LoadManifest(); }; } #endif /*BERRYSYSTEMBUNDLE_H_*/ diff --git a/BlueBerry/Bundles/org.blueberry.osgi/src/internal/berrySystemBundleActivator.cpp b/BlueBerry/Bundles/org.blueberry.osgi/src/internal/berrySystemBundleActivator.cpp index 85d94cdcd7..026243dbc8 100644 --- a/BlueBerry/Bundles/org.blueberry.osgi/src/internal/berrySystemBundleActivator.cpp +++ b/BlueBerry/Bundles/org.blueberry.osgi/src/internal/berrySystemBundleActivator.cpp @@ -1,45 +1,41 @@ /*========================================================================= Program: BlueBerry Platform Language: C++ Date: $Date$ Version: $Revision$ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #include "berryLog.h" #include "berrySystemBundleActivator.h" #include "../berryIBundleContext.h" #include "../berryPlatform.h" #include "../service/berryServiceRegistry.h" #include "berrySystemBundle.h" #include "berryExtensionPointService.h" namespace berry { void SystemBundleActivator::Start(IBundleContext::Pointer context) { - SystemBundle::Pointer systemBundle = context->GetThisBundle().Cast(); - Service::Pointer service(new ExtensionPointService(&systemBundle->GetBundleLoader())); - Platform::GetServiceRegistry().RegisterService( - IExtensionPointService::SERVICE_ID, service); - //BERRY_INFO << "Extension point service registered\n"; + } void SystemBundleActivator::Stop(IBundleContext::Pointer /*context*/) { - Platform::GetServiceRegistry().UnRegisterService(IExtensionPointService::SERVICE_ID); + } } diff --git a/BlueBerry/Bundles/org.blueberry.osgi/src/internal/berrySystemBundleManifest.cpp b/BlueBerry/Bundles/org.blueberry.osgi/src/internal/berrySystemBundleManifest.cpp new file mode 100644 index 0000000000..fb7ec2ae4e --- /dev/null +++ b/BlueBerry/Bundles/org.blueberry.osgi/src/internal/berrySystemBundleManifest.cpp @@ -0,0 +1,92 @@ +/*========================================================================= + +Program: BlueBerry Platform +Language: C++ +Date: $Date$ +Version: $Revision$ + +Copyright (c) German Cancer Research Center, Division of Medical and +Biological Informatics. All rights reserved. +See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. + +This software is distributed WITHOUT ANY WARRANTY; without even +the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ + + +#include "berrySystemBundleManifest.h" + +#include "berryInternalPlatform.h" + +#include +#include + +namespace berry { + +SystemBundleManifest::SystemBundleManifest() +{ + ctkPluginContext* context = InternalPlatform::GetInstance()->GetCTKPluginFrameworkContext(); + manifestHeaders = context->getPlugin()->getHeaders(); + + activatorClass = "berry::SystemBundleActivator"; + activatorLib = ""; + copyright = manifestHeaders.value(ctkPluginConstants::PLUGIN_COPYRIGHT).toStdString(); + name = manifestHeaders.value(ctkPluginConstants::PLUGIN_NAME).toStdString(); + symbolicName = manifestHeaders.value(ctkPluginConstants::PLUGIN_SYMBOLICNAME).toStdString(); + vendor = manifestHeaders.value(ctkPluginConstants::PLUGIN_VENDOR).toStdString(); +} + +const std::string& SystemBundleManifest::GetActivatorClass() const +{ + return activatorClass; +} + +const std::string& SystemBundleManifest::GetActivatorLibrary() const +{ + return activatorLib; +} + +const std::string& SystemBundleManifest::GetCopyright() const +{ + return copyright; +} + +IBundleManifest::ActivationPolicy SystemBundleManifest::GetActivationPolicy() const +{ + QString policy = manifestHeaders.value(ctkPluginConstants::PLUGIN_ACTIVATIONPOLICY); + if (policy == ctkPluginConstants::ACTIVATION_EAGER) + { + return EAGER; + } + return LAZY; +} + +bool SystemBundleManifest::IsSystemBundle() const +{ + return true; +} + +const std::string& SystemBundleManifest::GetName() const +{ + return name; +} + +const IBundleManifest::Dependencies& SystemBundleManifest::GetRequiredBundles() const +{ + // The system bundle does not depend on other bundles + return dependencies; +} + +const std::string& SystemBundleManifest::GetSymbolicName() const +{ + return symbolicName; +} + +const std::string& SystemBundleManifest::GetVendor() const +{ + return vendor; +} + +} diff --git a/BlueBerry/Bundles/org.blueberry.osgi/src/internal/berrySystemBundleManifest.h b/BlueBerry/Bundles/org.blueberry.osgi/src/internal/berrySystemBundleManifest.h new file mode 100644 index 0000000000..0345c5dac6 --- /dev/null +++ b/BlueBerry/Bundles/org.blueberry.osgi/src/internal/berrySystemBundleManifest.h @@ -0,0 +1,58 @@ +/*========================================================================= + +Program: BlueBerry Platform +Language: C++ +Date: $Date$ +Version: $Revision$ + +Copyright (c) German Cancer Research Center, Division of Medical and +Biological Informatics. All rights reserved. +See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. + +This software is distributed WITHOUT ANY WARRANTY; without even +the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ + + +#ifndef BERRYSYSTEMBUNDLEMANIFEST_H +#define BERRYSYSTEMBUNDLEMANIFEST_H + +#include "../berryIBundleManifest.h" + +#include + +namespace berry { + +class SystemBundleManifest : public IBundleManifest +{ +public: + SystemBundleManifest(); + + virtual const std::string& GetActivatorClass() const; + virtual const std::string& GetActivatorLibrary() const; + virtual const std::string& GetCopyright() const; + virtual ActivationPolicy GetActivationPolicy() const; + virtual bool IsSystemBundle() const; + virtual const std::string& GetName() const; + virtual const Dependencies& GetRequiredBundles() const; + virtual const std::string& GetSymbolicName() const; + virtual const std::string& GetVendor() const; + +private: + + Dependencies dependencies; + QHash manifestHeaders; + + std::string activatorClass; + std::string activatorLib; + std::string copyright; + std::string name; + std::string symbolicName; + std::string vendor; +}; + +} + +#endif // BERRYSYSTEMBUNDLEMANIFEST_H diff --git a/BlueBerry/Bundles/org.blueberry.osgi/src/service/berryIConfigurationElement.h b/BlueBerry/Bundles/org.blueberry.osgi/src/service/berryIConfigurationElement.h index 4839297432..654e385b48 100644 --- a/BlueBerry/Bundles/org.blueberry.osgi/src/service/berryIConfigurationElement.h +++ b/BlueBerry/Bundles/org.blueberry.osgi/src/service/berryIConfigurationElement.h @@ -1,107 +1,156 @@ /*========================================================================= Program: BlueBerry Platform Language: C++ Date: $Date$ Version: $Revision$ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #ifndef BERRYIEXTENSIONELEMENT_H_ #define BERRYIEXTENSIONELEMENT_H_ #include "berryLog.h" -#include "../berryOSGiDll.h" +#include #include "../berryBundleLoader.h" #include "../berryPlatformException.h" #include "berryIExecutableExtension.h" +#include "berryIExtension.h" #include #include namespace berry { struct IExtension; struct BERRY_OSGI IConfigurationElement : public Object { berryObjectMacro(IConfigurationElement); public: typedef std::vector vector; template C* CreateExecutableExtension(const std::string& propertyName, const std::string& manifestName) { std::string className; if (this->GetAttribute(propertyName, className)) { try { C* cl = m_ClassLoader->LoadClass(m_Contributor, className, manifestName); // check if we have extension adapter and initialize if (dynamic_cast(cl) != 0) { // make the call even if the initialization string is null dynamic_cast(cl)->SetInitializationData(Pointer(this), propertyName, Object::Pointer(0)); } + if (cl == 0) + { + BERRY_WARN << "Could not load executable extension " << className << " from " << GetContributor(); + } + return cl; } catch (Poco::Exception& e) { BERRY_ERROR << "Error loading class: " << e.displayText() << std::endl; throw e; } } throw CoreException("Missing attribute", propertyName); } template C* CreateExecutableExtension(const std::string& propertyName) { - return CreateExecutableExtension(propertyName, C::GetManifestName()); + std::string className; + if (this->GetAttribute(propertyName, className)) + { + std::string contributor = this->GetContributor(); + QSharedPointer plugin = Platform::GetCTKPlugin(QString::fromStdString(contributor)); + if (!plugin.isNull()) + { + // immediately start the plugin but do not change the plugins autostart setting + plugin->start(ctkPlugin::START_TRANSIENT); + + QString typeName = plugin->getSymbolicName() + "_" + QString::fromStdString(className); + int metaTypeId = QMetaType::type(typeName.toAscii().data()); + if (metaTypeId == 0) + { + BERRY_WARN << "The class " << className << " was not registered as a Qt MetaType using BERRY_REGISTER_EXTENSION_CLASS(type, pluginContext) or you forgot to run Qt's moc on the header file. " + "Legacy BlueBerry bundles should use CreateExecutableExtension(propertyName, C::GetManifestName()) instead."; + } + else + { + QObject* obj = static_cast(QMetaType::construct(metaTypeId)); + // check if we have extension adapter and initialize + if (IExecutableExtension* execExt = qobject_cast(obj)) + { + // make the call even if the initialization string is null + execExt->SetInitializationData(Pointer(this), propertyName, Object::Pointer(0)); + } + + C* interface = qobject_cast(obj); + if (interface == 0) + { + BERRY_WARN << "The QObject subclass " << className << " does not seem to implement the required interface class, or you forgot the Q_INTERFACES macro."; + } + return interface; + } + } + else + { + BERRY_WARN << "Trying to create an executable extension (from " + << this->GetDeclaringExtension()->GetExtensionPointIdentifier() + << " in " << contributor << ") from a non-CTK plug-in. " + "Use the CreateExecutableExtension(propertyName, manifestName) method instead."; + } + } + return 0; } virtual bool GetAttribute(const std::string& name, std::string& value) const = 0; virtual bool GetBoolAttribute(const std::string& name, bool& value) const = 0; virtual const std::vector GetChildren() const = 0; virtual const std::vector GetChildren(const std::string& name) const = 0; virtual std::string GetValue() const = 0; virtual std::string GetName() const = 0; virtual const IConfigurationElement* GetParent() const = 0; virtual const std::string& GetContributor() const = 0; virtual const IExtension* GetDeclaringExtension() const = 0; virtual ~IConfigurationElement() {}; protected: BundleLoader* m_ClassLoader; std::string m_Contributor; }; } // namespace berry #endif /*BERRYIEXTENSIONELEMENT_H_*/ diff --git a/BlueBerry/Bundles/org.blueberry.osgi/src/service/berryIExecutableExtension.h b/BlueBerry/Bundles/org.blueberry.osgi/src/service/berryIExecutableExtension.h index 0c23be7664..81eb2fb411 100644 --- a/BlueBerry/Bundles/org.blueberry.osgi/src/service/berryIExecutableExtension.h +++ b/BlueBerry/Bundles/org.blueberry.osgi/src/service/berryIExecutableExtension.h @@ -1,124 +1,128 @@ #ifndef BERRYIEXECUTABLEEXTENSION_H_ #define BERRYIEXECUTABLEEXTENSION_H_ #include "../berryObject.h" #include "../berrySmartPointer.h" +#include + namespace berry { struct IConfigurationElement; /** * Interface for executable extension classes that require access to * their configuration element, or implement an extension adapter. *

* Extension adapters are typically required in cases where the extension * implementation does not follow the interface rules specified * by the provider of the extension point. In these * cases, the role of the adapter is to map between the extension point * interface, and the actual extension implementation. In general, adapters * are used when attempting to plug-in existing Java implementations, or * non-Java implementations (e.g., external executables). *

*

* Clients may implement this interface. *

* * @see IConfigurationElement#createExecutableExtension * @since 3.0 */ struct IExecutableExtension { /** * This method is called by the implementation of the method * IConfigurationElement.createExecutableExtension * on a newly constructed extension, passing it its relevant configuration * information. Most executable extensions only make use of the first * two call arguments. *

* Regular executable extensions specify their Java implementation * class name as an attribute of the configuration element for the * extension. For example *

    *     <action run="com.example.BaseAction"/>
    * 
* In the above example, this method would be called with a reference * to the <action> element (first argument), and * "run" as the name of the attribute that defined * this executable extension (second argument). *

*

* The last parameter is for the specific use of extension adapters * and is typically not used by regular executable extensions. *

*

* There are two supported ways of associating additional * adapter-specific data with the configuration in a way that * is transparent to the extension point implementor: *

*

* (1) by specifying adapter data as part of the implementation * class attribute value. The Java class name can be followed * by a ":" separator, followed by any adapter data in string * form. For example, if the extension point specifies an attribute * "run" to contain the name of the extension implementation, * an adapter can be configured as *

    *     <action run="com.example.ExternalAdapter:./cmds/util.exe -opt 3"/>
    * 
*

*

* (2) by converting the attribute used to specify the executable * extension to a child element of the original configuration element, * and specifying the adapter data in the form of xml markup. * Using this form, the example above would become *

    *     <action>
    *         <run class="com.xyz.ExternalAdapter">
    *             <parameter name="exec" value="./cmds/util.exe"/>
    *             <parameter name="opt"  value="3"/>
    *         </run>
    *     </action>
    * 
*

*

* Form (2) will typically only be * used for extension points that anticipate the majority of * extensions configured into it will in fact be in the form * of adapters. *

*

* In either case, the specified adapter class is instantiated using its * 0-argument public constructor. The adapter data is passed as the * last argument of this method. The data argument is defined as Object. * It can have the following values: *

    *
  • null, if no adapter data was supplied
  • *
  • in case (1), the initialization data * string is passed as a String
  • *
  • in case (2), the initialization data is passed * as a Hashtable containing the actual * parameter names and values (both Strings)
  • *
*

* * @param config the configuration element used to trigger this execution. * It can be queried by the executable extension for specific * configuration properties * @param propertyName the name of an attribute of the configuration element * used on the createExecutableExtension(String) call. This * argument can be used in the cases where a single configuration element * is used to define multiple executable extensions. * @param data adapter data in the form of a String, * a Hashtable, or null. * @exception CoreException if error(s) detected during initialization processing * @see IConfigurationElement#createExecutableExtension */ virtual void SetInitializationData(SmartPointer config, const std::string& propertyName, Object::Pointer data) = 0; virtual ~IExecutableExtension() {}; }; } +Q_DECLARE_INTERFACE(berry::IExecutableExtension, "org.blueberry.IExecutableExtension") + #endif /*BERRYIEXECUTABLEEXTENSION_H_*/ diff --git a/BlueBerry/Bundles/org.blueberry.osgi/src/service/berryIExtension.h b/BlueBerry/Bundles/org.blueberry.osgi/src/service/berryIExtension.h index 85218d8fb1..56a04f4b3d 100644 --- a/BlueBerry/Bundles/org.blueberry.osgi/src/service/berryIExtension.h +++ b/BlueBerry/Bundles/org.blueberry.osgi/src/service/berryIExtension.h @@ -1,102 +1,108 @@ /*========================================================================= Program: BlueBerry Platform Language: C++ Date: $Date$ Version: $Revision$ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #ifndef BERRYIEXTENSION_H_ #define BERRYIEXTENSION_H_ -#include "berryIConfigurationElement.h" +#include + +#include + +#include namespace berry { +struct IConfigurationElement; + /** * An extension declared in a host. * All information is obtained from the declaring host * extensions manifest file. *

* This interface is not intended to be implemented by clients. * */ struct BERRY_OSGI IExtension { /** * Returns all configuration elements declared by this extension. * These elements are a direct reflection of the configuration * markup supplied in the manifest file for the host that declares * this extension. * Returns an empty array if this extension does not declare any * configuration elements. * * @return the configuration elements declared by this extension */ - virtual const std::vector GetConfigurationElements() const = 0; + virtual const std::vector > GetConfigurationElements() const = 0; virtual std::string GetNamespace() const = 0; /** * Returns the unique identifier of the extension point * that this extension gets plugged into. * * @return the unique identifier of the relevant extension point */ virtual std::string GetExtensionPointIdentifier() const = 0; /** * Returns the simple identifier of this extension, or null * if this extension does not have an identifier. * This identifier is specified in the extensions manifest * file as a non-empty string containing no period characters * ('.') and must be unique within the defining host. * * @return the simple identifier of the extension (e.g. "main") * or null */ virtual std::string GetSimpleIdentifier() const = 0; /** * Returns the unique identifier of this extension, or null * if this extension does not have an identifier. * If available, this identifier is unique within the extension registry, and * is composed of the identifier of the host that declared * this extension and this extension's simple identifier. * * @return the unique identifier of the extension * (e.g. "com.example.acme.main"), or null */ virtual std::string GetUniqueIdentifier() const = 0; /** * Returns a displayable label for this extension. * Returns the empty string if no label for this extension * is specified in the extension manifest file. *

Note that any translation specified in the extension manifest * file is automatically applied. *

* * @return a displayable string label for this extension, * possibly the empty string */ virtual std::string GetLabel() const = 0; virtual bool operator<(const IExtension* e2) const = 0; virtual ~IExtension() {} }; } #endif /*BERRYIEXTENSION_H_*/ diff --git a/BlueBerry/Bundles/org.blueberry.osgi/src/service/berryIExtensionPoint.h b/BlueBerry/Bundles/org.blueberry.osgi/src/service/berryIExtensionPoint.h index 1bed444f64..ff0bbd9c1e 100644 --- a/BlueBerry/Bundles/org.blueberry.osgi/src/service/berryIExtensionPoint.h +++ b/BlueBerry/Bundles/org.blueberry.osgi/src/service/berryIExtensionPoint.h @@ -1,147 +1,148 @@ /*========================================================================= Program: BlueBerry Platform Language: C++ Date: $Date$ Version: $Revision$ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #ifndef BERRYIEXTENSIONPOINT_H_ #define BERRYIEXTENSIONPOINT_H_ -#include "../berryOSGiDll.h" +#include #include "berryIExtension.h" +#include "berryIConfigurationElement.h" #include namespace berry { struct IBundle; /** * An extension point declared in a plug-in. * Except for the list of extensions plugged in to it, the information * available for an extension point is obtained from the declaring plug-in's * manifest (plugin.xml) file. *

* These registry objects are intended for relatively short-term use. Clients that * deal with these objects must be aware that they may become invalid if the * declaring plug-in is updated or uninstalled. If this happens, all methods except * {@link #isValid()} will throw {@link InvalidRegistryObjectException}. * For extension point objects, the most common case is code in a plug-in dealing * with one of the extension points it declares. These extension point objects are * guaranteed to be valid while the plug-in is active. Code in a plug-in that has * declared that it is not dynamic aware (or not declared anything) can also safely * ignore this issue, since the registry would not be modified while it is * active. However, code in a plug-in that declares that it is dynamic aware * must be careful if it access the extension point object of a different plug-in, * because it's at risk if that other plug-in is removed. Similarly, * tools that analyze or display the extension registry are vulnerable. * Client code can pre-test for invalid objects by calling {@link #isValid()}, * which never throws this exception. However, pre-tests are usually not sufficient * because of the possibility of the extension point object becoming invalid as a * result of a concurrent activity. At-risk clients must treat * InvalidRegistryObjectException as if it were a checked exception. * Also, such clients should probably register a listener with the extension registry * so that they receive notification of any changes to the registry. *

*

* This interface is not intended to be implemented by clients. *

*/ struct BERRY_OSGI IExtensionPoint { public: virtual ~IExtensionPoint() {}; virtual std::string GetContributor() const = 0; /** * Returns all configuration elements from all extensions configured * into this extension point. Returns an empty array if this extension * point has no extensions configured, or none of the extensions * contain configuration elements. * * @return the configuration elements for all extension configured * into this extension point * @throws InvalidRegistryObjectException if this extension point is no longer valid */ virtual const std::vector GetConfigurationElements() const = 0; /** * Returns the extension with the given unique identifier configured into * this extension point, or null if there is no such extension. * Since an extension might not have an identifier, some extensions * can only be found via the getExtensions method. * * @param extensionId the unique identifier of an extension * (e.g. "com.example.acme.main"). * @return an extension, or null * @throws InvalidRegistryObjectException if this extension point is no longer valid */ virtual const IExtension* GetExtension(const std::string& extensionId) const = 0; /** * Returns all extensions configured into this extension point. * Returns an empty array if this extension point has no extensions. * * @return the extensions configured into this extension point * @throws InvalidRegistryObjectException if this extension point is no longer valid */ virtual const std::vector GetExtensions() const = 0; /** * Returns a displayable label for this extension point. * Returns the empty string if no label for this extension point * is specified in the plug-in manifest file. *

Note that any translation specified in the plug-in manifest * file is automatically applied. *

* * @return a displayable string label for this extension point, * possibly the empty string * @throws InvalidRegistryObjectException if this extension point is no longer valid */ virtual std::string GetLabel() const = 0; /** * Returns the simple identifier of this extension point. * This identifier is a non-empty string containing no * period characters ('.') and is guaranteed * to be unique within the defining plug-in. * * @return the simple identifier of the extension point (e.g. "builders") * @throws InvalidRegistryObjectException if this extension point is no longer valid */ virtual std::string GetSimpleIdentifier() const = 0; /** * Returns the unique identifier of this extension point. * This identifier is unique within the plug-in registry, and * is composed of the namespace for this extension point * and this extension point's simple identifier. * * * @return the unique identifier of the extension point * (e.g. "org.blueberry.core.resources.builders") * @throws InvalidRegistryObjectException if this extension point is no longer valid */ virtual std::string GetUniqueIdentifier() const = 0; }; } #endif /*BERRYIEXTENSIONPOINT_H_*/ diff --git a/BlueBerry/Bundles/org.blueberry.osgi/src/service/berryIExtensionPointService.h b/BlueBerry/Bundles/org.blueberry.osgi/src/service/berryIExtensionPointService.h index 10ff452db5..7925dfe1ca 100644 --- a/BlueBerry/Bundles/org.blueberry.osgi/src/service/berryIExtensionPointService.h +++ b/BlueBerry/Bundles/org.blueberry.osgi/src/service/berryIExtensionPointService.h @@ -1,59 +1,62 @@ /*========================================================================= Program: BlueBerry Platform Language: C++ Date: $Date$ Version: $Revision$ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #ifndef BERRYIEXTENSIONPOINTSERVICE_H_ #define BERRYIEXTENSIONPOINTSERVICE_H_ -#include "../berryOSGiDll.h" +#include #include "berryService.h" #include "berryIExtensionPoint.h" #include "berryIConfigurationElement.h" +#include namespace berry { struct IBundle; struct BERRY_OSGI IExtensionPointService : public Service { - berryObjectMacro(IExtensionPointService); + berryInterfaceMacro(IExtensionPointService, berry); public: static std::string SERVICE_ID; virtual ~IExtensionPointService() {} virtual void AddContribution(std::istream& istr, const std::string& contributor) = 0; virtual const std::vector GetConfigurationElementsFor(const std::string& extensionPointId) const = 0; virtual const IExtension* GetExtension(const std::string& extensionPointId, const std::string& extensionId) const = 0; virtual const IExtensionPoint* GetExtensionPoint(const std::string& extensionPointId) const = 0; virtual const std::vector GetExtensions(const std::string& contributor) const = 0; virtual const std::vector GetExtensionPoints() const = 0; virtual const std::vector GetExtensionPoints(const std::string& contributor) const = 0; virtual bool HasContributionFrom(const std::string& name) const = 0; }; } // namespace berry +Q_DECLARE_INTERFACE(berry::IExtensionPointService, "org.blueberry.service.IExtensionPoint") + #endif /*BERRYIEXTENSIONPOINTSERVICE_H_*/ diff --git a/BlueBerry/Bundles/org.blueberry.osgi/src/service/berryService.h b/BlueBerry/Bundles/org.blueberry.osgi/src/service/berryService.h index 4db8efb791..be73d0b181 100644 --- a/BlueBerry/Bundles/org.blueberry.osgi/src/service/berryService.h +++ b/BlueBerry/Bundles/org.blueberry.osgi/src/service/berryService.h @@ -1,44 +1,44 @@ /*========================================================================= Program: BlueBerry Platform Language: C++ Date: $Date$ Version: $Revision$ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #ifndef BERRYSERVICE_H_ #define BERRYSERVICE_H_ -#include "../berryOSGiDll.h" +#include #include "../berryMacros.h" #include "../berryObject.h" #include namespace berry { class BERRY_OSGI Service : public Object { public: berryObjectMacro(Service); virtual ~Service(); virtual bool IsA(const std::type_info& type) const; virtual const std::type_info& GetType() const; }; } // namespace berry #endif /*BERRYSERVICE_H_*/ diff --git a/BlueBerry/Bundles/org.blueberry.osgi/src/service/berryServiceRegistry.h b/BlueBerry/Bundles/org.blueberry.osgi/src/service/berryServiceRegistry.h index be77bc878e..016ccb6d4b 100644 --- a/BlueBerry/Bundles/org.blueberry.osgi/src/service/berryServiceRegistry.h +++ b/BlueBerry/Bundles/org.blueberry.osgi/src/service/berryServiceRegistry.h @@ -1,55 +1,55 @@ /*========================================================================= Program: BlueBerry Platform Language: C++ Date: $Date$ Version: $Revision$ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #ifndef BERRYSERVICEREGISTRY_H_ #define BERRYSERVICEREGISTRY_H_ -#include "../berryOSGiDll.h" +#include #include "berryService.h" #include "Poco/Mutex.h" #include #include namespace berry { class BERRY_OSGI ServiceRegistry { private: std::map m_ServiceMap; mutable Poco::Mutex m_Mutex; public: virtual ~ServiceRegistry(); template typename S::Pointer GetServiceById(const std::string& id); void RegisterService(const std::string& id, Service::Pointer service); void UnRegisterService(const std::string& id); void UnRegisterService(Service::ConstPointer service); }; } // namespace berry #include "berryServiceRegistry.txx" #endif /*BERRYSERVICEREGISTRY_H_*/ diff --git a/BlueBerry/Bundles/org.blueberry.osgi/src/service/berryServiceRegistry.txx b/BlueBerry/Bundles/org.blueberry.osgi/src/service/berryServiceRegistry.txx index 18aa644e82..0013b4ca8c 100644 --- a/BlueBerry/Bundles/org.blueberry.osgi/src/service/berryServiceRegistry.txx +++ b/BlueBerry/Bundles/org.blueberry.osgi/src/service/berryServiceRegistry.txx @@ -1,49 +1,76 @@ /*========================================================================= Program: BlueBerry Platform Language: C++ Date: $Date$ Version: $Revision$ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #ifndef __BERRY_SERVICE_REGISTRY_TXX__ #define __BERRY_SERVICE_REGISTRY_TXX__ +#include "../internal/berryCTKPluginActivator.h" +#include "../berryLog.h" + +#include + namespace berry { template typename S::Pointer ServiceRegistry::GetServiceById(const std::string& id) { Poco::Mutex::ScopedLock lock(m_Mutex); Service::Pointer servicePtr; std::map::const_iterator serviceIt = m_ServiceMap.find(id); if (serviceIt != m_ServiceMap.end()) { servicePtr = serviceIt->second; } - if (servicePtr.IsNull()) return SmartPointer(); + if (servicePtr.IsNull()) + { + // Try to get the service from the CTK Service Registry + ctkPluginContext* context = CTKPluginActivator::getPluginContext(); + try + { + ctkServiceReference serviceRef = context->getServiceReference(); + S* service = context->getService(serviceRef); + if (!service) + { + return SmartPointer(); + } + //BERRY_WARN << "Getting a CTK Service object through the BlueBerry service registry.\n" + // "You should use a ctkPluginContext or ctkServiceTracker instance instead!"; + return typename S::Pointer(service); + } + catch (const ctkServiceException& exc) + { + BERRY_INFO << exc.what(); + } + + return SmartPointer(); + } if (servicePtr->IsA(typeid(S))) { SmartPointer castService = servicePtr.Cast(); return castService; } else throw Poco::BadCastException("The service could not be cast to: ", typeid(S).name()); } } // namespace berry #endif // __BERRY_SERVICE_REGISTRY_TXX__ diff --git a/BlueBerry/Bundles/org.blueberry.osgi/target_libraries.cmake b/BlueBerry/Bundles/org.blueberry.osgi/target_libraries.cmake new file mode 100644 index 0000000000..a5987ba09b --- /dev/null +++ b/BlueBerry/Bundles/org.blueberry.osgi/target_libraries.cmake @@ -0,0 +1,9 @@ +# See CMake/ctkFunctionGetTargetLibraries.cmake +# +# This file should list the libraries required to build the current CTK plugin. +# For specifying required plugins, see the manifest_headers.cmake file. +# + +SET(target_libraries + CTKPluginFramework +) diff --git a/BlueBerry/Bundles/org.blueberry.solstice.common/CMakeLists.txt b/BlueBerry/Bundles/org.blueberry.solstice.common/CMakeLists.txt index d96fc34537..137cfc97ae 100644 --- a/BlueBerry/Bundles/org.blueberry.solstice.common/CMakeLists.txt +++ b/BlueBerry/Bundles/org.blueberry.solstice.common/CMakeLists.txt @@ -1,2 +1,4 @@ +PROJECT(org_blueberry_solstice_common) -MACRO_CREATE_PLUGIN() +MACRO_CREATE_CTK_PLUGIN(EXPORT_DIRECTIVE BERRY_COMMON_RUNTIME + EXPORTED_INCLUDE_SUFFIXES src) diff --git a/BlueBerry/Bundles/org.blueberry.solstice.common/META-INF/MANIFEST.MF b/BlueBerry/Bundles/org.blueberry.solstice.common/META-INF/MANIFEST.MF deleted file mode 100644 index 77130b2d3e..0000000000 --- a/BlueBerry/Bundles/org.blueberry.solstice.common/META-INF/MANIFEST.MF +++ /dev/null @@ -1,7 +0,0 @@ -Manifest-Version: 1.0 -Bundle-Name: Common BlueBerry Runtime -Bundle-SymbolicName: org.blueberry.solstice.common -Bundle-Version: 1.0.0 -Bundle-Vendor: DKFZ, Medical and Biological Informatics -Require-Bundle: org.blueberry.osgi -Bundle-ActivationPolicy: lazy \ No newline at end of file diff --git a/BlueBerry/Bundles/org.blueberry.solstice.common/files.cmake b/BlueBerry/Bundles/org.blueberry.solstice.common/files.cmake index a55c9d40cd..e70cef7384 100644 --- a/BlueBerry/Bundles/org.blueberry.solstice.common/files.cmake +++ b/BlueBerry/Bundles/org.blueberry.solstice.common/files.cmake @@ -1,20 +1,25 @@ +SET(MOC_H_FILES + src/internal/berryPluginActivator.h +) + SET(SRC_CPP_FILES berryMultiStatus.cpp berrySafeRunner.cpp berrySolsticeExceptions.cpp berryStatus.cpp ) SET(INTERNAL_CPP_FILES berryIRuntimeConstants.cpp + berryPluginActivator.cpp ) #SET(CPP_FILES manifest.cpp) foreach(file ${SRC_CPP_FILES}) SET(CPP_FILES ${CPP_FILES} src/${file}) endforeach(file ${SRC_CPP_FILES}) foreach(file ${INTERNAL_CPP_FILES}) SET(CPP_FILES ${CPP_FILES} src/internal/${file}) endforeach(file ${INTERNAL_CPP_FILES}) diff --git a/BlueBerry/Bundles/org.blueberry.solstice.common/manifest_headers.cmake b/BlueBerry/Bundles/org.blueberry.solstice.common/manifest_headers.cmake new file mode 100644 index 0000000000..2ecbbe7e32 --- /dev/null +++ b/BlueBerry/Bundles/org.blueberry.solstice.common/manifest_headers.cmake @@ -0,0 +1,6 @@ +set(Plugin-Name "Common BlueBerry Runtime") +set(Plugin-Version "1.0.0") +set(Plugin-Vendor "DKFZ, Medical and Biological Informatics") +set(Plugin-ContactAddress "http://www.mitk.org") +set(Require-Plugin "org.blueberry.osgi") + diff --git a/BlueBerry/Bundles/org.blueberry.solstice.common/src/berryCommonRuntimeDll.h b/BlueBerry/Bundles/org.blueberry.solstice.common/src/berryCommonRuntimeDll.h deleted file mode 100644 index c978243156..0000000000 --- a/BlueBerry/Bundles/org.blueberry.solstice.common/src/berryCommonRuntimeDll.h +++ /dev/null @@ -1,43 +0,0 @@ -/*========================================================================= - - Program: BlueBerry Platform - Language: C++ - Date: $Date$ - Version: $Revision$ - - Copyright (c) German Cancer Research Center, Division of Medical and - Biological Informatics. All rights reserved. - See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. - - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - PURPOSE. See the above copyright notices for more information. - - =========================================================================*/ - - -#ifndef BERRYCOMMONRUNTIMEDLL_H_ -#define BERRYCOMMONRUNTIMEDLL_H_ - -// -// The following block is the standard way of creating macros which make exporting -// from a DLL simpler. All files within this DLL are compiled with the org_blueberry_solstice_common_EXPORTS -// symbol defined on the command line. this symbol should not be defined on any project -// that uses this DLL. This way any other project whose source files include this file see -// org_blueberry_solstice_common_EXPORTS functions as being imported from a DLL, wheras this DLL sees symbols -// defined with this macro as being exported. -// -#if defined(_WIN32) && !defined(BERRY_STATIC) - #if defined(org_blueberry_solstice_common_EXPORTS) - #define BERRY_COMMON_RUNTIME __declspec(dllexport) - #else - #define BERRY_COMMON_RUNTIME __declspec(dllimport) - #endif -#endif - - -#if !defined(BERRY_COMMON_RUNTIME) - #define BERRY_COMMON_RUNTIME -#endif - -#endif /* BERRYCOMMONRUNTIMEDLL_H_ */ diff --git a/BlueBerry/Bundles/org.blueberry.solstice.common/src/berryISafeRunnable.h b/BlueBerry/Bundles/org.blueberry.solstice.common/src/berryISafeRunnable.h index 887347a887..b076ca0ec7 100644 --- a/BlueBerry/Bundles/org.blueberry.solstice.common/src/berryISafeRunnable.h +++ b/BlueBerry/Bundles/org.blueberry.solstice.common/src/berryISafeRunnable.h @@ -1,103 +1,103 @@ /*========================================================================= Program: BlueBerry Platform Language: C++ Date: $Date$ Version: $Revision$ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #ifndef BERRYISAFERUNNABLE_H_ #define BERRYISAFERUNNABLE_H_ #include #include -#include "berryCommonRuntimeDll.h" +#include namespace berry { /** * Safe runnables represent blocks of code and associated exception * handlers. They are typically used when a plug-in needs to call some * untrusted code (e.g., code contributed by another plug-in via an * extension). *

* This interface can be used without OSGi running. *

* Clients may implement this interface. *

* @see SafeRunner#run(ISafeRunnable) */ struct BERRY_COMMON_RUNTIME ISafeRunnable: public Object { berryInterfaceMacro(ISafeRunnable, berry) /** * Handles an exception thrown by this runnable's run * method. The processing done here should be specific to the * particular usecase for this runnable. Generalized exception * processing (e.g., logging in the platform's log) is done by the * Platform's run mechanism. * * @param exception an exception which occurred during processing * the body of this runnable (i.e., in run()) * @see SafeRunner#run(ISafeRunnable) */ virtual void HandleException(const std::exception& exception) = 0; /** * Runs this runnable. Any exceptions thrown from this method will * be passed to this runnable's handleException * method. * * @exception Exception if a problem occurred while running this method. * The exception will be processed by handleException * @see SafeRunner#run(ISafeRunnable) */ virtual void Run() = 0; }; template struct SafeRunnableDelegate: public ISafeRunnable { typedef void(R::*RunCallback)(); typedef void(R::*HandleExcCallback)(const std::exception&); SafeRunnableDelegate(R* runnable, RunCallback func, HandleExcCallback handleFunc = 0) : m_Runnable(runnable), m_RunFunc(func), m_HandleExcFunc(handleFunc) { } void Run() { m_Runnable->*m_RunFunc(); } void HandleException(const std::exception& exception) { if (m_HandleExcFunc) m_Runnable->*m_HandleExcFunc(exception); } private: R* m_Runnable; RunCallback m_RunFunc; HandleExcCallback m_HandleExcFunc; }; } #endif /* BERRYISAFERUNNABLE_H_ */ diff --git a/BlueBerry/Bundles/org.blueberry.solstice.common/src/berryIStatus.h b/BlueBerry/Bundles/org.blueberry.solstice.common/src/berryIStatus.h index 1397158df7..f1b360c468 100644 --- a/BlueBerry/Bundles/org.blueberry.solstice.common/src/berryIStatus.h +++ b/BlueBerry/Bundles/org.blueberry.solstice.common/src/berryIStatus.h @@ -1,202 +1,202 @@ /*========================================================================= Program: BlueBerry Platform Language: C++ Date: $Date$ Version: $Revision$ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #ifndef BERRYISTATUS_H_ #define BERRYISTATUS_H_ #include #include #include -#include "berryCommonRuntimeDll.h" +#include namespace berry { /** * A status object represents the outcome of an operation. * All CoreExceptions carry a status object to indicate * what went wrong. Status objects are also returned by methods needing * to provide details of failures (e.g., validation methods). *

* A status carries the following information: *

    *
  • plug-in identifier (required)
  • *
  • severity (required)
  • *
  • status code (required)
  • *
  • message (required) - localized to current locale
  • *
  • exception (optional) - for problems stemming from a failure at * a lower level
  • *
* Some status objects, known as multi-statuses, have other status objects * as children. *

*

* The class Status is the standard public implementation * of status objects; the subclass MultiStatus is the * implements multi-status objects. *

* This interface can be used without OSGi running. *

* @see MultiStatus * @see Status */ struct BERRY_COMMON_RUNTIME IStatus: public Object { berryInterfaceMacro(IStatus, berry) enum Severity { /** Status severity constant (value 0) indicating this status represents the nominal case. * This constant is also used as the status code representing the nominal case. */ OK_TYPE = 0x00, /** Status type severity (bit mask, value 1) indicating this status is informational only. */ INFO_TYPE = 0x01, /** Status type severity (bit mask, value 2) indicating this status represents a warning. */ WARNING_TYPE = 0x02, /** Status type severity (bit mask, value 4) indicating this status represents an error. */ ERROR_TYPE = 0x04, /** Status type severity (bit mask, value 8) indicating this status represents a cancelation. */ CANCEL_TYPE = 0x08 }; BERRY_DECLARE_FLAGS(Severities, Severity) /** * Returns a list of status object immediately contained in this * multi-status, or an empty list if this is not a multi-status. * * @return an array of status objects * @see #isMultiStatus() */ virtual std::vector GetChildren() const = 0; /** * Returns the plug-in-specific status code describing the outcome. * * @return plug-in-specific status code */ virtual int GetCode() const = 0; /** * Returns the relevant low-level exception, or null if none. * For example, when an operation fails because of a network communications * failure, this might return the java.io.IOException * describing the exact nature of that failure. * * @return the relevant low-level exception, or null if none */ virtual std::exception GetException() const = 0; /** * Returns the message describing the outcome. * The message is localized to the current locale. * * @return a localized message */ virtual std::string GetMessage() const = 0; /** * Returns the unique identifier of the plug-in associated with this status * (this is the plug-in that defines the meaning of the status code). * * @return the unique identifier of the relevant plug-in */ virtual std::string GetPlugin() const = 0; /** * Returns the severity. The severities are as follows (in * descending order): *
    *
  • CANCEL_TYPE - cancelation occurred
  • *
  • ERROR_TYPE - a serious error (most severe)
  • *
  • WARNING_TYPE - a warning (less severe)
  • *
  • INFO_TYPE - an informational ("fyi") message (least severe)
  • *
  • OK_TYPE - everything is just fine
  • *
*

* The severity of a multi-status is defined to be the maximum * severity of any of its children, or OK if it has * no children. *

* * @return the severity: one of OK_TYPE, ERROR_TYPE, * INFO_TYPE, WARNING_TYPE, or CANCEL_TYPE * @see #matches(int) */ virtual Severity GetSeverity() const = 0; /** * Returns whether this status is a multi-status. * A multi-status describes the outcome of an operation * involving multiple operands. *

* The severity of a multi-status is derived from the severities * of its children; a multi-status with no children is * OK_TYPE by definition. * A multi-status carries a plug-in identifier, a status code, * a message, and an optional exception. Clients may treat * multi-status objects in a multi-status unaware way. *

* * @return true for a multi-status, * false otherwise * @see #getChildren() */ virtual bool IsMultiStatus() const = 0; /** * Returns whether this status indicates everything is okay * (neither info, warning, nor error). * * @return true if this status has severity * OK, and false otherwise */ virtual bool IsOK() const = 0; /** * Returns whether the severity of this status matches the given * severity mask. Note that a status with severity OK_TYPE * will never match; use isOK instead to detect * a status with a severity of OK. * * @param severityMask a mask formed by bitwise or'ing severity mask * constants (ERROR_TYPE, WARNING_TYPE, * INFO_TYPE, CANCEL_TYPE) * @return true if there is at least one match, * false if there are no matches * @see #getSeverity() * @see #CANCEL_TYPE * @see #ERROR_TYPE * @see #WARNING_TYPE * @see #INFO_TYPE */ virtual bool Matches(const Severities& severityMask) const = 0; }; } BERRY_DECLARE_OPERATORS_FOR_FLAGS(berry::IStatus::Severities) #endif /* BERRYISTATUS_H_ */ diff --git a/BlueBerry/Bundles/org.blueberry.solstice.common/src/berryMultiStatus.h b/BlueBerry/Bundles/org.blueberry.solstice.common/src/berryMultiStatus.h index a8f7497e3e..2a896f1a41 100644 --- a/BlueBerry/Bundles/org.blueberry.solstice.common/src/berryMultiStatus.h +++ b/BlueBerry/Bundles/org.blueberry.solstice.common/src/berryMultiStatus.h @@ -1,120 +1,120 @@ /*========================================================================= Program: BlueBerry Platform Language: C++ Date: $Date$ Version: $Revision$ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #ifndef BERRYMULTISTATUS_H_ #define BERRYMULTISTATUS_H_ #include "berryStatus.h" -#include "berryCommonRuntimeDll.h" +#include namespace berry { /** * A concrete multi-status implementation, * suitable either for instantiating or subclassing. *

* This class can be used without OSGi running. *

*/ class BERRY_COMMON_RUNTIME MultiStatus : public Status { private: /** List of child statuses. */ std::vector children; public: /** * Creates and returns a new multi-status object with the given children. * * @param pluginId the unique identifier of the relevant plug-in * @param code the plug-in-specific status code * @param newChildren the list of children status objects * @param message a human-readable message, localized to the * current locale * @param exception a low-level exception, or null if not * applicable */ MultiStatus(const std::string& pluginId, int code, const std::vector& newChildren, const std::string& message, const std::exception& exception = std::exception()); /** * Creates and returns a new multi-status object with no children. * * @param pluginId the unique identifier of the relevant plug-in * @param code the plug-in-specific status code * @param message a human-readable message, localized to the * current locale * @param exception a low-level exception, or null if not * applicable */ MultiStatus(const std::string& pluginId, int code, const std::string& message, const std::exception& exception = std::exception()); /** * Adds the given status to this multi-status. * * @param status the new child status */ void Add(IStatus::Pointer status); /** * Adds all of the children of the given status to this multi-status. * Does nothing if the given status has no children (which includes * the case where it is not a multi-status). * * @param status the status whose children are to be added to this one */ void AddAll(IStatus::Pointer status); /* (Intentionally not javadoc'd) * Implements the corresponding method on IStatus. */ std::vector GetChildren() const; /* (Intentionally not javadoc'd) * Implements the corresponding method on IStatus. */ bool IsMultiStatus() const; /** * Merges the given status into this multi-status. * Equivalent to add(status) if the * given status is not a multi-status. * Equivalent to addAll(status) if the * given status is a multi-status. * * @param status the status to merge into this one * @see #add(IStatus) * @see #addAll(IStatus) */ void Merge(IStatus::Pointer status); /** * Returns a string representation of the status, suitable * for debugging purposes only. */ std::string ToString() const; }; } #endif /* BERRYMULTISTATUS_H_ */ diff --git a/BlueBerry/Bundles/org.blueberry.solstice.common/src/berrySafeRunner.h b/BlueBerry/Bundles/org.blueberry.solstice.common/src/berrySafeRunner.h index 85236a318c..9cdfce7b34 100644 --- a/BlueBerry/Bundles/org.blueberry.solstice.common/src/berrySafeRunner.h +++ b/BlueBerry/Bundles/org.blueberry.solstice.common/src/berrySafeRunner.h @@ -1,57 +1,57 @@ /*========================================================================= Program: BlueBerry Platform Language: C++ Date: $Date$ Version: $Revision$ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #ifndef BERRYSAFERUNNER_H_ #define BERRYSAFERUNNER_H_ -#include "berryCommonRuntimeDll.h" +#include #include "berryISafeRunnable.h" namespace berry { /** * Runs the given ISafeRunnable in a protected mode: exceptions * thrown in the runnable are logged and passed to the runnable's * exception handler. Such exceptions are not rethrown by this method. *

* This class can be used without OSGi running. *

*/ class BERRY_COMMON_RUNTIME SafeRunner { public: /** * Runs the given runnable in a protected mode. Exceptions * thrown in the runnable are logged and passed to the runnable's * exception handler. Such exceptions are not rethrown by this method. * * @param code the runnable to run */ static void Run(ISafeRunnable::Pointer code); private: static void HandleException(ISafeRunnable::Pointer code, const std::exception& e = std::exception()); }; } #endif /* BERRYSAFERUNNER_H_ */ diff --git a/BlueBerry/Bundles/org.blueberry.solstice.common/src/berrySolsticeExceptions.h b/BlueBerry/Bundles/org.blueberry.solstice.common/src/berrySolsticeExceptions.h index 86f084ee6b..750c9f6c4d 100644 --- a/BlueBerry/Bundles/org.blueberry.solstice.common/src/berrySolsticeExceptions.h +++ b/BlueBerry/Bundles/org.blueberry.solstice.common/src/berrySolsticeExceptions.h @@ -1,41 +1,41 @@ /*========================================================================= Program: BlueBerry Platform Language: C++ Date: $Date$ Version: $Revision$ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #ifndef BERRYSOLSTICEEXCEPTIONS_H_ #define BERRYSOLSTICEEXCEPTIONS_H_ -#include "berryCommonRuntimeDll.h" +#include #include namespace berry { /** * This exception is thrown to blow out of a long-running method * when the user cancels it. *

* This class can be used without OSGi running. *

* This class is not intended to be subclassed by clients but * may be instantiated. *

*/ POCO_DECLARE_EXCEPTION(BERRY_COMMON_RUNTIME, OperationCanceledException, Poco::RuntimeException); } #endif /* BERRYSOLSTICEEXCEPTIONS_H_ */ diff --git a/BlueBerry/Bundles/org.blueberry.solstice.common/src/berryStatus.h b/BlueBerry/Bundles/org.blueberry.solstice.common/src/berryStatus.h index 5ddad5aa84..b95e687c04 100644 --- a/BlueBerry/Bundles/org.blueberry.solstice.common/src/berryStatus.h +++ b/BlueBerry/Bundles/org.blueberry.solstice.common/src/berryStatus.h @@ -1,217 +1,217 @@ /*========================================================================= Program: BlueBerry Platform Language: C++ Date: $Date$ Version: $Revision$ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #ifndef BERRYSTATUS_H_ #define BERRYSTATUS_H_ #include "berryIStatus.h" -#include "berryCommonRuntimeDll.h" +#include namespace berry { /** * A concrete status implementation, suitable either for * instantiating or subclassing. *

* This class can be used without OSGi running. *

*/ class BERRY_COMMON_RUNTIME Status : public IStatus { private: /** * The severity. One of *
    *
  • CANCEL
  • *
  • ERROR
  • *
  • WARNING
  • *
  • INFO
  • *
  • or OK (0)
  • *
*/ Severity severity; /** Unique identifier of plug-in. */ std::string pluginId; /** Plug-in-specific status code. */ int code; /** Message, localized to the current locale. */ std::string message; /** Wrapped exception, or null if none. */ std::exception exception; /** Constant to avoid generating garbage. */ static const std::vector theEmptyStatusArray; public: /** * A standard OK status with an "ok" message. * * @since 3.0 */ static const IStatus::Pointer OK_STATUS; /** * A standard CANCEL status with no message. * * @since 3.0 */ static const IStatus::Pointer CANCEL_STATUS; /** * Creates a new status object. The created status has no children. * * @param severity the severity; one of OK, ERROR, * INFO, WARNING, or CANCEL * @param pluginId the unique identifier of the relevant plug-in * @param code the plug-in-specific status code, or OK * @param message a human-readable message, localized to the * current locale * @param exception a low-level exception, or null if not * applicable */ Status(const Severity& severity, const std::string& pluginId, int code, const std::string& message, const std::exception& exception = std::exception()); /** * Simplified constructor of a new status object; assumes that code is OK. * The created status has no children. * * @param severity the severity; one of OK, ERROR, * INFO, WARNING, or CANCEL * @param pluginId the unique identifier of the relevant plug-in * @param message a human-readable message, localized to the * current locale * @param exception a low-level exception, or null if not * applicable * * @since org.eclipse.equinox.common 3.3 */ Status(const Severity& severity, const std::string& pluginId, const std::string& message, const std::exception& exception = std::exception()); /* (Intentionally not javadoc'd) * Implements the corresponding method on IStatus. */ std::vector GetChildren() const; /* (Intentionally not javadoc'd) * Implements the corresponding method on IStatus. */ int GetCode() const; /* (Intentionally not javadoc'd) * Implements the corresponding method on IStatus. */ std::exception GetException() const; /* (Intentionally not javadoc'd) * Implements the corresponding method on IStatus. */ std::string GetMessage() const; /* (Intentionally not javadoc'd) * Implements the corresponding method on IStatus. */ std::string GetPlugin() const; /* (Intentionally not javadoc'd) * Implements the corresponding method on IStatus. */ Severity GetSeverity() const; /* (Intentionally not javadoc'd) * Implements the corresponding method on IStatus. */ bool IsMultiStatus() const; /* (Intentionally not javadoc'd) * Implements the corresponding method on IStatus. */ bool IsOK() const; /* (Intentionally not javadoc'd) * Implements the corresponding method on IStatus. */ bool Matches(const Severities& severityMask) const; protected: /** * Sets the status code. * * @param code the plug-in-specific status code, or OK */ virtual void SetCode(int code); /** * Sets the exception. * * @param exception a low-level exception, or null if not * applicable */ virtual void SetException(const std::exception& exception); /** * Sets the message. If null is passed, message is set to an empty * string. * * @param message a human-readable message, localized to the * current locale */ virtual void SetMessage(const std::string& message); /** * Sets the plug-in id. * * @param pluginId the unique identifier of the relevant plug-in */ virtual void SetPlugin(const std::string& pluginId); /** * Sets the severity. * * @param severity the severity; one of OK, ERROR, * INFO, WARNING, or CANCEL */ virtual void SetSeverity(const Severity& severity); public: /** * Returns a string representation of the status, suitable * for debugging purposes only. */ std::string ToString() const; }; } #endif /* BERRYSTATUS_H_ */ diff --git a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryQtDnDTweaklet.h b/BlueBerry/Bundles/org.blueberry.solstice.common/src/internal/berryPluginActivator.cpp old mode 100755 new mode 100644 similarity index 60% copy from BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryQtDnDTweaklet.h copy to BlueBerry/Bundles/org.blueberry.solstice.common/src/internal/berryPluginActivator.cpp index d4ba28a835..0c95395e65 --- a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryQtDnDTweaklet.h +++ b/BlueBerry/Bundles/org.blueberry.solstice.common/src/internal/berryPluginActivator.cpp @@ -1,35 +1,41 @@ /*========================================================================= Program: BlueBerry Platform Language: C++ Date: $Date$ Version: $Revision$ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ -#ifndef BERRYQTDNDTWEAKLET_H_ -#define BERRYQTDNDTWEAKLET_H_ +#include "berryPluginActivator.h" -#include +#include namespace berry { -class QtDnDTweaklet : public DnDTweaklet +org_blueberry_solstice_common_Activator::org_blueberry_solstice_common_Activator() { -public: +} + +void org_blueberry_solstice_common_Activator::start(ctkPluginContext* context) +{ + Q_UNUSED(context) +} - ITracker* CreateTracker(); -}; +void org_blueberry_solstice_common_Activator::stop(ctkPluginContext* context) +{ + Q_UNUSED(context) +} } -#endif /* BERRYQTDNDTWEAKLET_H_ */ +Q_EXPORT_PLUGIN2(org_blueberry_solstice_common, berry::org_blueberry_solstice_common_Activator) diff --git a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryQtIconImageDescriptor.h b/BlueBerry/Bundles/org.blueberry.solstice.common/src/internal/berryPluginActivator.h old mode 100755 new mode 100644 similarity index 59% copy from BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryQtIconImageDescriptor.h copy to BlueBerry/Bundles/org.blueberry.solstice.common/src/internal/berryPluginActivator.h index 9afe1a7db5..14064dec30 --- a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryQtIconImageDescriptor.h +++ b/BlueBerry/Bundles/org.blueberry.solstice.common/src/internal/berryPluginActivator.h @@ -1,49 +1,43 @@ /*========================================================================= Program: BlueBerry Platform Language: C++ Date: $Date$ Version: $Revision$ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ -#ifndef BERRYQTICONIMAGEDESCRIPTOR_H_ -#define BERRYQTICONIMAGEDESCRIPTOR_H_ +#ifndef BERRYPLUGINACTIVATOR_H +#define BERRYPLUGINACTIVATOR_H -#include - -class QIcon; +#include namespace berry { -class QtIconImageDescriptor : public ImageDescriptor +class org_blueberry_solstice_common_Activator : + public QObject, public ctkPluginActivator { - -private: - - QIcon* icon; + Q_OBJECT + Q_INTERFACES(ctkPluginActivator) public: + org_blueberry_solstice_common_Activator(); - QtIconImageDescriptor(void* img); - - virtual void* CreateImage(bool returnMissingImageOnError = true); - - virtual void DestroyImage(void* img); - - virtual bool operator==(const Object* o) const; - + void start(ctkPluginContext* context); + void stop(ctkPluginContext* context); }; +typedef org_blueberry_solstice_common_Activator PluginActivator; + } -#endif /* BERRYQTICONIMAGEDESCRIPTOR_H_ */ +#endif // BERRYPLUGINACTIVATOR_H diff --git a/BlueBerry/Bundles/org.blueberry.test/CMakeLists.txt b/BlueBerry/Bundles/org.blueberry.test/CMakeLists.txt index 11845849f7..06a0e46381 100644 --- a/BlueBerry/Bundles/org.blueberry.test/CMakeLists.txt +++ b/BlueBerry/Bundles/org.blueberry.test/CMakeLists.txt @@ -1,4 +1,8 @@ +PROJECT(org_blueberry_test) -MACRO_CREATE_PLUGIN() +MACRO_CREATE_CTK_PLUGIN( + EXPORT_DIRECTIVE BERRY_TEST_EXPORT + EXPORTED_INCLUDE_SUFFIXES src src/harness + ) -TARGET_LINK_LIBRARIES(${PLUGIN_TARGET} optimized CppUnit debug CppUnitd) \ No newline at end of file +TARGET_LINK_LIBRARIES(${PROJECT_NAME} optimized CppUnit debug CppUnitd) diff --git a/BlueBerry/Bundles/org.blueberry.test/META-INF/MANIFEST.MF b/BlueBerry/Bundles/org.blueberry.test/META-INF/MANIFEST.MF deleted file mode 100644 index 3977b0e3fb..0000000000 --- a/BlueBerry/Bundles/org.blueberry.test/META-INF/MANIFEST.MF +++ /dev/null @@ -1,7 +0,0 @@ -Manifest-Version: 1.0 -Bundle-Name: BlueBerry Automated Testing -Bundle-SymbolicName: org.blueberry.test -Bundle-Version: 0.9 -Bundle-Vendor: DKFZ, Medical and Biological Informatics -Require-Bundle: org.blueberry.osgi -Bundle-Activator: diff --git a/BlueBerry/Bundles/org.blueberry.test/files.cmake b/BlueBerry/Bundles/org.blueberry.test/files.cmake index e0301ff836..d99a9c2825 100644 --- a/BlueBerry/Bundles/org.blueberry.test/files.cmake +++ b/BlueBerry/Bundles/org.blueberry.test/files.cmake @@ -1,24 +1,35 @@ +SET(MOC_H_FILES + src/internal/berryPluginActivator.h + + src/berryCoreTestApplication.h +) + +SET(CACHED_RESOURCE_FILES + plugin.xml +) + SET(SRC_CPP_FILES berryCoreTestApplication.cpp berryBlueBerryTestDriver.cpp harness/berryTestCase.cpp util/berryCallHistory.cpp ) SET(INTERNAL_CPP_FILES + berryPluginActivator.cpp berryTestDescriptor.cpp berryTestRegistry.cpp ) -SET(CPP_FILES manifest.cpp) +SET(CPP_FILES ) foreach(file ${SRC_CPP_FILES}) SET(CPP_FILES ${CPP_FILES} src/${file}) endforeach(file ${SRC_CPP_FILES}) foreach(file ${INTERNAL_CPP_FILES}) SET(CPP_FILES ${CPP_FILES} src/internal/${file}) endforeach(file ${INTERNAL_CPP_FILES}) diff --git a/BlueBerry/Bundles/org.blueberry.test/includes.cmake b/BlueBerry/Bundles/org.blueberry.test/includes.cmake deleted file mode 100644 index 150462cd19..0000000000 --- a/BlueBerry/Bundles/org.blueberry.test/includes.cmake +++ /dev/null @@ -1,3 +0,0 @@ -SET(ADDITIONAL_INCLUDE_DIRECTORIES - src/harness -) \ No newline at end of file diff --git a/BlueBerry/Bundles/org.blueberry.test/manifest.cpp b/BlueBerry/Bundles/org.blueberry.test/manifest.cpp deleted file mode 100644 index 8408216c6e..0000000000 --- a/BlueBerry/Bundles/org.blueberry.test/manifest.cpp +++ /dev/null @@ -1,25 +0,0 @@ -/*========================================================================= - - Program: BlueBerry Platform - Language: C++ - Date: $Date$ - Version: $Revision$ - - Copyright (c) German Cancer Research Center, Division of Medical and - Biological Informatics. All rights reserved. - See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. - - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - PURPOSE. See the above copyright notices for more information. - - =========================================================================*/ - -#include "Poco/ClassLibrary.h" - -#include -#include "src/berryCoreTestApplication.h" - -POCO_BEGIN_NAMED_MANIFEST(berryIApplication, berry::IApplication) - POCO_EXPORT_CLASS(berry::CoreTestApplication) -POCO_END_MANIFEST diff --git a/BlueBerry/Bundles/org.blueberry.test/manifest_headers.cmake b/BlueBerry/Bundles/org.blueberry.test/manifest_headers.cmake new file mode 100644 index 0000000000..57fc45e72c --- /dev/null +++ b/BlueBerry/Bundles/org.blueberry.test/manifest_headers.cmake @@ -0,0 +1,6 @@ +set(Plugin-Name "BlueBerry Automated Testing") +set(Plugin-Version "0.9") +set(Plugin-Vendor "DKFZ, Medical and Biological Informatics") +set(Plugin-ContactAddress "http://www.mitk.org") +set(Require-Plugin "org.blueberry.osgi") + diff --git a/BlueBerry/Bundles/org.blueberry.test/src/berryBlueBerryTestDriver.h b/BlueBerry/Bundles/org.blueberry.test/src/berryBlueBerryTestDriver.h index f9a2412b84..571177c135 100644 --- a/BlueBerry/Bundles/org.blueberry.test/src/berryBlueBerryTestDriver.h +++ b/BlueBerry/Bundles/org.blueberry.test/src/berryBlueBerryTestDriver.h @@ -1,56 +1,56 @@ /*========================================================================= Program: BlueBerry Platform Language: C++ Date: $Date$ Version: $Revision$ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #ifndef BERRYBLUEBERRYTESTDRIVER_H_ #define BERRYBLUEBERRYTESTDRIVER_H_ -#include "berryTestDll.h" +#include #include "berryITestDescriptor.h" #include namespace berry { /** * A TestDriver for CppUnit that supports running tests inside BlueBerry as well as * running standalone. * Example call: TODO */ class BERRY_TEST_EXPORT BlueBerryTestDriver { public: BlueBerryTestDriver(const std::vector& descriptors, bool uitests = false, const std::string& testName="", bool wait=false); int Run(); static int Run(const std::string& pluginId, bool uitests = false); protected: std::vector descriptors; bool uitests; std::string testName; bool wait; }; } #endif /* BERRYBLUEBERRYTESTDRIVER_H_ */ diff --git a/BlueBerry/Bundles/org.blueberry.test/src/berryCoreTestApplication.cpp b/BlueBerry/Bundles/org.blueberry.test/src/berryCoreTestApplication.cpp index 80e8dd9af2..14dc02a3eb 100644 --- a/BlueBerry/Bundles/org.blueberry.test/src/berryCoreTestApplication.cpp +++ b/BlueBerry/Bundles/org.blueberry.test/src/berryCoreTestApplication.cpp @@ -1,45 +1,55 @@ /*========================================================================= Program: BlueBerry Platform Language: C++ Date: $Date$ Version: $Revision$ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #include "berryCoreTestApplication.h" #include #include #include "berryBlueBerryTestDriver.h" namespace berry { +CoreTestApplication::CoreTestApplication() +{ + +} + +CoreTestApplication::CoreTestApplication(const CoreTestApplication& other) +{ + Q_UNUSED(other) +} + int CoreTestApplication::Start() { std::string testPlugin; try { testPlugin = Platform::GetConfiguration().getString(Platform::ARG_TESTPLUGIN); } catch (const Poco::NotFoundException& /*e*/) { BERRY_ERROR << "You must specify a test plug-in id via " << Platform::ARG_TESTPLUGIN << "="; return 1; } return BlueBerryTestDriver::Run(testPlugin); } void CoreTestApplication::Stop() { } } diff --git a/BlueBerry/Bundles/org.blueberry.test/src/berryCoreTestApplication.h b/BlueBerry/Bundles/org.blueberry.test/src/berryCoreTestApplication.h index 5d9f9069b4..b5ddad8010 100644 --- a/BlueBerry/Bundles/org.blueberry.test/src/berryCoreTestApplication.h +++ b/BlueBerry/Bundles/org.blueberry.test/src/berryCoreTestApplication.h @@ -1,36 +1,44 @@ /*========================================================================= Program: BlueBerry Platform Language: C++ Date: $Date$ Version: $Revision$ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #ifndef BERRYCORETESTAPPLICATION_H_ #define BERRYCORETESTAPPLICATION_H_ #include +#include + namespace berry { -class CoreTestApplication : public IApplication +class CoreTestApplication : public QObject, public IApplication { + Q_OBJECT + Q_INTERFACES(berry::IApplication) + public: + CoreTestApplication(); + CoreTestApplication(const CoreTestApplication& other); + int Start(); void Stop(); }; } #endif /* BERRYCORETESTAPPLICATION_H_ */ diff --git a/BlueBerry/Bundles/org.blueberry.test/src/berryTestDll.h b/BlueBerry/Bundles/org.blueberry.test/src/berryTestDll.h deleted file mode 100644 index 54f7749319..0000000000 --- a/BlueBerry/Bundles/org.blueberry.test/src/berryTestDll.h +++ /dev/null @@ -1,43 +0,0 @@ -/*========================================================================= - -Program: BlueBerry Platform -Language: C++ -Date: $Date$ -Version: $Revision$ - -Copyright (c) German Cancer Research Center, Division of Medical and -Biological Informatics. All rights reserved. -See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. - -This software is distributed WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. See the above copyright notices for more information. - -=========================================================================*/ - -#ifndef _BERRY_TEST_EXPORT_DLL_H_ -#define _BERRY_TEST_EXPORT_DLL_H_ - - -// -// The following block is the standard way of creating macros which make exporting -// from a DLL simpler. All files within this DLL are compiled with the org_blueberry_test_EXPORTS -// symbol defined on the command line. this symbol should not be defined on any project -// that uses this DLL. This way any other project whose source files include this file see -// org_blueberry_test_EXPORTS functions as being imported from a DLL, wheras this DLL sees symbols -// defined with this macro as being exported. -// -#if defined(_WIN32) && !defined(BERRY_STATIC) - #if defined(org_blueberry_test_EXPORTS) - #define BERRY_TEST_EXPORT __declspec(dllexport) - #else - #define BERRY_TEST_EXPORT __declspec(dllimport) - #endif -#endif - - -#if !defined(BERRY_TEST_EXPORT) - #define BERRY_TEST_EXPORT -#endif - -#endif /*_BERRY_TEST_EXPORT_DLL_H_*/ diff --git a/BlueBerry/Bundles/org.blueberry.test/src/harness/berryTestCase.h b/BlueBerry/Bundles/org.blueberry.test/src/harness/berryTestCase.h index c47fd3b068..b56842a77c 100644 --- a/BlueBerry/Bundles/org.blueberry.test/src/harness/berryTestCase.h +++ b/BlueBerry/Bundles/org.blueberry.test/src/harness/berryTestCase.h @@ -1,85 +1,85 @@ /*========================================================================= Program: BlueBerry Platform Language: C++ Date: $Date$ Version: $Revision$ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #ifndef BERRYTESTCASE_H_ #define BERRYTESTCASE_H_ #include -#include "berryTestDll.h" +#include namespace berry { class BERRY_TEST_EXPORT TestCase : public CppUnit::TestCase { public: TestCase(const std::string& testName); /** * Sets up the fixture, for example, open a network connection. * This method is called before a test is executed. * The default implementation does nothing. * Subclasses may extend. */ virtual void DoSetUp(); /** * Tears down the fixture, for example, close a network connection. * This method is called after a test is executed. * The default implementation closes all test windows, processing events both before * and after doing so. * Subclasses may extend. */ virtual void DoTearDown(); /** * Clients should overwrite DoSetUp() instead of this method. */ void setUp(); /** * Clients should overwrite DoSetUp() instead of this method. */ void tearDown(); protected: /** * Call this method in your unit test to enable detailed * output about leaking berry::Object instances. */ void LeakDetailsOn(); /** * Call this method to ignore leaking objects and to continue * with the unit tests. */ void IgnoreLeakingObjects(); private: bool m_LeakDetails; bool m_IgnoreLeakage; }; } #endif /* BERRYTESTCASE_H_ */ diff --git a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryQtIconImageDescriptor.h b/BlueBerry/Bundles/org.blueberry.test/src/internal/berryPluginActivator.cpp old mode 100755 new mode 100644 similarity index 59% copy from BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryQtIconImageDescriptor.h copy to BlueBerry/Bundles/org.blueberry.test/src/internal/berryPluginActivator.cpp index 9afe1a7db5..4a2a278649 --- a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryQtIconImageDescriptor.h +++ b/BlueBerry/Bundles/org.blueberry.test/src/internal/berryPluginActivator.cpp @@ -1,49 +1,44 @@ /*========================================================================= Program: BlueBerry Platform Language: C++ Date: $Date$ Version: $Revision$ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ -#ifndef BERRYQTICONIMAGEDESCRIPTOR_H_ -#define BERRYQTICONIMAGEDESCRIPTOR_H_ +#include "berryPluginActivator.h" -#include +#include "../berryCoreTestApplication.h" -class QIcon; +#include namespace berry { -class QtIconImageDescriptor : public ImageDescriptor +org_blueberry_test_Activator::org_blueberry_test_Activator() { -private: - - QIcon* icon; - -public: - - QtIconImageDescriptor(void* img); - - virtual void* CreateImage(bool returnMissingImageOnError = true); - - virtual void DestroyImage(void* img); +} - virtual bool operator==(const Object* o) const; +void org_blueberry_test_Activator::start(ctkPluginContext* context) +{ + BERRY_REGISTER_EXTENSION_CLASS(CoreTestApplication, context) +} -}; +void org_blueberry_test_Activator::stop(ctkPluginContext* context) +{ + Q_UNUSED(context) +} } -#endif /* BERRYQTICONIMAGEDESCRIPTOR_H_ */ +Q_EXPORT_PLUGIN2(org_blueberry_test, berry::org_blueberry_test_Activator) diff --git a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryQtDnDTweaklet.h b/BlueBerry/Bundles/org.blueberry.test/src/internal/berryPluginActivator.h old mode 100755 new mode 100644 similarity index 61% copy from BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryQtDnDTweaklet.h copy to BlueBerry/Bundles/org.blueberry.test/src/internal/berryPluginActivator.h index d4ba28a835..b3fbfcd853 --- a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryQtDnDTweaklet.h +++ b/BlueBerry/Bundles/org.blueberry.test/src/internal/berryPluginActivator.h @@ -1,35 +1,43 @@ /*========================================================================= Program: BlueBerry Platform Language: C++ Date: $Date$ Version: $Revision$ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ -#ifndef BERRYQTDNDTWEAKLET_H_ -#define BERRYQTDNDTWEAKLET_H_ +#ifndef BERRYPLUGINACTIVATOR_H +#define BERRYPLUGINACTIVATOR_H -#include +#include namespace berry { -class QtDnDTweaklet : public DnDTweaklet +class org_blueberry_test_Activator : + public QObject, public ctkPluginActivator { + Q_OBJECT + Q_INTERFACES(ctkPluginActivator) + public: + org_blueberry_test_Activator(); - ITracker* CreateTracker(); + void start(ctkPluginContext* context); + void stop(ctkPluginContext* context); }; +typedef org_blueberry_test_Activator PluginActivator; + } -#endif /* BERRYQTDNDTWEAKLET_H_ */ +#endif // BERRYPLUGINACTIVATOR_H diff --git a/BlueBerry/Bundles/org.blueberry.test/src/internal/berryTestDescriptor.cpp b/BlueBerry/Bundles/org.blueberry.test/src/internal/berryTestDescriptor.cpp index 2ec39a589f..931800f402 100644 --- a/BlueBerry/Bundles/org.blueberry.test/src/internal/berryTestDescriptor.cpp +++ b/BlueBerry/Bundles/org.blueberry.test/src/internal/berryTestDescriptor.cpp @@ -1,69 +1,77 @@ /*========================================================================= Program: BlueBerry Platform Language: C++ Date: $Date$ Version: $Revision$ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #include "berryTestDescriptor.h" #include "berryTestRegistry.h" #include +Q_DECLARE_INTERFACE(CppUnit::Test, "CppUnit.Test") + namespace berry { TestDescriptor::TestDescriptor(IConfigurationElement::Pointer elem) : configElem(elem) { } CppUnit::Test* TestDescriptor::CreateTest() { CppUnit::Test* test = configElem->CreateExecutableExtension ( - TestRegistry::ATT_CLASS, TestRegistry::TEST_MANIFEST); + TestRegistry::ATT_CLASS); + if (test == 0) + { + // Try legacy BlueBerry manifests instead + test = configElem->CreateExecutableExtension ( + TestRegistry::ATT_CLASS, TestRegistry::TEST_MANIFEST); + } return test; } std::string TestDescriptor::GetId() const { std::string id; configElem->GetAttribute(TestRegistry::ATT_ID, id); return id; } std::string TestDescriptor::GetContributor() const { return configElem->GetContributor(); } std::string TestDescriptor::GetDescription() const { std::string descr; configElem->GetAttribute(TestRegistry::ATT_DESCRIPTION, descr); return descr; } bool TestDescriptor::IsUITest() const { std::string isUi; if (configElem->GetAttribute(TestRegistry::ATT_UITEST, isUi)) { return !Poco::icompare(isUi, "true"); } return false; } } diff --git a/BlueBerry/Bundles/org.blueberry.test/src/util/berryCallHistory.h b/BlueBerry/Bundles/org.blueberry.test/src/util/berryCallHistory.h index e057d5ea16..752fbe2d97 100644 --- a/BlueBerry/Bundles/org.blueberry.test/src/util/berryCallHistory.h +++ b/BlueBerry/Bundles/org.blueberry.test/src/util/berryCallHistory.h @@ -1,136 +1,136 @@ /*========================================================================= Program: BlueBerry Platform Language: C++ Date: $Date$ Version: $Revision$ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #ifndef BERRYCALLHISTORY_H_ #define BERRYCALLHISTORY_H_ -#include "../berryTestDll.h" +#include #include #include #include #include #include namespace berry { /** * CallHistory is used to record the invocation * of methods within a target object. This is useful during * lifecycle testing for an object. *

* To use CallHistory .. *

    *
  1. Create a CallHistory in the target or pass one in.
  2. *
  3. Invoke some test scenario.
  4. *
  5. If a method is called on the target record the invocation * in the call history
  6. *
  7. Verify the call history after the test scenario is * complete.
  8. *
*

* Each CallHistory has a target which is used to * verify the method names passed to the history. If an invalid * name is passed an IllegalArgumentException will * be thrown. *

*/ class BERRY_TEST_EXPORT CallHistory : public Object { private: std::vector methodList; // Class classType; public: berryObjectMacro(CallHistory) /** * Creates a new call history for an object. * * @param target the call history target. */ CallHistory(/*Object target*/); /** * Adds a method name to the call history. * * @param methodName the name of a method */ void Add(const std::string& methodName); /** * Clears the call history. */ void Clear(); /** * Returns whether a list of methods have been called in * order. * * @param testNames an array of the method names in the order they are expected * @return true if the methods were called in order */ bool VerifyOrder(const std::vector& testNames) const throw(Poco::InvalidArgumentException); /** * Returns whether a method has been called. * * @param methodName a method name * @return true if the method was called */ bool Contains(const std::string& methodName) const ; /** * Returns whether a list of methods were called. * * @param methodNames a list of methods * @return true if the methods were called */ bool Contains(const std::vector& methodNames) const; /** * Returns whether the list of methods called is empty. * * @return true iff the list of methods is empty */ bool IsEmpty() const; /** * Prints the call history to the console. */ void PrintTo(std::ostream& out) const; private: /** * Throws an exception if the method name is invalid * for the given target class. */ void TestMethodName(const std::string&) const throw(Poco::InvalidArgumentException); }; } #endif /* BERRYCALLHISTORY_H_ */ diff --git a/BlueBerry/Bundles/org.blueberry.ui.qt.log/CMakeLists.txt b/BlueBerry/Bundles/org.blueberry.ui.qt.log/CMakeLists.txt index c4ae258e19..65a94ecd4d 100644 --- a/BlueBerry/Bundles/org.blueberry.ui.qt.log/CMakeLists.txt +++ b/BlueBerry/Bundles/org.blueberry.ui.qt.log/CMakeLists.txt @@ -1,2 +1,7 @@ -MACRO_CREATE_QT_PLUGIN() -TARGET_LINK_LIBRARIES(${PLUGIN_TARGET} mbilog) \ No newline at end of file +PROJECT(org_blueberry_ui_qt_log) + +MACRO_CREATE_CTK_PLUGIN( + EXPORT_DIRECTIVE org_blueberry_ui_qt_log_EXPORT + EXPORTED_INCLUDE_SUFFIXES src +) + diff --git a/BlueBerry/Bundles/org.blueberry.ui.qt.log/META-INF/MANIFEST.MF b/BlueBerry/Bundles/org.blueberry.ui.qt.log/META-INF/MANIFEST.MF deleted file mode 100644 index b16a9af497..0000000000 --- a/BlueBerry/Bundles/org.blueberry.ui.qt.log/META-INF/MANIFEST.MF +++ /dev/null @@ -1,7 +0,0 @@ -Manifest-Version: 1.0 -Bundle-Name: The Logging Module -Bundle-SymbolicName: org.blueberry.ui.qt.log -Bundle-Version: 1.0.0 -Bundle-Vendor: DKFZ, Medical and Biological Informatics -Bundle-Activator: berry::QtLogPlugin -Require-Bundle: org.blueberry.ui.qt \ No newline at end of file diff --git a/BlueBerry/Bundles/org.blueberry.ui.qt.log/files.cmake b/BlueBerry/Bundles/org.blueberry.ui.qt.log/files.cmake index b093d2ddf2..fcd783cc82 100644 --- a/BlueBerry/Bundles/org.blueberry.ui.qt.log/files.cmake +++ b/BlueBerry/Bundles/org.blueberry.ui.qt.log/files.cmake @@ -1,33 +1,37 @@ SET(SRC_CPP_FILES ) SET(INTERNAL_CPP_FILES berryLogView.cpp berryQtLogPlugin.cpp berryQtLogView.cpp berryQtPlatformLogModel.cpp ) -SET(CPP_FILES manifest.cpp) +SET(CPP_FILES ) SET(MOC_H_FILES + src/internal/berryLogView.h + src/internal/berryQtLogPlugin.h src/internal/berryQtLogView.h src/internal/berryQtPlatformLogModel.h ) -SET(RESOURCE_FILES +SET(CACHED_RESOURCE_FILES + plugin.xml + resources/Logging.png ) SET(UI_FILES src/internal/berryQtLogView.ui ) foreach(file ${SRC_CPP_FILES}) SET(CPP_FILES ${CPP_FILES} src/${file}) endforeach(file ${SRC_CPP_FILES}) foreach(file ${INTERNAL_CPP_FILES}) SET(CPP_FILES ${CPP_FILES} src/internal/${file}) -endforeach(file ${INTERNAL_CPP_FILES}) \ No newline at end of file +endforeach(file ${INTERNAL_CPP_FILES}) diff --git a/BlueBerry/Bundles/org.blueberry.ui.qt.log/manifest.cpp b/BlueBerry/Bundles/org.blueberry.ui.qt.log/manifest.cpp deleted file mode 100644 index f8dafc3fb2..0000000000 --- a/BlueBerry/Bundles/org.blueberry.ui.qt.log/manifest.cpp +++ /dev/null @@ -1,32 +0,0 @@ -/*========================================================================= - - Program: BlueBerry Platform - Language: C++ - Date: $Date$ - Version: $Revision$ - - Copyright (c) German Cancer Research Center, Division of Medical and - Biological Informatics. All rights reserved. - See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. - - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - PURPOSE. See the above copyright notices for more information. - - =========================================================================*/ - -#include "Poco/ClassLibrary.h" - -#include -#include "src/internal/berryQtLogPlugin.h" - -#include -#include "src/internal/berryLogView.h" - -POCO_BEGIN_MANIFEST(berry::IBundleActivator) - POCO_EXPORT_CLASS(berry::QtLogPlugin) -POCO_END_MANIFEST - -POCO_BEGIN_NAMED_MANIFEST(berryIViewPart, berry::IViewPart) - POCO_EXPORT_CLASS(berry::LogView) -POCO_END_MANIFEST diff --git a/BlueBerry/Bundles/org.blueberry.ui.qt.log/manifest_headers.cmake b/BlueBerry/Bundles/org.blueberry.ui.qt.log/manifest_headers.cmake new file mode 100644 index 0000000000..1b65ca4047 --- /dev/null +++ b/BlueBerry/Bundles/org.blueberry.ui.qt.log/manifest_headers.cmake @@ -0,0 +1,6 @@ +set(Plugin-Name "BlueBerry Log Bundle") +set(Plugin-Version "1.0.0") +set(Plugin-Vendor "DKFZ, Medical and Biological Informatics") +set(Plugin-ContactAddress "http://www.mitk.org") +set(Require-Plugin org.blueberry.ui.qt) + diff --git a/BlueBerry/Bundles/org.blueberry.ui.qt.log/src/internal/berryLogView.cpp b/BlueBerry/Bundles/org.blueberry.ui.qt.log/src/internal/berryLogView.cpp index e829c6ed11..5f326c39b4 100644 --- a/BlueBerry/Bundles/org.blueberry.ui.qt.log/src/internal/berryLogView.cpp +++ b/BlueBerry/Bundles/org.blueberry.ui.qt.log/src/internal/berryLogView.cpp @@ -1,46 +1,57 @@ /*========================================================================= Program: BlueBerry Platform Language: C++ Date: $Date$ Version: $Revision$ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #ifdef __MINGW32__ // We need to inlclude winbase.h here in order to declare // atomic intrinsics like InterlockedIncrement correctly. // Otherwhise, they would be declared wrong within qatomic_windows.h . #include #endif #include "berryLogView.h" #include "berryQtLogView.h" #include namespace berry { +LogView::LogView() +{ + +} + +LogView::LogView(const LogView& other) +{ + Q_UNUSED(other) + throw std::runtime_error("Copy constructor not implemented"); +} + void LogView::CreateQtPartControl(QWidget* parent) { QHBoxLayout* layout = new QHBoxLayout(parent); layout->setContentsMargins(0,0,0,0); QtLogView* logView = new QtLogView(parent); layout->addWidget(logView); } void LogView::SetFocus() { } } diff --git a/BlueBerry/Bundles/org.blueberry.ui.qt.log/src/internal/berryLogView.h b/BlueBerry/Bundles/org.blueberry.ui.qt.log/src/internal/berryLogView.h index ee43dc637f..86e9424210 100644 --- a/BlueBerry/Bundles/org.blueberry.ui.qt.log/src/internal/berryLogView.h +++ b/BlueBerry/Bundles/org.blueberry.ui.qt.log/src/internal/berryLogView.h @@ -1,41 +1,46 @@ /*========================================================================= Program: BlueBerry Platform Language: C++ Date: $Date$ Version: $Revision$ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #ifndef BERRYLOGVIEW_H_ #define BERRYLOGVIEW_H_ #include #include "../berryQtViewPart.h" namespace berry { class LogView : public QtViewPart { + Q_OBJECT + public: + LogView(); + LogView(const LogView& other); + void SetFocus(); protected: void CreateQtPartControl(QWidget* parent); }; } // namespace berry #endif /*BERRYLOGVIEW_H_*/ diff --git a/BlueBerry/Bundles/org.blueberry.ui.qt.log/src/internal/berryQtLogPlugin.cpp b/BlueBerry/Bundles/org.blueberry.ui.qt.log/src/internal/berryQtLogPlugin.cpp index aaf66503e8..96b45b0f33 100644 --- a/BlueBerry/Bundles/org.blueberry.ui.qt.log/src/internal/berryQtLogPlugin.cpp +++ b/BlueBerry/Bundles/org.blueberry.ui.qt.log/src/internal/berryQtLogPlugin.cpp @@ -1,53 +1,61 @@ /*========================================================================= Program: BlueBerry Platform Language: C++ Date: $Date$ Version: $Revision$ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #include "berryQtLogPlugin.h" +#include "berryLogView.h" + +#include + namespace berry { QtLogPlugin* QtLogPlugin::instance = 0; QtLogPlugin::QtLogPlugin() { instance = this; } void -QtLogPlugin::Start(IBundleContext::Pointer /*context*/) +QtLogPlugin::start(ctkPluginContext* context) { + BERRY_REGISTER_EXTENSION_CLASS(berry::LogView, context) + m_LogModel = new QtPlatformLogModel(); } void -QtLogPlugin::Stop(IBundleContext::Pointer /*context*/) +QtLogPlugin::stop(ctkPluginContext* /*context*/) { delete m_LogModel; } QtLogPlugin* QtLogPlugin::GetInstance() { return instance; } QtPlatformLogModel* QtLogPlugin::GetLogModel() { return m_LogModel; } } + +Q_EXPORT_PLUGIN2(org_blueberry_ui_qt_log, berry::QtLogPlugin) diff --git a/BlueBerry/Bundles/org.blueberry.ui.qt.log/src/internal/berryQtLogPlugin.h b/BlueBerry/Bundles/org.blueberry.ui.qt.log/src/internal/berryQtLogPlugin.h index baf28c3626..b56a932780 100644 --- a/BlueBerry/Bundles/org.blueberry.ui.qt.log/src/internal/berryQtLogPlugin.h +++ b/BlueBerry/Bundles/org.blueberry.ui.qt.log/src/internal/berryQtLogPlugin.h @@ -1,49 +1,52 @@ /*========================================================================= Program: BlueBerry Platform Language: C++ Date: $Date$ Version: $Revision$ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #ifndef BERRYLOGPLUGIN_H_ #define BERRYLOGPLUGIN_H_ -#include +#include #include "berryQtPlatformLogModel.h" namespace berry { -class QtLogPlugin : public Plugin +class QtLogPlugin : public QObject, public ctkPluginActivator { + Q_OBJECT + Q_INTERFACES(ctkPluginActivator) + public: QtLogPlugin(); - void Start(IBundleContext::Pointer context); - void Stop(IBundleContext::Pointer context); + void start(ctkPluginContext* context); + void stop(ctkPluginContext* context); static QtLogPlugin* GetInstance(); QtPlatformLogModel* GetLogModel(); private: static QtLogPlugin* instance; QtPlatformLogModel* m_LogModel; }; } #endif /*BERRYLOGPLUGIN_H_*/ diff --git a/BlueBerry/Bundles/org.blueberry.ui.qt.objectinspector/CMakeLists.txt b/BlueBerry/Bundles/org.blueberry.ui.qt.objectinspector/CMakeLists.txt index 83cbfe0728..765ae928c6 100644 --- a/BlueBerry/Bundles/org.blueberry.ui.qt.objectinspector/CMakeLists.txt +++ b/BlueBerry/Bundles/org.blueberry.ui.qt.objectinspector/CMakeLists.txt @@ -1,6 +1,10 @@ +PROJECT(org_blueberry_ui_qt_objectinspector) -MACRO_CREATE_QT_PLUGIN() +MACRO_CREATE_CTK_PLUGIN( + EXPORT_DIRECTIVE BERRY_OBJECTINSPECTOR_EXPORT + EXPORTED_INCLUDE_SUFFIXES src +) IF(NOT BLUEBERRY_DEBUG_SMARTPOINTER) - MESSAGE("You should set BLUEBERRY_DEBUG_SMARTPOINTER to ON if you want the bundle ${BUNDLE-SYMBOLICNAME} to be useful") -ENDIF() \ No newline at end of file + MESSAGE("You should set BLUEBERRY_DEBUG_SMARTPOINTER to ON if you want the plug-in ${Plugin-SymbolicName} to be useful") +ENDIF() diff --git a/BlueBerry/Bundles/org.blueberry.ui.qt.objectinspector/META-INF/MANIFEST.MF b/BlueBerry/Bundles/org.blueberry.ui.qt.objectinspector/META-INF/MANIFEST.MF deleted file mode 100644 index b74025bb8d..0000000000 --- a/BlueBerry/Bundles/org.blueberry.ui.qt.objectinspector/META-INF/MANIFEST.MF +++ /dev/null @@ -1,7 +0,0 @@ -Manifest-Version: 1.0 -Bundle-Name: Object Inspector -Bundle-SymbolicName: org.blueberry.ui.qt.objectinspector -Bundle-Version: 0.1 -Bundle-Vendor: DKFZ, Medical and Biological Informatics -Require-Bundle: org.blueberry.ui.qt -Bundle-Activator: diff --git a/BlueBerry/Bundles/org.blueberry.ui.qt.objectinspector/files.cmake b/BlueBerry/Bundles/org.blueberry.ui.qt.objectinspector/files.cmake index 204399f21c..3d96b5a3c4 100644 --- a/BlueBerry/Bundles/org.blueberry.ui.qt.objectinspector/files.cmake +++ b/BlueBerry/Bundles/org.blueberry.ui.qt.objectinspector/files.cmake @@ -1,37 +1,40 @@ SET(SRC_CPP_FILES ) SET(INTERNAL_CPP_FILES berryObjectBrowserView.cpp berryObjectItem.cpp + berryPluginActivator.cpp berryQtObjectTableModel.cpp ) SET(UI_FILES src/internal/berryQtObjectBrowserView.ui ) SET(MOC_H_FILES src/internal/berryObjectBrowserView.h + src/internal/berryPluginActivator.h src/internal/berryQtObjectTableModel.h ) -SET(RESOURCE_FILES +SET(CACHED_RESOURCE_FILES + plugin.xml resources/ObjectBrowser.png ) SET(RES_FILES resources/blueberry_ui_qt_objectinspector.qrc ) -SET(CPP_FILES manifest.cpp) +SET(CPP_FILES ) foreach(file ${SRC_CPP_FILES}) SET(CPP_FILES ${CPP_FILES} src/${file}) endforeach(file ${SRC_CPP_FILES}) foreach(file ${INTERNAL_CPP_FILES}) SET(CPP_FILES ${CPP_FILES} src/internal/${file}) endforeach(file ${INTERNAL_CPP_FILES}) diff --git a/BlueBerry/Bundles/org.blueberry.ui.qt.objectinspector/manifest.cpp b/BlueBerry/Bundles/org.blueberry.ui.qt.objectinspector/manifest.cpp deleted file mode 100755 index 616688055c..0000000000 --- a/BlueBerry/Bundles/org.blueberry.ui.qt.objectinspector/manifest.cpp +++ /dev/null @@ -1,27 +0,0 @@ -/*========================================================================= - -Program: BlueBerry Platform -Language: C++ -Date: $Date$ -Version: $Revision$ - -Copyright (c) German Cancer Research Center, Division of Medical and -Biological Informatics. All rights reserved. -See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. - -This software is distributed WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. See the above copyright notices for more information. - -=========================================================================*/ - -#include "Poco/ClassLibrary.h" - -#include -#include "src/internal/berryObjectBrowserView.h" - - -//******************** Views ********************** -POCO_BEGIN_NAMED_MANIFEST(berryIViewPart, berry::IViewPart) - POCO_EXPORT_CLASS(berry::ObjectBrowserView) -POCO_END_MANIFEST diff --git a/BlueBerry/Bundles/org.blueberry.ui.qt.objectinspector/manifest_headers.cmake b/BlueBerry/Bundles/org.blueberry.ui.qt.objectinspector/manifest_headers.cmake new file mode 100644 index 0000000000..87af27bb0e --- /dev/null +++ b/BlueBerry/Bundles/org.blueberry.ui.qt.objectinspector/manifest_headers.cmake @@ -0,0 +1,6 @@ +set(Plugin-Name "Object Inspector") +set(Plugin-Version "0.1") +set(Plugin-Vendor "DKFZ, Medical and Biological Informatics") +set(Plugin-ContactAddress "http://www.mitk.org") +set(Require-Plugin org.blueberry.ui.qt) + diff --git a/BlueBerry/Bundles/org.blueberry.ui.qt.objectinspector/src/berryObjectinspectorDll.h b/BlueBerry/Bundles/org.blueberry.ui.qt.objectinspector/src/berryObjectinspectorDll.h deleted file mode 100644 index aa3c845ce2..0000000000 --- a/BlueBerry/Bundles/org.blueberry.ui.qt.objectinspector/src/berryObjectinspectorDll.h +++ /dev/null @@ -1,43 +0,0 @@ -/*========================================================================= - -Program: BlueBerry Platform -Language: C++ -Date: $Date$ -Version: $Revision$ - -Copyright (c) German Cancer Research Center, Division of Medical and -Biological Informatics. All rights reserved. -See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. - -This software is distributed WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. See the above copyright notices for more information. - -=========================================================================*/ - -#ifndef _BERRY_OBJECTINSPECTOR_EXPORT_DLL_H_ -#define _BERRY_OBJECTINSPECTOR_EXPORT_DLL_H_ - - -// -// The following block is the standard way of creating macros which make exporting -// from a DLL simpler. All files within this DLL are compiled with the org_blueberry_ui_qt_objectinspector_EXPORTS -// symbol defined on the command line. this symbol should not be defined on any project -// that uses this DLL. This way any other project whose source files include this file see -// org_blueberry_ui_qt_objectinspector_EXPORTS functions as being imported from a DLL, wheras this DLL sees symbols -// defined with this macro as being exported. -// -#if defined(_WIN32) && !defined(BERRY_STATIC) - #if defined(org_blueberry_ui_qt_objectinspector_EXPORTS) - #define BERRY_OBJECTINSPECTOR_EXPORT __declspec(dllexport) - #else - #define BERRY_OBJECTINSPECTOR_EXPORT __declspec(dllimport) - #endif -#endif - - -#if !defined(BERRY_OBJECTINSPECTOR_EXPORT) - #define BERRY_OBJECTINSPECTOR_EXPORT -#endif - -#endif /*_BERRY_OBJECTINSPECTOR_EXPORT_DLL_H_*/ diff --git a/BlueBerry/Bundles/org.blueberry.ui.qt.objectinspector/src/internal/berryObjectBrowserView.cpp b/BlueBerry/Bundles/org.blueberry.ui.qt.objectinspector/src/internal/berryObjectBrowserView.cpp index 0900459774..a0659e5cc9 100644 --- a/BlueBerry/Bundles/org.blueberry.ui.qt.objectinspector/src/internal/berryObjectBrowserView.cpp +++ b/BlueBerry/Bundles/org.blueberry.ui.qt.objectinspector/src/internal/berryObjectBrowserView.cpp @@ -1,273 +1,281 @@ /*========================================================================= Program: BlueBerry Platform Language: C++ Date: $Date$ Version: $Revision$ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #ifdef __MINGW32__ // We need to inlclude winbase.h here in order to declare // atomic intrinsics like InterlockedIncrement correctly. // Otherwhise, they would be declared wrong within qatomic_windows.h . #include #endif #include #include #include #include #include "berryObjectBrowserView.h" #include "berryDebugUtil.h" #include "berryDebugBreakpointManager.h" #include namespace berry { const std::string ObjectBrowserView::VIEW_ID = "objectbrowser"; ObjectBrowserView::ObjectBrowserView() : m_ActionToggleBreakpoint(this), m_ActionEnableBreakpoint(this), m_ActionDisableBreakpoint(this) { #ifdef BLUEBERRY_DEBUG_SMARTPOINTER m_Useful = true; #else m_Useful = false; #endif } +ObjectBrowserView::ObjectBrowserView(const ObjectBrowserView& other) + : m_ActionToggleBreakpoint(this), m_ActionEnableBreakpoint(this), + m_ActionDisableBreakpoint(this) +{ + Q_UNUSED(other) + throw std::runtime_error("Copy constructor not implemented"); +} + void ObjectBrowserView::Init(IViewSite::Pointer site, IMemento::Pointer memento) { QtViewPart::Init(site, memento); m_StateMemento = memento; } void ObjectBrowserView::CreateQtPartControl(QWidget* parent) { if (m_Useful) { m_Controls.setupUi(parent); m_ProxyModel = new QSortFilterProxyModel(m_Controls.m_TreeView); m_ObjectModel = new QtObjectTableModel(m_ProxyModel); m_ProxyModel->setSourceModel(m_ObjectModel); m_Controls.m_TreeView->setModel(m_ProxyModel); m_Controls.m_TreeView->setSortingEnabled(true); m_Controls.m_TreeView->setContextMenuPolicy(Qt::CustomContextMenu); m_ActionToggleBreakpoint.setText(QString("Toggle Breakpoint")); m_ActionToggleBreakpoint.setCheckable(true); m_ContextMenu.addAction(&m_ActionToggleBreakpoint); QToolBar* toolbar = new QToolBar(parent); QAction* resetAction = toolbar->addAction("Reset"); toolbar->addAction("Show Breakpoints Only"); connect(resetAction, SIGNAL(triggered(bool)), this, SLOT(ResetAction(bool))); connect(m_Controls.m_TreeView->selectionModel(), SIGNAL(selectionChanged(const QItemSelection&, const QItemSelection&)), this, SLOT(SelectionChanged(const QItemSelection&, const QItemSelection&))); connect(m_Controls.m_TreeView, SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT(ContextMenuRequested(const QPoint&))); // context menu actions connect(&m_ActionToggleBreakpoint, SIGNAL(triggered(bool)), this, SLOT(ToggleBreakpoint(bool))); parent->layout()->setMenuBar(toolbar); RestoreGuiState(m_StateMemento); m_StateMemento = 0; } else { QVBoxLayout* layout = new QVBoxLayout(parent); QLabel* label = new QLabel(parent); label->setText( "Set the CMake variable BLUEBERRY_DEBUG_SMARTPOINTER to ON for a useful object browser."); label->setWordWrap(true); label->setAlignment(Qt::AlignTop); layout->addWidget(label); } } void ObjectBrowserView::RestoreGuiState(IMemento::Pointer memento) { if (memento) { IMemento::Pointer columnWidths = memento->GetChild("columnWidths"); if (columnWidths) { int colWidth = 0; if (columnWidths->GetInteger("column0", colWidth)) { m_Controls.m_TreeView->setColumnWidth(0, colWidth); } if (columnWidths->GetInteger("column1", colWidth)) { m_Controls.m_TreeView->setColumnWidth(1, colWidth); } } IMemento::Pointer splitter = memento->GetChild("splitter"); if (splitter) { QList sizes; int size = 200; splitter->GetInteger("first", size); sizes.push_back(size); splitter->GetInteger("second", size); sizes.push_back(size); m_Controls.m_Splitter->setSizes(sizes); } } } void ObjectBrowserView::ResetAction(bool /*checked*/) { m_ObjectModel->ResetData(); } void ObjectBrowserView::SelectionChanged(const QItemSelection& selected, const QItemSelection& /*deselected*/) { QList indexes = selected.indexes(); if (indexes.empty()) { m_Controls.m_DetailsView->clear(); return; } QModelIndex index = indexes.front(); if (!index.parent().isValid()) { m_Controls.m_DetailsView->clear(); } QVariant data = m_ProxyModel->data(index, Qt::UserRole); if (data.isValid()) { const ObjectItem* item = static_cast (data.value ()); if (item) { const Object* obj = 0; if (item->type == ObjectItem::INSTANCE) obj = item->obj; else if (item->type == ObjectItem::SMARTPOINTER) { const ObjectItem* item = static_cast (m_ProxyModel->data(index.parent(), Qt::UserRole).value ()); if (item) obj = item->obj; } if (obj) { std::stringstream ss; ss << *(obj) << std::endl << obj->ToString(); m_Controls.m_DetailsView->setPlainText(QString::fromStdString(ss.str())); } else { m_Controls.m_DetailsView->setPlainText(QString("0")); } } else { m_Controls.m_DetailsView->setPlainText(QString("0")); } } } void ObjectBrowserView::ContextMenuRequested(const QPoint& p) { QModelIndex index = m_Controls.m_TreeView->selectionModel()->currentIndex(); if (index.isValid()) { QVariant data = m_ProxyModel->data(index, Qt::UserRole); if (!data.isValid()) return; const ObjectItem* item = static_cast (data.value ()); if (item->type == ObjectItem::CLASS) return; m_ContextMenu.exec(m_Controls.m_TreeView->mapToGlobal(p)); } } void ObjectBrowserView::ToggleBreakpoint(bool checked) { QModelIndex index = m_Controls.m_TreeView->selectionModel()->currentIndex(); if (index.isValid()) { QVariant data = m_ProxyModel->data(index, Qt::UserRole); if (!data.isValid()) return; const ObjectItem* item = static_cast (data.value ()); if (item->type == ObjectItem::INSTANCE) { #ifdef BLUEBERRY_DEBUG_SMARTPOINTER if (checked) DebugUtil::GetBreakpointManager()->AddObjectBreakpoint(item->obj->GetTraceId()); else DebugUtil::GetBreakpointManager()->RemoveObjectBreakpoint(item->obj->GetTraceId()); #endif } else if (item->type == ObjectItem::SMARTPOINTER) { if (checked) DebugUtil::GetBreakpointManager()->AddSmartpointerBreakpoint(item->spId); else DebugUtil::GetBreakpointManager()->RemoveSmartpointerBreakpoint( item->spId); } } } void ObjectBrowserView::SetFocus() { if (m_Useful) { m_Controls.m_TreeView->setFocus(); } } void ObjectBrowserView::SaveState(IMemento::Pointer memento) { if (!m_Useful) return; IMemento::Pointer cols = memento->CreateChild("columnWidths"); cols->PutInteger("column0", m_Controls.m_TreeView->columnWidth(0)); cols->PutInteger("column1", m_Controls.m_TreeView->columnWidth(1)); QList sizes(m_Controls.m_Splitter->sizes()); IMemento::Pointer splitter = memento->CreateChild("splitter"); splitter->PutInteger("first", sizes[0]); splitter->PutInteger("second", sizes[1]); // delete the tree view here in order to delete the underlying model // which in turn unregisters the object listener. Otherwise, we get // notifications of deleted objects during workbench shutdown which // leads to segmentation faults m_Controls.m_TreeView->deleteLater(); } } //namespace berry diff --git a/BlueBerry/Bundles/org.blueberry.ui.qt.objectinspector/src/internal/berryObjectBrowserView.h b/BlueBerry/Bundles/org.blueberry.ui.qt.objectinspector/src/internal/berryObjectBrowserView.h index 721c2b0a2f..a5a0bf59a2 100644 --- a/BlueBerry/Bundles/org.blueberry.ui.qt.objectinspector/src/internal/berryObjectBrowserView.h +++ b/BlueBerry/Bundles/org.blueberry.ui.qt.objectinspector/src/internal/berryObjectBrowserView.h @@ -1,101 +1,102 @@ /*========================================================================= Program: BlueBerry Platform Language: C++ Date: $Date$ Version: $Revision$ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #ifndef BERRY_OBJECTINSPECTORVIEW_H_INCLUDED #define BERRY_OBJECTINSPECTORVIEW_H_INCLUDED #include #include #include #include "berryQtObjectTableModel.h" #include #include class QAbstractProxyModel; namespace berry { /*! * \ingroup org_blueberry_ui_qt_objectinspector_internal * * \brief Object Inspector * * You need to reimplement the methods SetFocus() and CreateQtPartControl(QWidget*) * from berry::QtViewPart * * \sa berry::QtViewPart */ -class ObjectBrowserView : public QObject, public berry::QtViewPart +class ObjectBrowserView : public berry::QtViewPart { Q_OBJECT public: static const std::string VIEW_ID; ObjectBrowserView(); + ObjectBrowserView(const ObjectBrowserView& other); void Init(IViewSite::Pointer site, IMemento::Pointer memento); /*! * \brief Gives focus to a specific control in the view * This method is called from the framework when the view is activated. */ void SetFocus(); void SaveState(IMemento::Pointer memento); protected slots: void ResetAction(bool checked); void SelectionChanged(const QItemSelection& selected, const QItemSelection& deselected); void ContextMenuRequested(const QPoint&); void ToggleBreakpoint(bool checked); protected: /*! * \brief Builds the user interface of the view * This method is called from the framework. The parent widget has no layout, so * you should set one adapted to your needs. */ void CreateQtPartControl(QWidget* parent); void RestoreGuiState(IMemento::Pointer memento); private: Ui::QtObjectBrowserView m_Controls; QtObjectTableModel* m_ObjectModel; QAbstractProxyModel* m_ProxyModel; QAction m_ActionToggleBreakpoint; QAction m_ActionEnableBreakpoint; QAction m_ActionDisableBreakpoint; QMenu m_ContextMenu; IMemento::Pointer m_StateMemento; bool m_Useful; }; } //namespace berry #endif /*BERRY_OBJECTINSPECTORVIEW_H_INCLUDED*/ diff --git a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryQtIconImageDescriptor.h b/BlueBerry/Bundles/org.blueberry.ui.qt.objectinspector/src/internal/berryPluginActivator.cpp old mode 100755 new mode 100644 similarity index 59% copy from BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryQtIconImageDescriptor.h copy to BlueBerry/Bundles/org.blueberry.ui.qt.objectinspector/src/internal/berryPluginActivator.cpp index 9afe1a7db5..74358e53c5 --- a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryQtIconImageDescriptor.h +++ b/BlueBerry/Bundles/org.blueberry.ui.qt.objectinspector/src/internal/berryPluginActivator.cpp @@ -1,49 +1,41 @@ /*========================================================================= Program: BlueBerry Platform Language: C++ Date: $Date$ Version: $Revision$ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ -#ifndef BERRYQTICONIMAGEDESCRIPTOR_H_ -#define BERRYQTICONIMAGEDESCRIPTOR_H_ +#include "berryPluginActivator.h" -#include +#include "berryObjectBrowserView.h" -class QIcon; +#include namespace berry { -class QtIconImageDescriptor : public ImageDescriptor +void org_blueberry_ui_qt_objectinspector_Activator::start(ctkPluginContext* context) { + BERRY_REGISTER_EXTENSION_CLASS(berry::ObjectBrowserView, context) +} -private: - - QIcon* icon; - -public: - - QtIconImageDescriptor(void* img); - - virtual void* CreateImage(bool returnMissingImageOnError = true); - - virtual void DestroyImage(void* img); +void org_blueberry_ui_qt_objectinspector_Activator::stop(ctkPluginContext* context) +{ + Q_UNUSED(context) +} - virtual bool operator==(const Object* o) const; +} -}; +Q_EXPORT_PLUGIN2(org_blueberry_ui_qt_objectinspector, berry::org_blueberry_ui_qt_objectinspector_Activator) -} -#endif /* BERRYQTICONIMAGEDESCRIPTOR_H_ */ diff --git a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryQtIconImageDescriptor.h b/BlueBerry/Bundles/org.blueberry.ui.qt.objectinspector/src/internal/berryPluginActivator.h old mode 100755 new mode 100644 similarity index 60% copy from BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryQtIconImageDescriptor.h copy to BlueBerry/Bundles/org.blueberry.ui.qt.objectinspector/src/internal/berryPluginActivator.h index 9afe1a7db5..36edc91068 --- a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryQtIconImageDescriptor.h +++ b/BlueBerry/Bundles/org.blueberry.ui.qt.objectinspector/src/internal/berryPluginActivator.h @@ -1,49 +1,43 @@ /*========================================================================= Program: BlueBerry Platform Language: C++ Date: $Date$ Version: $Revision$ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ -#ifndef BERRYQTICONIMAGEDESCRIPTOR_H_ -#define BERRYQTICONIMAGEDESCRIPTOR_H_ +#ifndef BERRYOBJECTINSPECTORACTIVATOR_H +#define BERRYOBJECTINSPECTORACTIVATOR_H -#include - -class QIcon; +#include namespace berry { -class QtIconImageDescriptor : public ImageDescriptor +class org_blueberry_ui_qt_objectinspector_Activator : + public QObject, public ctkPluginActivator { - -private: - - QIcon* icon; + Q_OBJECT + Q_INTERFACES(ctkPluginActivator) public: - QtIconImageDescriptor(void* img); - - virtual void* CreateImage(bool returnMissingImageOnError = true); - - virtual void DestroyImage(void* img); - - virtual bool operator==(const Object* o) const; + void start(ctkPluginContext* context); + void stop(ctkPluginContext* context); }; +typedef org_blueberry_ui_qt_objectinspector_Activator PluginActivator; + } -#endif /* BERRYQTICONIMAGEDESCRIPTOR_H_ */ +#endif // BERRYOBJECTINSPECTORACTIVATOR_H diff --git a/BlueBerry/Bundles/org.blueberry.ui.qt/CMakeLists.txt b/BlueBerry/Bundles/org.blueberry.ui.qt/CMakeLists.txt index e6d864b0b5..1fdd586264 100644 --- a/BlueBerry/Bundles/org.blueberry.ui.qt/CMakeLists.txt +++ b/BlueBerry/Bundles/org.blueberry.ui.qt/CMakeLists.txt @@ -1,3 +1,5 @@ -MACRO_CREATE_QT_PLUGIN() +PROJECT(org_blueberry_ui_qt) +MACRO_CREATE_CTK_PLUGIN(EXPORT_DIRECTIVE BERRY_UI_QT + EXPORTED_INCLUDE_SUFFIXES src src/application) diff --git a/BlueBerry/Bundles/org.blueberry.ui.qt/META-INF/MANIFEST.MF b/BlueBerry/Bundles/org.blueberry.ui.qt/META-INF/MANIFEST.MF deleted file mode 100644 index 99613ad188..0000000000 --- a/BlueBerry/Bundles/org.blueberry.ui.qt/META-INF/MANIFEST.MF +++ /dev/null @@ -1,7 +0,0 @@ -Manifest-Version: 1.0 -Bundle-Name: BlueBerry Qt User Interface Plugin -Bundle-SymbolicName: org.blueberry.ui.qt -Bundle-Version: 1.0.0 -Bundle-Vendor: DKFZ, Medical and Biological Informatics -Bundle-Activator: berry::QtPluginActivator -Require-Bundle: org.blueberry.ui \ No newline at end of file diff --git a/BlueBerry/Bundles/org.blueberry.ui.qt/files.cmake b/BlueBerry/Bundles/org.blueberry.ui.qt/files.cmake index 2958425fbb..e0307afbf8 100644 --- a/BlueBerry/Bundles/org.blueberry.ui.qt/files.cmake +++ b/BlueBerry/Bundles/org.blueberry.ui.qt/files.cmake @@ -1,100 +1,116 @@ SET(SRC_CPP_FILES berryIQtPreferencePage.cpp berryIQtStyleManager.cpp + berryQCHPluginListener.cpp berryQtAssistantUtil.cpp berryQModelIndexObject.cpp berryQtEditorPart.cpp berryQtItemSelection.cpp berryQtIntroPart.cpp berryQtPreferences.cpp berryQtSelectionProvider.cpp berryQtViewPart.cpp # application application/berryQtWorkbenchAdvisor.cpp ) SET(INTERNAL_CPP_FILES defaultpresentation/berryEmptyTabFolder.cpp defaultpresentation/berryEmptyTabItem.cpp defaultpresentation/berryNativeTabFolder.cpp defaultpresentation/berryNativeTabItem.cpp defaultpresentation/berryQCTabBar.cpp defaultpresentation/berryQtWorkbenchPresentationFactory.cpp util/berryAbstractTabFolder.cpp util/berryLeftToRightTabOrder.cpp util/berryPartInfo.cpp util/berryPresentablePartFolder.cpp util/berryReplaceDragHandler.cpp util/berryTabbedStackPresentation.cpp util/berryTabFolderEvent.cpp berryQtControlWidget.cpp berryQtDisplay.cpp berryQtDnDTweaklet.cpp berryQtFileImageDescriptor.cpp berryQtGlobalEventFilter.cpp berryQtIconImageDescriptor.cpp berryQtImageTweaklet.cpp berryQtMainWindowControl.cpp berryQtMessageDialogTweaklet.cpp berryQtMissingImageDescriptor.cpp berryQtOpenPerspectiveAction.cpp berryQtPerspectiveSwitcher.cpp berryQtPluginActivator.cpp berryQtSafeApplication.cpp berryQtSash.cpp berryQtShell.cpp berryQtShowViewAction.cpp berryQtShowViewDialog.cpp berryQtStyleManager.cpp berryQtStylePreferencePage.cpp berryQtTracker.cpp berryQtWidgetController.cpp berryQtWidgetsTweaklet.cpp berryQtWidgetsTweakletImpl.cpp berryQtWorkbenchPageTweaklet.cpp berryQtWorkbenchTweaklet.cpp berryQtWorkbenchWindow.cpp ) SET(MOC_H_FILES + src/berryQCHPluginListener.h src/berryQtSelectionProvider.h src/internal/defaultpresentation/berryNativeTabFolder.h src/internal/defaultpresentation/berryNativeTabItem.h src/internal/defaultpresentation/berryQCTabBar.h + src/internal/defaultpresentation/berryQtWorkbenchPresentationFactory.h src/internal/berryQtDisplay.h + src/internal/berryQtDnDTweaklet.h src/internal/berryQtGlobalEventFilter.h + src/internal/berryQtImageTweaklet.h src/internal/berryQtMainWindowControl.h + src/internal/berryQtMessageDialogTweaklet.h src/internal/berryQtOpenPerspectiveAction.h src/internal/berryQtPerspectiveSwitcher.h src/internal/berryQtSash.h src/internal/berryQtShowViewAction.h + src/internal/berryQtStyleManager.h src/internal/berryQtStylePreferencePage.h src/internal/berryQtTracker.h + src/internal/berryQtWidgetsTweaklet.h src/internal/berryQtWidgetsTweakletImpl.h + src/internal/berryQtWorkbenchTweaklet.h + src/internal/berryQtWorkbenchPageTweaklet.h + + src/internal/berryQtPluginActivator.h ) SET(UI_FILES src/internal/berryQtShowViewDialog.ui src/internal/berryQtStylePreferencePage.ui src/internal/berryQtStatusPart.ui ) -SET(RES_FILES +SET(QRC_FILES resources/org_blueberry_ui_qt.qrc ) -SET(CPP_FILES manifest.cpp) +SET(CACHED_RESOURCE_FILES + plugin.xml +) + +SET(CPP_FILES ) foreach(file ${SRC_CPP_FILES}) SET(CPP_FILES ${CPP_FILES} src/${file}) endforeach(file ${SRC_CPP_FILES}) foreach(file ${INTERNAL_CPP_FILES}) SET(CPP_FILES ${CPP_FILES} src/internal/${file}) endforeach(file ${INTERNAL_CPP_FILES}) diff --git a/BlueBerry/Bundles/org.blueberry.ui.qt/includes.cmake b/BlueBerry/Bundles/org.blueberry.ui.qt/includes.cmake deleted file mode 100755 index 804f09ce52..0000000000 --- a/BlueBerry/Bundles/org.blueberry.ui.qt/includes.cmake +++ /dev/null @@ -1,3 +0,0 @@ -SET(ADDITIONAL_INCLUDE_DIRECTORIES - src/application -) \ No newline at end of file diff --git a/BlueBerry/Bundles/org.blueberry.ui.qt/manifest.cpp b/BlueBerry/Bundles/org.blueberry.ui.qt/manifest.cpp index 6fad819efb..5f0288d5a7 100644 --- a/BlueBerry/Bundles/org.blueberry.ui.qt/manifest.cpp +++ b/BlueBerry/Bundles/org.blueberry.ui.qt/manifest.cpp @@ -1,74 +1,45 @@ /*========================================================================= Program: BlueBerry Platform Language: C++ Date: $Date$ Version: $Revision$ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #include "Poco/ClassLibrary.h" #include #include "src/internal/berryQtPluginActivator.h" #include "src/internal/berryQtWorkbenchTweaklet.h" #include "src/internal/berryQtWorkbenchPageTweaklet.h" #include "src/internal/berryQtDnDTweaklet.h" #include "src/internal/berryQtWidgetsTweaklet.h" #include "src/internal/berryQtImageTweaklet.h" #include "src/internal/berryQtMessageDialogTweaklet.h" #include "src/internal/defaultpresentation/berryQtWorkbenchPresentationFactory.h" #include "src/internal/berryQtStylePreferencePage.h" //**** Activator **************** POCO_BEGIN_MANIFEST(berry::IBundleActivator) POCO_EXPORT_CLASS(berry::QtPluginActivator) POCO_END_MANIFEST //**** Tweaklets **************** -POCO_BEGIN_NAMED_MANIFEST(berryWorkbenchTweaklet, berry::WorkbenchTweaklet) - POCO_EXPORT_CLASS(berry::QtWorkbenchTweaklet) -POCO_END_MANIFEST - -POCO_BEGIN_NAMED_MANIFEST(berryWorkbenchPageTweaklet, berry::WorkbenchPageTweaklet) - POCO_EXPORT_CLASS(berry::QtWorkbenchPageTweaklet) -POCO_END_MANIFEST - -POCO_BEGIN_NAMED_MANIFEST(berryGuiWidgetsTweaklet, berry::GuiWidgetsTweaklet) - POCO_EXPORT_CLASS(berry::QtWidgetsTweaklet) -POCO_END_MANIFEST - -POCO_BEGIN_NAMED_MANIFEST(berryDnDTweaklet, berry::DnDTweaklet) - POCO_EXPORT_CLASS(berry::QtDnDTweaklet) -POCO_END_MANIFEST - -POCO_BEGIN_NAMED_MANIFEST(berryImageTweaklet, berry::ImageTweaklet) - POCO_EXPORT_CLASS(berry::QtImageTweaklet) -POCO_END_MANIFEST - -POCO_BEGIN_NAMED_MANIFEST(berryMessageDialogTweaklet, berry::MessageDialogTweaklet) - POCO_EXPORT_CLASS(berry::QtMessageDialogTweaklet) -POCO_END_MANIFEST - - -//**** Presentation Factories ********* -POCO_BEGIN_NAMED_MANIFEST(berryIPresentationFactory, berry::IPresentationFactory) - POCO_EXPORT_CLASS(berry::QtWorkbenchPresentationFactory) -POCO_END_MANIFEST //**** Preference Pages ***** POCO_BEGIN_NAMED_MANIFEST(berryIPreferencePage, berry::IPreferencePage) POCO_EXPORT_CLASS(berry::QtStylePreferencePage) POCO_END_MANIFEST diff --git a/BlueBerry/Bundles/org.blueberry.ui.qt/manifest_headers.cmake b/BlueBerry/Bundles/org.blueberry.ui.qt/manifest_headers.cmake new file mode 100644 index 0000000000..0b6525ce0b --- /dev/null +++ b/BlueBerry/Bundles/org.blueberry.ui.qt/manifest_headers.cmake @@ -0,0 +1,6 @@ +set(Plugin-Name "BlueBerry Qt User Interface Plugin") +set(Plugin-Version "1.0.0") +set(Plugin-Vendor "DKFZ, Medical and Biological Informatics") +set(Plugin-ContactAddress "http://www.mitk.org") +set(Require-Plugin org.blueberry.ui) + diff --git a/BlueBerry/Bundles/org.blueberry.ui.qt/src/application/berryQtWorkbenchAdvisor.h b/BlueBerry/Bundles/org.blueberry.ui.qt/src/application/berryQtWorkbenchAdvisor.h index d84aa0e7c0..2f286584d7 100755 --- a/BlueBerry/Bundles/org.blueberry.ui.qt/src/application/berryQtWorkbenchAdvisor.h +++ b/BlueBerry/Bundles/org.blueberry.ui.qt/src/application/berryQtWorkbenchAdvisor.h @@ -1,44 +1,44 @@ /*========================================================================= Program: BlueBerry Platform Language: C++ Date: $Date$ Version: $Revision$ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #ifndef BERRYQTWORKBENCHADVISOR_H_ #define BERRYQTWORKBENCHADVISOR_H_ -#include "../berryUiQtDll.h" +#include #include namespace berry { class BERRY_UI_QT QtWorkbenchAdvisor : public WorkbenchAdvisor { public: /** * Creates the global QApplication object */ void Initialize(IWorkbenchConfigurer::Pointer configurer); bool PreShutdown(); }; } #endif /* BERRYQTWORKBENCHADVISOR_H_ */ diff --git a/BlueBerry/Bundles/org.blueberry.ui.qt/src/berryIQtPreferencePage.h b/BlueBerry/Bundles/org.blueberry.ui.qt/src/berryIQtPreferencePage.h index 7307f42e3b..a85d868851 100644 --- a/BlueBerry/Bundles/org.blueberry.ui.qt/src/berryIQtPreferencePage.h +++ b/BlueBerry/Bundles/org.blueberry.ui.qt/src/berryIQtPreferencePage.h @@ -1,58 +1,58 @@ /*========================================================================= Program: BlueBerry Platform Language: C++ Date: $Date: 2009-01-23 09:44:29 +0100 (Fr, 23 Jan 2009) $ Version: $Revision: 16084 $ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #ifndef BERRYIQTPREFERENCEPAGE_H_ #define BERRYIQTPREFERENCEPAGE_H_ #ifdef __MINGW32__ // We need to include winbase.h here in order to declare // atomic intrinsics like InterlockedIncrement correctly. // Otherwhise, they would be declared wrong within qatomic_windows.h . #include #endif #include #include "berryIPreferencePage.h" -#include "berryUiQtDll.h" +#include namespace berry { /** * \ingroup org_blueberry_ui * */ struct BERRY_UI_QT IQtPreferencePage : public IPreferencePage { berryInterfaceMacro(IQtPreferencePage, berry); virtual void CreateQtControl(QWidget* parent) = 0; virtual QWidget* GetQtControl() const = 0; protected: void CreateControl(void* parent); void* GetControl() const; }; } #endif /*BERRYIQTPREFERENCEPAGE_H_*/ diff --git a/BlueBerry/Bundles/org.blueberry.ui.qt/src/berryIQtStyleManager.h b/BlueBerry/Bundles/org.blueberry.ui.qt/src/berryIQtStyleManager.h index 6bc705befe..6a6fe6433a 100644 --- a/BlueBerry/Bundles/org.blueberry.ui.qt/src/berryIQtStyleManager.h +++ b/BlueBerry/Bundles/org.blueberry.ui.qt/src/berryIQtStyleManager.h @@ -1,87 +1,90 @@ /*========================================================================= Program: BlueBerry Platform Language: C++ Date: $Date$ Version: $Revision$ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #ifndef BERRYIQTSTYLEMANAGER_H_ #define BERRYIQTSTYLEMANAGER_H_ #include #include #include +#include #include -#include "berryUiQtDll.h" +#include namespace berry { struct BERRY_UI_QT IQtStyleManager : public Service { berryInterfaceMacro(IQtStyleManager, berry) struct Style { QString name; QString fileName; Style() {} Style(const QString& name, const QString& fn) : name(name), fileName(fn) {} Style& operator=(const Style& s) { this->name = s.name; this->fileName = s.fileName; return *this; } bool operator<(const Style& s) const { return name < s.name; } bool operator==(const Style& s) const { return name == s.name; } }; static const std::string ID; // = "org.blueberry.service.qtstylemanager"; typedef QList