00001 /*========================================================================= 00002 00003 Program: Insight Segmentation & Registration Toolkit 00004 Module: $RCSfile: itkSpatialObjectFactoryBase.h,v $ 00005 Language: C++ 00006 Date: $Date: 2005/07/05 20:46:17 $ 00007 Version: $Revision: 1.2 $ 00008 00009 Copyright (c) Insight Software Consortium. All rights reserved. 00010 See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. 00011 00012 Portions of this code are covered under the VTK copyright. 00013 See VTKCopyright.txt or http://www.kitware.com/VTKCopyright.htm for details. 00014 00015 This software is distributed WITHOUT ANY WARRANTY; without even 00016 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 00017 PURPOSE. See the above copyright notices for more information. 00018 00019 =========================================================================*/ 00020 #ifndef __itkSpatialObjectFactoryBase_h 00021 #define __itkSpatialObjectFactoryBase_h 00022 00023 #include "itkObjectFactoryBase.h" 00024 00025 namespace itk 00026 { 00031 class SpatialObjectFactoryBase : public ObjectFactoryBase 00032 { 00033 public: 00035 typedef SpatialObjectFactoryBase Self; 00036 typedef ObjectFactoryBase Superclass; 00037 typedef SmartPointer< Self > Pointer; 00038 typedef SmartPointer< const Self > ConstPointer; 00039 00041 virtual const char* GetITKSourceVersion(void) const; 00042 virtual const char* GetDescription(void) const; 00043 00045 itkTypeMacro(SpatialObjectFactoryBase, ObjectFactoryBase); 00046 00048 itkFactorylessNewMacro(Self); 00049 00051 static void RegisterDefaultSpatialObjects(); 00052 00054 static SpatialObjectFactoryBase* GetFactory () 00055 { 00056 if ( m_Factory == 0 ) 00057 { 00058 // Make and register the factory 00059 SpatialObjectFactoryBase::Pointer p = SpatialObjectFactoryBase::New(); 00060 m_Factory = p.GetPointer(); 00061 ObjectFactoryBase::RegisterFactory ( p ); 00062 p->RegisterDefaultSpatialObjects (); 00063 } 00064 return m_Factory; 00065 } 00066 00067 void RegisterSpatialObject(const char* classOverride, 00068 const char* overrideClassName, 00069 const char* description, 00070 bool enableFlag, 00071 CreateObjectFunctionBase* createFunction) 00072 { 00073 this->RegisterOverride ( classOverride, overrideClassName, description, enableFlag, createFunction ); 00074 } 00075 00076 protected: 00077 SpatialObjectFactoryBase(); 00078 virtual ~SpatialObjectFactoryBase(); 00079 00080 private: 00081 SpatialObjectFactoryBase(const Self&); //purposely not implemented 00082 void operator=(const Self&); //purposely not implemented 00083 static SpatialObjectFactoryBase* m_Factory; 00084 }; 00085 } // end namespace itk 00086 00087 #endif