ITK
4.1.0
Insight Segmentation and Registration Toolkit
|
00001 /*========================================================================= 00002 * 00003 * Copyright Insight Software Consortium 00004 * 00005 * Licensed under the Apache License, Version 2.0 (the "License"); 00006 * you may not use this file except in compliance with the License. 00007 * You may obtain a copy of the License at 00008 * 00009 * http://www.apache.org/licenses/LICENSE-2.0.txt 00010 * 00011 * Unless required by applicable law or agreed to in writing, software 00012 * distributed under the License is distributed on an "AS IS" BASIS, 00013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00014 * See the License for the specific language governing permissions and 00015 * limitations under the License. 00016 * 00017 *=========================================================================*/ 00018 #ifndef __itkCreateObjectFunction_h 00019 #define __itkCreateObjectFunction_h 00020 00021 #include "itkObject.h" 00022 00023 namespace itk 00024 { 00031 class CreateObjectFunctionBase:public Object 00032 { 00033 public: 00035 typedef CreateObjectFunctionBase Self; 00036 typedef Object Superclass; 00037 typedef SmartPointer< Self > Pointer; 00038 typedef SmartPointer< const Self > ConstPointer; 00039 00042 virtual SmartPointer< LightObject > CreateObject() = 0; 00043 00044 protected: 00045 CreateObjectFunctionBase() {} 00046 ~CreateObjectFunctionBase() {} 00047 private: 00048 CreateObjectFunctionBase(const Self &); //purposely not implemented 00049 void operator=(const Self &); //purposely not implemented 00050 }; 00051 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 protected: 00071 CreateObjectFunction() {} 00072 ~CreateObjectFunction() {} 00073 private: 00074 CreateObjectFunction(const Self &); //purposely not implemented 00075 void operator=(const Self &); //purposely not implemented 00076 }; 00077 } // end namespace itk 00079 00080 #endif 00081