Medical Imaging Interaction Toolkit  2018.4.99-389bf124
Medical Imaging Interaction Toolkit
mitk::BaseApplication Class Reference

#include <mitkBaseApplication.h>

Inheritance diagram for mitk::BaseApplication:
Collaboration diagram for mitk::BaseApplication:

Public Member Functions

 BaseApplication (int argc, char **argv)
 
 ~BaseApplication () override
 
void initializeQt ()
 
int run () override
 
void printHelp (const std::string &name, const std::string &value)
 
void setApplicationName (const QString &name)
 
QString getApplicationName () const
 
void setOrganizationName (const QString &name)
 
QString getOrganizationName () const
 
void setOrganizationDomain (const QString &name)
 
QString getOrganizationDomain () const
 
void setSingleMode (bool singleMode)
 
bool getSingleMode () const
 
void setSafeMode (bool safeMode)
 
bool getSafeMode () const
 
void setPreloadLibraries (const QStringList &libraryBaseNames)
 
QStringList getPreloadLibraries () const
 
void setProvisioningFilePath (const QString &filePath)
 
QString getProvisioningFilePath () const
 
void setProperty (const QString &property, const QVariant &value)
 
QVariant getProperty (const QString &property) const
 
void installTranslator (QTranslator *)
 
bool isRunning ()
 
void sendMessage (const QByteArray)
 

Static Public Attributes

static const QString ARG_APPLICATION
 
static const QString ARG_CLEAN
 
static const QString ARG_CONSOLELOG
 
static const QString ARG_DEBUG
 
static const QString ARG_FORCE_PLUGIN_INSTALL
 
static const QString ARG_HOME
 
static const QString ARG_NEWINSTANCE
 
static const QString ARG_NO_LAZY_REGISTRY_CACHE_LOADING
 
static const QString ARG_NO_REGISTRY_CACHE
 
static const QString ARG_PLUGIN_CACHE
 
static const QString ARG_PLUGIN_DIRS
 
static const QString ARG_PRELOAD_LIBRARY
 
static const QString ARG_PRODUCT
 
static const QString ARG_PROVISIONING
 
static const QString ARG_REGISTRY_MULTI_LANGUAGE
 
static const QString ARG_SPLASH_IMAGE
 
static const QString ARG_STORAGE_DIR
 
static const QString ARG_XARGS
 
static const QString PROP_APPLICATION
 
static const QString PROP_FORCE_PLUGIN_INSTALL
 
static const QString PROP_NEWINSTANCE
 
static const QString PROP_NO_LAZY_REGISTRY_CACHE_LOADING
 
static const QString PROP_NO_REGISTRY_CACHE
 
static const QString PROP_PRODUCT
 
static const QString PROP_REGISTRY_MULTI_LANGUAGE
 

Protected Member Functions

void initialize (Poco::Util::Application &self) override
 
void uninitialize () override
 
int getArgc () const
 
char ** getArgv () const
 
virtual QString getCTKFrameworkStorageDir () const
 
virtual void initializeCppMicroServices ()
 
virtual QCoreApplication * getQApplication () const
 
virtual void initializeLibraryPaths ()
 
int main (const std::vector< std::string > &args) override
 
void defineOptions (Poco::Util::OptionSet &options) override
 
QSharedPointer< ctkPluginFramework > getFramework () const
 
ctkPluginContext * getFrameworkContext () const
 
QHash< QString, QVariant > getFrameworkProperties () const
 
void initializeSplashScreen (QCoreApplication *application) const
 

Detailed Description

A utility class for starting BlueBerry applications.

In the simplest case, create an instance of this class and call run(). This will launch a CTK plugin framework instance and execute the default application registered by a plug-in via the org.blueberry.osgi.applications extension point.

This class contains many convenience methods to:

  • Put the application in {safe mode} which catches unhandled exceptions thrown in the Qt event loop and displays an error message.
  • Put the application in {single mode} which by default sends the command line arguments to an already running instance of the same application instead of creating a second instance.
  • Add a list of library names which should be pre-loaded at application start-up, e.g. to speed up the initial launch during the caching process of the plug-in meta-data.
  • Set a custom provisioning file to start a specific set of CTK plug-ins during application start-up.
  • Set and get CTK plugin framework properties

The behavior can further be customized by deriving from BaseApplication and overriding specific methods, such as:

A simple but complete example: #include <mitkBaseApplication.h>

int main(int argc, char* argv[]) { mitk::BaseApplication app(argc, argv); app.setApplicationName("MyApp"); app.setOrganizationName("MyOrganization");

// Run the workbench return app.run(); }

Definition at line 75 of file mitkBaseApplication.h.

Constructor & Destructor Documentation

◆ BaseApplication()

mitk::BaseApplication::BaseApplication ( int  argc,
char **  argv 
)

Definition at line 326 of file mitkBaseApplication.cpp.

◆ ~BaseApplication()

mitk::BaseApplication::~BaseApplication ( )
override

Definition at line 332 of file mitkBaseApplication.cpp.

Member Function Documentation

◆ defineOptions()

void mitk::BaseApplication::defineOptions ( Poco::Util::OptionSet &  options)
overrideprotected

◆ getApplicationName()

QString mitk::BaseApplication::getApplicationName ( ) const

Definition at line 355 of file mitkBaseApplication.cpp.

Referenced by getCTKFrameworkStorageDir(), and initializeQt().

◆ getArgc()

int mitk::BaseApplication::getArgc ( ) const
protected

Definition at line 581 of file mitkBaseApplication.cpp.

◆ getArgv()

char ** mitk::BaseApplication::getArgv ( ) const
protected

Definition at line 586 of file mitkBaseApplication.cpp.

◆ getCTKFrameworkStorageDir()

QString mitk::BaseApplication::getCTKFrameworkStorageDir ( ) const
protectedvirtual

Get the framework storage directory for the CTK plugin framework. This method is called in the initialize(Poco::Util::Application&) method. It must not be called without a QCoreApplications instance.

Returns
The CTK Plugin Framework storage directory.

Definition at line 591 of file mitkBaseApplication.cpp.

References ARG_NEWINSTANCE, getApplicationName(), getOrganizationName(), getSingleMode(), and qHash().

Referenced by initialize().

◆ getFramework()

QSharedPointer< ctkPluginFramework > mitk::BaseApplication::getFramework ( ) const
protected

Definition at line 773 of file mitkBaseApplication.cpp.

Referenced by getFrameworkContext(), and uninitialize().

◆ getFrameworkContext()

ctkPluginContext * mitk::BaseApplication::getFrameworkContext ( ) const
protected

Definition at line 778 of file mitkBaseApplication.cpp.

References framework, and getFramework().

◆ getFrameworkProperties()

QHash< QString, QVariant > mitk::BaseApplication::getFrameworkProperties ( ) const
protected

Get the initial properties for the CTK plugin framework.

The returned map contains the initial framework properties for initializing the CTK plugin framework. The value of specific properties may change at runtime and differ from the initial value.

Returns
The initial CTK Plugin Framework properties.

Definition at line 808 of file mitkBaseApplication.cpp.

◆ getOrganizationDomain()

QString mitk::BaseApplication::getOrganizationDomain ( ) const

Definition at line 385 of file mitkBaseApplication.cpp.

Referenced by initializeQt().

◆ getOrganizationName()

QString mitk::BaseApplication::getOrganizationName ( ) const

Definition at line 370 of file mitkBaseApplication.cpp.

Referenced by getCTKFrameworkStorageDir(), and initializeQt().

◆ getPreloadLibraries()

QStringList mitk::BaseApplication::getPreloadLibraries ( ) const

Get the list of library base names which should be pre-loaded.

Returns
A list of pre-loaded libraries.

Definition at line 427 of file mitkBaseApplication.cpp.

Referenced by initialize().

◆ getProperty()

QVariant mitk::BaseApplication::getProperty ( const QString &  property) const

Definition at line 824 of file mitkBaseApplication.cpp.

Referenced by initializeCppMicroServices().

◆ getProvisioningFilePath()

QString mitk::BaseApplication::getProvisioningFilePath ( ) const

Get the file path to the provisioning file.

Returns
The provisioning file path.

Definition at line 437 of file mitkBaseApplication.cpp.

Referenced by initialize().

◆ getQApplication()

QCoreApplication * mitk::BaseApplication::getQApplication ( ) const
protectedvirtual

Get the QCoreApplication object.

This method is called in the initialize(Poco::Util::Application&) method and must create a QCoreApplication instance if the global qApp variable is not initialized yet.

Returns
The current QCoreApplication instance. This method never returns null.

Definition at line 630 of file mitkBaseApplication.cpp.

References getSingleMode().

Referenced by initializeQt(), installTranslator(), isRunning(), and sendMessage().

◆ getSafeMode()

bool mitk::BaseApplication::getSafeMode ( ) const

Definition at line 417 of file mitkBaseApplication.cpp.

◆ getSingleMode()

bool mitk::BaseApplication::getSingleMode ( ) const

◆ initialize()

void mitk::BaseApplication::initialize ( Poco::Util::Application &  self)
overrideprotected

◆ initializeCppMicroServices()

void mitk::BaseApplication::initializeCppMicroServices ( )
protectedvirtual

Initialize the CppMicroServices library.

The default implementation set the CppMicroServices storage path to the current ctkPluginConstants::FRAMEWORK_STORAGE property value.

This method is called in the initialize(Poco::Util::Application&) after the CTK Plugin Framework storage directory property was set.

Definition at line 622 of file mitkBaseApplication.cpp.

References getProperty(), and us::ModuleSettings::SetStoragePath().

◆ initializeLibraryPaths()

void mitk::BaseApplication::initializeLibraryPaths ( )
protectedvirtual

Add plugin library search paths to the CTK Plugin Framework.

This method is called in the nitialize(Poco::Util::Application&) method after getQApplication() was called.

Definition at line 654 of file mitkBaseApplication.cpp.

◆ initializeQt()

void mitk::BaseApplication::initializeQt ( )

Initialize the Qt library such that a QCoreApplication instance is available and e.g. Qt widgets can be created.

This is usually not called directly by the user.

Definition at line 491 of file mitkBaseApplication.cpp.

References getApplicationName(), getOrganizationDomain(), getOrganizationName(), getQApplication(), setApplicationName(), setOrganizationDomain(), and setOrganizationName().

Referenced by initialize(), and main().

◆ initializeSplashScreen()

void mitk::BaseApplication::initializeSplashScreen ( QCoreApplication *  application) const
protected

Definition at line 787 of file mitkBaseApplication.cpp.

References ARG_SPLASH_IMAGE.

Referenced by initialize().

◆ installTranslator()

void mitk::BaseApplication::installTranslator ( QTranslator *  translator)

Definition at line 829 of file mitkBaseApplication.cpp.

References getQApplication().

◆ isRunning()

bool mitk::BaseApplication::isRunning ( )

Definition at line 834 of file mitkBaseApplication.cpp.

References getQApplication(), and mitkThrow.

◆ main()

int mitk::BaseApplication::main ( const std::vector< std::string > &  args)
overrideprotected

Runs the application for which the platform was started. The platform must be running.

The given argument is passed to the application being run. If it is an invalid QVariant then the command line arguments used in starting the platform, and not consumed by the platform code, are passed to the application as a QStringList.

Parameters
argumentthe argument passed to the application. May be invalid
Returns
the result of running the application
Exceptions
std::exceptionif anything goes wrong

Definition at line 685 of file mitkBaseApplication.cpp.

◆ printHelp()

void mitk::BaseApplication::printHelp ( const std::string &  name,
const std::string &  value 
)

Definition at line 337 of file mitkBaseApplication.cpp.

Referenced by defineOptions().

◆ run()

int mitk::BaseApplication::run ( )
override

Launches the BlueBerry framework and runs the default application or the one specified in the PROP_APPLICATION framework property.

Returns
The return code of the application after it was shut down.

Definition at line 813 of file mitkBaseApplication.cpp.

Referenced by main().

◆ sendMessage()

void mitk::BaseApplication::sendMessage ( const QByteArray  msg)

Definition at line 844 of file mitkBaseApplication.cpp.

References getQApplication(), and mitkThrow.

◆ setApplicationName()

void mitk::BaseApplication::setApplicationName ( const QString &  name)

Set the application name. Same as QCoreApplication::setApplicationName.

Parameters
nameThe application name.

Definition at line 347 of file mitkBaseApplication.cpp.

Referenced by initializeQt(), and main().

◆ setOrganizationDomain()

void mitk::BaseApplication::setOrganizationDomain ( const QString &  name)

Set the organization domain. Same as QCoreApplication::setOrganizationDomain.

Parameters
nameThe organization domain.

Definition at line 377 of file mitkBaseApplication.cpp.

Referenced by initializeQt().

◆ setOrganizationName()

void mitk::BaseApplication::setOrganizationName ( const QString &  name)

Set the organization name. Same as QCoreApplication::setOrganizationName.

Parameters
nameThe organization name.

Definition at line 362 of file mitkBaseApplication.cpp.

Referenced by initializeQt(), and main().

◆ setPreloadLibraries()

void mitk::BaseApplication::setPreloadLibraries ( const QStringList &  libraryBaseNames)

Set a list of library names or absoulte file paths which should be loaded at application start-up. The name and file path may contain a library version appended at the end and separated by a '$' charactger.

For example liborg_mitk_gui_qt_common$1.0. Platform specific suffixes are appended automatically.

Parameters
libraryBaseNamesA list of library base names.

Definition at line 422 of file mitkBaseApplication.cpp.

Referenced by main().

◆ setProperty()

void mitk::BaseApplication::setProperty ( const QString &  property,
const QVariant &  value 
)

Definition at line 819 of file mitkBaseApplication.cpp.

Referenced by main().

◆ setProvisioningFilePath()

void mitk::BaseApplication::setProvisioningFilePath ( const QString &  filePath)

Set the path to the provisioning file.

By default a provisioning file located in the same directory as the executable and named <executable>.provisioning is loaded if it exists. To disable parsing of provisioning files, use an empty string as the argument. Use a null QString (QString::null) to reset to the default behaviour.

Parameters
filePathAn absolute file path to the provisioning file.

Definition at line 432 of file mitkBaseApplication.cpp.

Referenced by main().

◆ setSafeMode()

void mitk::BaseApplication::setSafeMode ( bool  safeMode)

Put the application in safe mode, catching exceptions from the Qt event loop.

Parameters
safeMode

Definition at line 405 of file mitkBaseApplication.cpp.

References getSingleMode().

◆ setSingleMode()

void mitk::BaseApplication::setSingleMode ( bool  singleMode)

Put the application in single mode, which by default only allows a single instance of the application to be created.

Calling this method after run() has been called has no effect.

Parameters
singleMode

Definition at line 392 of file mitkBaseApplication.cpp.

Referenced by main().

◆ uninitialize()

void mitk::BaseApplication::uninitialize ( )
overrideprotected

Definition at line 567 of file mitkBaseApplication.cpp.

References getFramework().

Member Data Documentation

◆ ARG_APPLICATION

const QString mitk::BaseApplication::ARG_APPLICATION
static

Definition at line 80 of file mitkBaseApplication.h.

Referenced by defineOptions().

◆ ARG_CLEAN

const QString mitk::BaseApplication::ARG_CLEAN
static

Definition at line 81 of file mitkBaseApplication.h.

Referenced by defineOptions().

◆ ARG_CONSOLELOG

const QString mitk::BaseApplication::ARG_CONSOLELOG
static

Definition at line 82 of file mitkBaseApplication.h.

Referenced by defineOptions().

◆ ARG_DEBUG

const QString mitk::BaseApplication::ARG_DEBUG
static

Definition at line 83 of file mitkBaseApplication.h.

Referenced by defineOptions().

◆ ARG_FORCE_PLUGIN_INSTALL

const QString mitk::BaseApplication::ARG_FORCE_PLUGIN_INSTALL
static

Definition at line 84 of file mitkBaseApplication.h.

Referenced by defineOptions().

◆ ARG_HOME

const QString mitk::BaseApplication::ARG_HOME
static

Definition at line 85 of file mitkBaseApplication.h.

◆ ARG_NEWINSTANCE

const QString mitk::BaseApplication::ARG_NEWINSTANCE
static

Definition at line 86 of file mitkBaseApplication.h.

Referenced by defineOptions(), and getCTKFrameworkStorageDir().

◆ ARG_NO_LAZY_REGISTRY_CACHE_LOADING

const QString mitk::BaseApplication::ARG_NO_LAZY_REGISTRY_CACHE_LOADING
static

Definition at line 87 of file mitkBaseApplication.h.

Referenced by defineOptions().

◆ ARG_NO_REGISTRY_CACHE

const QString mitk::BaseApplication::ARG_NO_REGISTRY_CACHE
static

Definition at line 88 of file mitkBaseApplication.h.

Referenced by defineOptions().

◆ ARG_PLUGIN_CACHE

const QString mitk::BaseApplication::ARG_PLUGIN_CACHE
static

Definition at line 89 of file mitkBaseApplication.h.

◆ ARG_PLUGIN_DIRS

const QString mitk::BaseApplication::ARG_PLUGIN_DIRS
static

Definition at line 90 of file mitkBaseApplication.h.

◆ ARG_PRELOAD_LIBRARY

const QString mitk::BaseApplication::ARG_PRELOAD_LIBRARY
static

Definition at line 91 of file mitkBaseApplication.h.

Referenced by defineOptions().

◆ ARG_PRODUCT

const QString mitk::BaseApplication::ARG_PRODUCT
static

Definition at line 92 of file mitkBaseApplication.h.

Referenced by defineOptions().

◆ ARG_PROVISIONING

const QString mitk::BaseApplication::ARG_PROVISIONING
static

Definition at line 93 of file mitkBaseApplication.h.

Referenced by defineOptions().

◆ ARG_REGISTRY_MULTI_LANGUAGE

const QString mitk::BaseApplication::ARG_REGISTRY_MULTI_LANGUAGE
static

Definition at line 94 of file mitkBaseApplication.h.

Referenced by defineOptions().

◆ ARG_SPLASH_IMAGE

const QString mitk::BaseApplication::ARG_SPLASH_IMAGE
static

Definition at line 95 of file mitkBaseApplication.h.

Referenced by defineOptions(), and initializeSplashScreen().

◆ ARG_STORAGE_DIR

const QString mitk::BaseApplication::ARG_STORAGE_DIR
static

Definition at line 96 of file mitkBaseApplication.h.

Referenced by defineOptions().

◆ ARG_XARGS

const QString mitk::BaseApplication::ARG_XARGS
static

Definition at line 97 of file mitkBaseApplication.h.

Referenced by defineOptions().

◆ PROP_APPLICATION

const QString mitk::BaseApplication::PROP_APPLICATION
static

Definition at line 101 of file mitkBaseApplication.h.

Referenced by defineOptions(), and main().

◆ PROP_FORCE_PLUGIN_INSTALL

const QString mitk::BaseApplication::PROP_FORCE_PLUGIN_INSTALL
static

Definition at line 102 of file mitkBaseApplication.h.

◆ PROP_NEWINSTANCE

const QString mitk::BaseApplication::PROP_NEWINSTANCE
static

Definition at line 103 of file mitkBaseApplication.h.

◆ PROP_NO_LAZY_REGISTRY_CACHE_LOADING

const QString mitk::BaseApplication::PROP_NO_LAZY_REGISTRY_CACHE_LOADING
static

Definition at line 104 of file mitkBaseApplication.h.

◆ PROP_NO_REGISTRY_CACHE

const QString mitk::BaseApplication::PROP_NO_REGISTRY_CACHE
static

Definition at line 105 of file mitkBaseApplication.h.

◆ PROP_PRODUCT

const QString mitk::BaseApplication::PROP_PRODUCT
static

Definition at line 106 of file mitkBaseApplication.h.

Referenced by defineOptions(), and main().

◆ PROP_REGISTRY_MULTI_LANGUAGE

const QString mitk::BaseApplication::PROP_REGISTRY_MULTI_LANGUAGE
static

Definition at line 107 of file mitkBaseApplication.h.


The documentation for this class was generated from the following files: