00001 /*========================================================================= 00002 00003 Program: Open IGT Link Library 00004 Module: $HeadURL: http://svn.na-mic.org/NAMICSandBox/trunk/OpenIGTLink/Source/igtlCreateObjectFunction.h $ 00005 Language: C++ 00006 Date: $Date: 2008-12-22 19:05:42 -0500 (Mon, 22 Dec 2008) $ 00007 Version: $Revision: 3460 $ 00008 00009 Copyright (c) Insight Software Consortium. All rights reserved. 00010 00011 This software is distributed WITHOUT ANY WARRANTY; without even 00012 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 00013 PURPOSE. See the above copyright notices for more information. 00014 00015 =========================================================================*/ 00016 /*========================================================================= 00017 00018 Program: Insight Segmentation & Registration Toolkit 00019 Module: $RCSfile: itkCreateObjectFunction.h,v $ 00020 Language: C++ 00021 Date: $Date: 2008-12-22 19:05:42 -0500 (Mon, 22 Dec 2008) $ 00022 Version: $Revision: 3460 $ 00023 00024 Copyright (c) Insight Software Consortium. All rights reserved. 00025 See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. 00026 00027 This software is distributed WITHOUT ANY WARRANTY; without even 00028 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 00029 PURPOSE. See the above copyright notices for more information. 00030 00031 =========================================================================*/ 00032 #ifndef __igtlCreateObjectFunction_h 00033 #define __igtlCreateObjectFunction_h 00034 00035 #include "igtlObject.h" 00036 00037 namespace igtl 00038 { 00039 00045 class CreateObjectFunctionBase: public Object 00046 { 00047 public: 00049 typedef CreateObjectFunctionBase Self; 00050 typedef Object Superclass; 00051 typedef SmartPointer<Self> Pointer; 00052 typedef SmartPointer<const Self> ConstPointer; 00053 00056 virtual SmartPointer<LightObject> CreateObject() = 0; 00057 00058 protected: 00059 CreateObjectFunctionBase() {} 00060 ~CreateObjectFunctionBase() {} 00061 00062 private: 00063 CreateObjectFunctionBase(const Self&); //purposely not implemented 00064 void operator=(const Self&); //purposely not implemented 00065 }; 00066 00067 00074 template <class T> 00075 class CreateObjectFunction : public CreateObjectFunctionBase 00076 { 00077 public: 00079 typedef CreateObjectFunction Self; 00080 typedef SmartPointer<Self> Pointer; 00081 00083 igtlFactorylessNewMacro(Self); 00084 LightObject::Pointer CreateObject() { return T::New().GetPointer(); } 00086 00087 protected: 00088 CreateObjectFunction() {} 00089 ~CreateObjectFunction() {} 00090 00091 private: 00092 CreateObjectFunction(const Self&); //purposely not implemented 00093 void operator=(const Self&); //purposely not implemented 00094 }; 00095 00096 } // end namespace igtl 00097 00098 #endif 00099