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 /*========================================================================= 00019 * 00020 * Portions of this file are subject to the VTK Toolkit Version 3 copyright. 00021 * 00022 * Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen 00023 * 00024 * For complete copyright, license and disclaimer of warranty information 00025 * please refer to the NOTICE file at the top of the ITK source tree. 00026 * 00027 *=========================================================================*/ 00028 #ifndef __itkObjectFactoryBase_h 00029 #define __itkObjectFactoryBase_h 00030 00031 #include "itkCreateObjectFunction.h" 00032 #include <list> 00033 #include <vector> 00034 00035 namespace itk 00036 { 00056 class OverRideMap; 00057 00058 class ITKCommon_EXPORT ObjectFactoryBase:public Object 00059 { 00060 public: 00062 typedef ObjectFactoryBase Self; 00063 typedef Object Superclass; 00064 typedef SmartPointer< Self > Pointer; 00065 typedef SmartPointer< const Self > ConstPointer; 00066 00068 itkTypeMacro(ObjectFactoryBase, Object); 00069 00074 static LightObject::Pointer CreateInstance(const char *itkclassname); 00075 00080 static std::list< LightObject::Pointer > 00081 CreateAllInstance(const char *itkclassname); 00082 00085 static void ReHash(); 00086 00091 static void RegisterFactoryInternal(ObjectFactoryBase *); 00092 00096 typedef enum 00097 { 00098 INSERT_AT_FRONT, 00099 INSERT_AT_BACK, 00100 INSERT_AT_POSITION 00101 } InsertionPositionType; 00102 00118 static void RegisterFactory(ObjectFactoryBase *, 00119 InsertionPositionType where=INSERT_AT_BACK, size_t position = 0); 00121 00123 static void UnRegisterFactory(ObjectFactoryBase *); 00124 00126 static void UnRegisterAllFactories(); 00127 00130 static std::list< ObjectFactoryBase * > GetRegisteredFactories(); 00131 00137 virtual const char * GetITKSourceVersion(void) const = 0; 00138 00144 static void SetStrictVersionChecking( bool ); 00145 static void StrictVersionCheckingOn(); 00146 static void StrictVersionCheckingOff(); 00147 static bool GetStrictVersionChecking(); 00149 00151 virtual const char * GetDescription(void) const = 0; 00152 00154 virtual std::list< std::string > GetClassOverrideNames(); 00155 00157 virtual std::list< std::string > GetClassOverrideWithNames(); 00158 00160 virtual std::list< std::string > GetClassOverrideDescriptions(); 00161 00163 virtual std::list< bool > GetEnableFlags(); 00164 00166 virtual void SetEnableFlag(bool flag, 00167 const char *className, 00168 const char *subclassName); 00169 00171 virtual bool GetEnableFlag(const char *className, 00172 const char *subclassName); 00173 00177 virtual void Disable(const char *className); 00178 00180 const char * GetLibraryPath(); 00181 00186 struct OverrideInformation { 00187 std::string m_Description; 00188 std::string m_OverrideWithName; 00189 bool m_EnabledFlag; 00190 CreateObjectFunctionBase::Pointer m_CreateObject; 00191 }; 00192 protected: 00193 virtual void PrintSelf(std::ostream & os, Indent indent) const; 00194 00196 void RegisterOverride(const char *classOverride, 00197 const char *overrideClassName, 00198 const char *description, 00199 bool enableFlag, 00200 CreateObjectFunctionBase *createFunction); 00201 00205 virtual LightObject::Pointer CreateObject(const char *itkclassname); 00206 00210 virtual std::list< LightObject::Pointer > 00211 CreateAllObject(const char *itkclassname); 00212 00213 ObjectFactoryBase(); 00214 virtual ~ObjectFactoryBase(); 00215 private: 00216 OverRideMap *m_OverrideMap; 00217 00218 ObjectFactoryBase(const Self &); //purposely not implemented 00219 void operator=(const Self &); //purposely not implemented 00220 00222 static void InitializeFactoryList(); 00223 00226 static void Initialize(); 00227 00229 static void RegisterDefaults(); 00230 00232 static void LoadDynamicFactories(); 00233 00235 static void LoadLibrariesInPath(const char *); 00236 00239 void * m_LibraryHandle; 00240 unsigned long m_LibraryDate; 00241 std::string m_LibraryPath; 00242 00243 static bool m_StrictVersionChecking; 00244 }; 00245 } // end namespace itk 00246 00247 #endif 00248