diff --git a/Modules/MitkExt/Interactions/mitkToolFactoryMacro.h b/Modules/MitkExt/Interactions/mitkToolFactoryMacro.h index 7cf8737255..8b81a2dbed 100644 --- a/Modules/MitkExt/Interactions/mitkToolFactoryMacro.h +++ b/Modules/MitkExt/Interactions/mitkToolFactoryMacro.h @@ -1,222 +1,244 @@ /*========================================================================= 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/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 MITK_TOOL_MACRO(EXPORT_SPEC, CLASS_NAME, DESCRIPTION) \ \ class EXPORT_SPEC CLASS_NAME ## Factory : public ::itk::ObjectFactoryBase \ { \ public: \ \ /* ITK typedefs */ \ typedef CLASS_NAME ## Factory Self; \ typedef itk::ObjectFactoryBase Superclass; \ typedef itk::SmartPointer Pointer; \ typedef itk::SmartPointer ConstPointer; \ \ /* Methods from ObjectFactoryBase */ \ virtual const char* GetITKSourceVersion() const \ { \ return ITK_SOURCE_VERSION; \ }\ \ virtual const char* GetDescription() const \ { \ return DESCRIPTION; \ }\ \ /* Method for class instantiation. */ \ itkFactorylessNewMacro(Self); \ \ /* Run-time type information (and related methods). */ \ itkTypeMacro(CLASS_NAME ## Factory, itkObjectFactoryBase); \ \ /* Register one factory of this type */ \ static void RegisterOneFactory() \ { \ CLASS_NAME ## Factory::Pointer CLASS_NAME ## Factory = CLASS_NAME ## Factory::New(); \ itk::ObjectFactoryBase::RegisterFactory(CLASS_NAME ## Factory); \ } \ \ protected: \ \ CLASS_NAME ## Factory() \ { \ itk::ObjectFactoryBase::RegisterOverride("mitkTool", \ #CLASS_NAME, \ DESCRIPTION, \ 1, \ itk::CreateObjectFunction::New()); \ } \ \ ~CLASS_NAME ## Factory() \ { \ } \ \ private: \ \ CLASS_NAME ## Factory(const Self&); /* purposely not implemented */ \ void operator=(const Self&); /* purposely not implemented */ \ \ }; \ \ class CLASS_NAME ## RegistrationMethod \ { \ public: \ \ CLASS_NAME ## RegistrationMethod() \ { \ /*MITK_INFO("tools") << "Registered " #CLASS_NAME; */ \ - itk::ObjectFactoryBase::RegisterFactory( CLASS_NAME ## Factory::New() ); \ + m_Factory = CLASS_NAME ## Factory::New(); \ + itk::ObjectFactoryBase::RegisterFactory( m_Factory ); \ } \ + \ + ~CLASS_NAME ## RegistrationMethod() \ + { \ + /*MITK_INFO("tools") << "UnRegistered " #CLASS_NAME; */ \ + itk::ObjectFactoryBase::UnRegisterFactory( m_Factory ); \ + } \ + \ + private: \ + \ + CLASS_NAME ## Factory::Pointer m_Factory; \ }; \ \ static mitk::CLASS_NAME ## RegistrationMethod somestaticinitializer_ ## CLASS_NAME ; #define MITK_DERIVED_SM_TOOL_MACRO(EXPORT_SPEC, BASE_CLASS, CLASS_NAME, DESCRIPTION) \ \ class EXPORT_SPEC CLASS_NAME ## Tool : public BASE_CLASS \ { \ public: \ \ typedef CLASS_NAME ## Tool Self; \ typedef BASE_CLASS Superclass; \ typedef itk::SmartPointer Pointer; \ typedef itk::SmartPointer ConstPointer; \ \ itkNewMacro(CLASS_NAME ## Tool); \ \ protected: \ \ CLASS_NAME ## Tool() \ { \ m_SegmentationGenerator = CLASS_NAME::New(); \ } \ \ void RegisterProgressObserver() \ { \ itk::ReceptorMemberCommand< CLASS_NAME ## Tool >::Pointer command = itk::ReceptorMemberCommand< CLASS_NAME ## Tool >::New(); \ command->SetCallbackFunction(this, &CLASS_NAME ## Tool::OnProgressEvent); \ m_SegmentationGenerator->AddSegmentationProgressObserver< CLASS_NAME ## Tool >( command ); \ } \ \ void RegisterFinishedSegmentationObserver() \ { \ itk::ReceptorMemberCommand< CLASS_NAME ## Tool >::Pointer command = itk::ReceptorMemberCommand< CLASS_NAME ## Tool >::New(); \ command->SetCallbackFunction(this, &CLASS_NAME ## Tool::OnSegmentationFinished); \ m_SegmentationGenerator->AddSegmentationFinishedObserver< CLASS_NAME ## Tool >( command ); \ } \ \ ~CLASS_NAME ## Tool() \ { \ } \ }; \ MITK_TOOL_MACRO(EXPORT_SPEC, CLASS_NAME ## Tool, DESCRIPTION); /* GUI classes are _not_ exported! */ #define MITK_TOOL_GUI_MACRO(EXPORT_SPEC, CLASS_NAME, DESCRIPTION) \ \ class EXPORT_SPEC CLASS_NAME ## Factory : public ::itk::ObjectFactoryBase \ { \ public: \ \ /* ITK typedefs */ \ typedef CLASS_NAME ## Factory Self; \ typedef itk::ObjectFactoryBase Superclass; \ typedef itk::SmartPointer Pointer; \ typedef itk::SmartPointer ConstPointer; \ \ /* Methods from ObjectFactoryBase */ \ virtual const char* GetITKSourceVersion() const \ { \ return ITK_SOURCE_VERSION; \ }\ \ virtual const char* GetDescription() const \ { \ return DESCRIPTION; \ }\ \ /* Method for class instantiation. */ \ itkFactorylessNewMacro(Self); \ \ /* Run-time type information (and related methods). */ \ itkTypeMacro(CLASS_NAME ## Factory, itkObjectFactoryBase); \ \ /* Register one factory of this type */ \ static void RegisterOneFactory() \ { \ CLASS_NAME ## Factory::Pointer CLASS_NAME ## Factory = CLASS_NAME ## Factory::New(); \ itk::ObjectFactoryBase::RegisterFactory(CLASS_NAME ## Factory); \ } \ \ protected: \ \ CLASS_NAME ## Factory() \ { \ itk::ObjectFactoryBase::RegisterOverride(#CLASS_NAME, \ #CLASS_NAME, \ DESCRIPTION, \ 1, \ itk::CreateObjectFunction::New()); \ } \ \ ~CLASS_NAME ## Factory() \ { \ } \ \ private: \ \ CLASS_NAME ## Factory(const Self&); /* purposely not implemented */ \ void operator=(const Self&); /* purposely not implemented */ \ \ }; \ \ class CLASS_NAME ## RegistrationMethod \ { \ public: \ \ CLASS_NAME ## RegistrationMethod() \ { \ /*MITK_INFO("tools") << "Registered " #CLASS_NAME; */ \ - itk::ObjectFactoryBase::RegisterFactory( CLASS_NAME ## Factory::New() ); \ + m_Factory = CLASS_NAME ## Factory::New(); \ + itk::ObjectFactoryBase::RegisterFactory( m_Factory ); \ } \ + \ + ~CLASS_NAME ## RegistrationMethod() \ + { \ + /*MITK_INFO("tools") << "UnRegistered " #CLASS_NAME; */ \ + itk::ObjectFactoryBase::UnRegisterFactory( m_Factory ); \ + } \ + \ + private: \ + \ + CLASS_NAME ## Factory::Pointer m_Factory; \ }; \ \ static CLASS_NAME ## RegistrationMethod somestaticinitializer_ ## CLASS_NAME ; #define MITK_EXTERNAL_TOOL_GUI_HEADER_MACRO(EXPORT_SPEC, CLASS_NAME, DESCRIPTION) \ extern "C" { \ EXPORT_SPEC itk::ObjectFactoryBase* itkLoad(); \ } #define MITK_EXTERNAL_TOOL_GUI_CPP_MACRO(EXPORT_SPEC, CLASS_NAME, DESCRIPTION) \ MITK_TOOL_GUI_MACRO(EXPORT_SPEC, CLASS_NAME, DESCRIPTION) \ extern "C" { \ EXPORT_SPEC itk::ObjectFactoryBase* itkLoad() { \ static CLASS_NAME ## Factory::Pointer p = CLASS_NAME ## Factory::New(); \ return p; \ } \ } diff --git a/Modules/SceneSerializationBase/mitkSerializerMacros.h b/Modules/SceneSerializationBase/mitkSerializerMacros.h index 2582694143..e185035789 100644 --- a/Modules/SceneSerializationBase/mitkSerializerMacros.h +++ b/Modules/SceneSerializationBase/mitkSerializerMacros.h @@ -1,96 +1,107 @@ /*========================================================================= Program: Medical Imaging & Interaction Toolkit Language: C++ Date: $Date: 2009-07-14 19:11:20 +0200 (Tue, 14 Jul 2009) $ Version: $Revision: 18127 $ 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 #define MITK_REGISTER_SERIALIZER(classname) \ \ namespace mitk \ { \ \ class classname ## Factory : public ::itk::ObjectFactoryBase \ { \ public: \ \ /* ITK typedefs */ \ typedef classname ## Factory Self; \ typedef itk::ObjectFactoryBase Superclass; \ typedef itk::SmartPointer Pointer; \ typedef itk::SmartPointer ConstPointer; \ \ /* Methods from ObjectFactoryBase */ \ virtual const char* GetITKSourceVersion() const \ { \ return ITK_SOURCE_VERSION; \ } \ \ virtual const char* GetDescription() const \ { \ return "Generated factory for " #classname; \ } \ \ /* Method for class instantiation. */ \ itkFactorylessNewMacro(Self); \ \ /* Run-time type information (and related methods). */ \ itkTypeMacro(classname ## Factory, itkObjectFactoryBase); \ \ /* Register one factory of this type */ \ static void RegisterOneFactory() \ { \ classname ## Factory::Pointer factory = classname ## Factory::New(); \ itk::ObjectFactoryBase::RegisterFactory(factory); \ } \ \ protected: \ \ classname ## Factory() \ { \ itk::ObjectFactoryBase::RegisterOverride(#classname, \ #classname, \ "Generated factory for " #classname, \ 1, \ itk::CreateObjectFunction::New()); \ } \ \ ~classname ## Factory() \ { \ } \ \ private: \ \ classname ## Factory(const Self&); /* purposely not implemented */ \ void operator=(const Self&); /* purposely not implemented */ \ \ }; \ \ \ \ class classname ## RegistrationMethod \ { \ public: \ \ classname ## RegistrationMethod() \ { \ - itk::ObjectFactoryBase::RegisterFactory( classname ## Factory::New() ); \ + m_Factory = classname ## Factory::New(); \ + itk::ObjectFactoryBase::RegisterFactory( m_Factory ); \ } \ + \ + ~classname ## RegistrationMethod() \ + { \ + itk::ObjectFactoryBase::UnRegisterFactory( m_Factory ); \ + } \ + \ + private: \ + \ + classname ## Factory::Pointer m_Factory; \ + \ }; \ } \ \ static mitk::classname ## RegistrationMethod somestaticinitializer_ ## classname ;