00001 /*========================================================================= 00002 00003 Program: Insight Segmentation & Registration Toolkit 00004 Module: $RCSfile: itkCreateObjectFunction.h,v $ 00005 Language: C++ 00006 Date: $Date: 2002/02/14 22:50:42 $ 00007 Version: $Revision: 1.21 $ 00008 00009 Copyright (c) 2002 Insight Consortium. All rights reserved. 00010 See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. 00011 00012 This software is distributed WITHOUT ANY WARRANTY; without even 00013 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 00014 PURPOSE. See the above copyright notices for more information. 00015 00016 =========================================================================*/ 00017 #ifndef __itkCreateObjectFunction_h 00018 #define __itkCreateObjectFunction_h 00019 00020 #include "itkObject.h" 00021 00022 namespace itk 00023 { 00024 00030 class CreateObjectFunctionBase: public Object 00031 { 00032 public: 00034 typedef CreateObjectFunctionBase Self; 00035 typedef Object Superclass; 00036 typedef SmartPointer<Self> Pointer; 00037 typedef SmartPointer<const Self> ConstPointer; 00038 00041 virtual SmartPointer<LightObject> CreateObject() = 0; 00042 00043 protected: 00044 CreateObjectFunctionBase() {} 00045 ~CreateObjectFunctionBase() {} 00046 00047 private: 00048 CreateObjectFunctionBase(const Self&); //purposely not implemented 00049 void operator=(const Self&); //purposely not implemented 00050 }; 00051 00052 00059 template <class T> 00060 class CreateObjectFunction : public CreateObjectFunctionBase 00061 { 00062 public: 00064 typedef CreateObjectFunction Self; 00065 typedef SmartPointer<Self> Pointer; 00066 00068 itkFactorylessNewMacro(Self); 00069 LightObject::Pointer CreateObject() { return T::New().GetPointer(); } 00070 00071 protected: 00072 CreateObjectFunction() {} 00073 ~CreateObjectFunction() {} 00074 00075 private: 00076 CreateObjectFunction(const Self&); //purposely not implemented 00077 void operator=(const Self&); //purposely not implemented 00078 }; 00079 00080 } // end namespace itk 00081 00082 #endif 00083 00084