diff --git a/Documentation/Snippets/CMakeLists.txt b/Documentation/Snippets/CMakeLists.txt deleted file mode 100644 index b7543e01f6..0000000000 --- a/Documentation/Snippets/CMakeLists.txt +++ /dev/null @@ -1,6 +0,0 @@ -if(BUILD_TESTING) - MITK_USE_MODULE(Mitk) - include_directories(${ALL_INCLUDE_DIRECTORIES}) - link_directories(${ALL_LIBRARY_DIRS}) - mitkFunctionCompileSnippets("${CMAKE_CURRENT_SOURCE_DIR}" ${ALL_LIBRARIES}) -endif() diff --git a/Documentation/Snippets/uServices-activator/main.cpp b/Documentation/Snippets/uServices-activator/main.cpp deleted file mode 100644 index 2c92be2050..0000000000 --- a/Documentation/Snippets/uServices-activator/main.cpp +++ /dev/null @@ -1,26 +0,0 @@ -//! [0] -#include -#include - -class MyActivator : public mitk::ModuleActivator -{ - -public: - - void Load(mitk::ModuleContext* context) - { /* register stuff */ } - - - void Unload(mitk::ModuleContext* context) - { /* cleanup */ } - -}; - -MITK_EXPORT_MODULE_ACTIVATOR(mylibname, MyActivator) -//![0] - -int main(int argc, char* argv[]) -{ - MyActivator ma; - return 0; -} diff --git a/Documentation/Snippets/uServices-singleton/SingletonOne.cpp b/Documentation/Snippets/uServices-singleton/SingletonOne.cpp deleted file mode 100644 index ec9ee5f23d..0000000000 --- a/Documentation/Snippets/uServices-singleton/SingletonOne.cpp +++ /dev/null @@ -1,79 +0,0 @@ -#include "SingletonOne.h" - -#include "SingletonTwo.h" - -#include - -#include -#include - -#include - -//![s1] -SingletonOne& SingletonOne::GetInstance() -{ - static SingletonOne instance; - return instance; -} -//![s1] - -SingletonOne::SingletonOne() : a(1) -{ -} - -//![s1d] -SingletonOne::~SingletonOne() -{ - std::cout << "SingletonTwo::b = " << SingletonTwo::GetInstance().b << std::endl; -} -//![s1d] - -//![ss1gi] -SingletonOneService* SingletonOneService::GetInstance() -{ - static mitk::ServiceReference serviceRef; - static mitk::ModuleContext* context = mitk::GetModuleContext(); - - if (!serviceRef) - { - // This is either the first time GetInstance() was called, - // or a SingletonOneService instance has not yet been registered. - serviceRef = context->GetServiceReference(); - } - - if (serviceRef) - { - // We have a valid service reference. It always points to the service - // with the lowest id (usually the one which was registered first). - // This still might return a null pointer, if all SingletonOneService - // instances have been unregistered (during unloading of the library, - // for example). - return context->GetService(serviceRef); - } - else - { - // No SingletonOneService instance was registered yet. - return 0; - } -} -//![ss1gi] - -SingletonOneService::SingletonOneService() - : a(1) -{ - SingletonTwoService* singletonTwoService = SingletonTwoService::GetInstance(); - assert(singletonTwoService != 0); - std::cout << "SingletonTwoService::b = " << singletonTwoService->b << std::endl; -} - -//![ss1d] -SingletonOneService::~SingletonOneService() -{ - SingletonTwoService* singletonTwoService = SingletonTwoService::GetInstance(); - - // The module activator must ensure that a SingletonTwoService instance is - // available during destruction of a SingletonOneService instance. - assert(singletonTwoService != 0); - std::cout << "SingletonTwoService::b = " << singletonTwoService->b << std::endl; -} -//![ss1d] diff --git a/Documentation/Snippets/uServices-singleton/SingletonOne.h b/Documentation/Snippets/uServices-singleton/SingletonOne.h deleted file mode 100644 index 1d862df6fd..0000000000 --- a/Documentation/Snippets/uServices-singleton/SingletonOne.h +++ /dev/null @@ -1,73 +0,0 @@ -#ifndef SINGLETONONE_H -#define SINGLETONONE_H - -#include -#include -#include -#include - -#include - -namespace mitk { class ModuleContext; } - -//![s1] -class SingletonOne -{ -public: - - static SingletonOne& GetInstance(); - - // Just some member - int a; - -private: - - SingletonOne(); - ~SingletonOne(); - - // Disable copy constructor and assignment operator. - SingletonOne(const SingletonOne&); - SingletonOne& operator=(const SingletonOne&); -}; -//![s1] - -class SingletonTwoService; - -//![ss1] -class SingletonOneService : public itk::LightObject -{ -public: - - // This will return a SingletonOneService instance with the - // lowest service id at the time this method was called the first - // time and returned a non-null value (which is usually the instance - // which was registered first). A null-pointer is returned if no - // instance was registered yet. - static SingletonOneService* GetInstance(); - - int a; - -private: - - // Only our module activator class should be able to instantiate - // a SingletonOneService object. - friend class MyActivator; - - // Creates some typedefs - mitkClassMacro(SingletonOneService, itk::LightObject) - - // Creates a static New() method which correct reference counting - itkFactorylessNewMacro(SingletonOneService) - - SingletonOneService(); - ~SingletonOneService(); - - // Disable copy constructor and assignment operator. - SingletonOneService(const SingletonOneService&); - SingletonOneService& operator=(const SingletonOneService&); -}; - -MITK_DECLARE_SERVICE_INTERFACE(SingletonOneService, "org.mitk.snippet.SingletonOneService") -//![ss1] - -#endif // SINGLETONONE_H diff --git a/Documentation/Snippets/uServices-singleton/SingletonTwo.cpp b/Documentation/Snippets/uServices-singleton/SingletonTwo.cpp deleted file mode 100644 index 793605579c..0000000000 --- a/Documentation/Snippets/uServices-singleton/SingletonTwo.cpp +++ /dev/null @@ -1,63 +0,0 @@ -#include "SingletonTwo.h" - -#include "SingletonOne.h" -#include - -#include -#include - - -SingletonTwo& SingletonTwo::GetInstance() -{ - static SingletonTwo instance; - return instance; -} - -SingletonTwo::SingletonTwo() : b(2) -{ - std::cout << "Constructing SingletonTwo" << std::endl; -} - -SingletonTwo::~SingletonTwo() -{ - std::cout << "Deleting SingletonTwo" << std::endl; - std::cout << "SingletonOne::a = " << SingletonOne::GetInstance().a << std::endl; -} - -SingletonTwoService* SingletonTwoService::GetInstance() -{ - static mitk::ServiceReference serviceRef; - static mitk::ModuleContext* context = mitk::GetModuleContext(); - - if (!serviceRef) - { - // This is either the first time GetInstance() was called, - // or a SingletonTwoService instance has not yet been registered. - serviceRef = context->GetServiceReference(); - } - - if (serviceRef) - { - // We have a valid service reference. It always points to the service - // with the lowest id (usually the one which was registered first). - // This still might return a null pointer, if all SingletonTwoService - // instances have been unregistered (during unloading of the library, - // for example). - return context->GetService(serviceRef); - } - else - { - // No SingletonTwoService instance was registered yet. - return 0; - } -} - -SingletonTwoService::SingletonTwoService() : b(2) -{ - std::cout << "Constructing SingletonTwoService" << std::endl; -} - -SingletonTwoService::~SingletonTwoService() -{ - std::cout << "Deleting SingletonTwoService" << std::endl; -} diff --git a/Documentation/Snippets/uServices-singleton/SingletonTwo.h b/Documentation/Snippets/uServices-singleton/SingletonTwo.h deleted file mode 100644 index c7e17fdf0a..0000000000 --- a/Documentation/Snippets/uServices-singleton/SingletonTwo.h +++ /dev/null @@ -1,52 +0,0 @@ -#ifndef SINGLETONTWO_H -#define SINGLETONTWO_H - -#include - -#include -#include - -class SingletonTwo -{ -public: - - static SingletonTwo& GetInstance(); - - int b; - -private: - - SingletonTwo(); - ~SingletonTwo(); - - // Disable copy constructor and assignment operator. - SingletonTwo(const SingletonTwo&); - SingletonTwo& operator=(const SingletonTwo&); -}; - -class SingletonTwoService : public itk::LightObject -{ -public: - - static SingletonTwoService* GetInstance(); - - int b; - -private: - - friend class MyActivator; - - mitkClassMacro(SingletonTwoService, itk::LightObject) - itkFactorylessNewMacro(SingletonTwoService) - - SingletonTwoService(); - ~SingletonTwoService(); - - // Disable copy constructor and assignment operator. - SingletonTwoService(const SingletonTwoService&); - SingletonTwoService& operator=(const SingletonTwoService&); -}; - -MITK_DECLARE_SERVICE_INTERFACE(SingletonTwoService, "org.mitk.snippet.SingletonTwoService") - -#endif // SINGLETONTWO_H diff --git a/Documentation/Snippets/uServices-singleton/files.cmake b/Documentation/Snippets/uServices-singleton/files.cmake deleted file mode 100644 index 15e028e436..0000000000 --- a/Documentation/Snippets/uServices-singleton/files.cmake +++ /dev/null @@ -1,16 +0,0 @@ -set(_init_file ${CMAKE_CURRENT_BINARY_DIR}/uServices_singleton_init.cpp) - -set(MODULE_NAME "uServices_singleton") -set(MODULE_LIBNAME "") -set(MODULE_DEPENDS_STR "Mitk") -set(MODULE_PACKAGE_DEPENDS_STR) -set(MODULE_VERSION) -set(MODULE_QT_BOOL "false") -configure_file(${MITK_SOURCE_DIR}/CMake/mitkModuleInit.cpp ${_init_file} @ONLY) - -set(snippet_src_files - main.cpp - SingletonOne.cpp - SingletonTwo.cpp - ${_init_file} -) diff --git a/Documentation/Snippets/uServices-singleton/main.cpp b/Documentation/Snippets/uServices-singleton/main.cpp deleted file mode 100644 index 13bc54eb67..0000000000 --- a/Documentation/Snippets/uServices-singleton/main.cpp +++ /dev/null @@ -1,65 +0,0 @@ -#include -#include -#include - -#include "SingletonOne.h" -#include "SingletonTwo.h" - -class MyActivator : public mitk::ModuleActivator -{ - -public: - - //![0] - void Load(mitk::ModuleContext* context) - { - // The Load() method of the module activator is called during static - // initialization time of the shared library. - - // First create and register a SingletonTwoService instance. - m_SingletonTwo = SingletonTwoService::New(); - context->RegisterService(m_SingletonTwo); - - // Now the SingletonOneService constructor will get a valid - // SingletonTwoService instance. - m_SingletonOne = SingletonOneService::New(); - m_SingletonOneReg = context->RegisterService(m_SingletonOne); - } - //![0] - - //![1] - void Unload(mitk::ModuleContext* /*context*/) - { - // Services are automatically unregistered during unloading of - // the shared library after the call to Unload(mitk::ModuleContext*) - // has returned. - - // Since SingletonOneService needs a non-null SingletonTwoService - // instance in its destructor, we explicitly unregister and delete the - // SingletonOneService instance here. This way, the SingletonOneService - // destructor will still get a valid SingletonTwoService instance. - m_SingletonOneReg.Unregister(); - m_SingletonOne = 0; - - // For singletonTwoService, we rely on the automatic unregistering - // by the service registry and on automatic deletion due to the - // smart pointer reference counting. You must not delete service instances - // in this method without unregistering them first. - } - //![1] - -private: - - // We use smart pointers for automatic garbage collection - SingletonOneService::Pointer m_SingletonOne; - SingletonTwoService::Pointer m_SingletonTwo; - - mitk::ServiceRegistration m_SingletonOneReg; - -}; - -MITK_EXPORT_MODULE_ACTIVATOR(uServices_singleton, MyActivator) - -int main() -{ -}