Main Page   Groups   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Concepts

itkObjectFactoryBase.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Insight Segmentation & Registration Toolkit
00004   Module:    $RCSfile: itkObjectFactoryBase.h,v $
00005   Language:  C++
00006   Date:      $Date: 2003/09/10 14:29:19 $
00007   Version:   $Revision: 1.35 $
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 __itkObjectFactoryBase_h
00021 #define __itkObjectFactoryBase_h
00022 
00023 #include "itkObject.h"
00024 #include "itkCreateObjectFunction.h"
00025 #include <list>
00026 #include <vector>
00027 
00028 namespace itk
00029 {
00048 class OverRideMap;
00049 
00050 class ITKCommon_EXPORT ObjectFactoryBase : public Object
00051 {
00052 public:  
00054   typedef ObjectFactoryBase   Self;
00055   typedef Object  Superclass;
00056   typedef SmartPointer<Self>  Pointer;
00057   typedef SmartPointer<const Self>  ConstPointer;
00058   
00060   itkTypeMacro(ObjectFactoryBase, Object);
00061 
00066   static LightObject::Pointer CreateInstance(const char* itkclassname);
00067 
00072   static std::list<LightObject::Pointer>
00073   CreateAllInstance(const char* itkclassname);
00074   
00077   static void ReHash(); 
00078 
00080   static void RegisterFactory(ObjectFactoryBase* );
00081 
00083   static void UnRegisterFactory(ObjectFactoryBase*);
00084 
00086   static void UnRegisterAllFactories();
00087   
00090   static std::list<ObjectFactoryBase*> GetRegisteredFactories();
00091 
00097   virtual const char* GetITKSourceVersion(void) const = 0;
00098 
00100   virtual const char* GetDescription(void) const = 0;
00101 
00103   virtual std::list<std::string> GetClassOverrideNames();
00104 
00106   virtual std::list<std::string> GetClassOverrideWithNames();
00107 
00109   virtual std::list<std::string> GetClassOverrideDescriptions();
00110 
00112   virtual std::list<bool> GetEnableFlags();
00113 
00115   virtual void SetEnableFlag(bool flag,
00116            const char* className,
00117            const char* subclassName);
00118 
00120   virtual bool GetEnableFlag(const char* className,
00121                              const char* subclassName);
00122 
00126   virtual void Disable(const char* className);
00127   
00129   const char* GetLibraryPath();
00130 
00133   struct OverrideInformation
00134   {
00135     std::string m_Description;
00136     std::string m_OverrideWithName;
00137     bool m_EnabledFlag;
00138     CreateObjectFunctionBase::Pointer m_CreateObject;
00139   };
00140 
00141 protected:
00142   virtual void PrintSelf(std::ostream& os, Indent indent) const;
00143 
00145   void RegisterOverride(const char* classOverride,
00146       const char* overrideClassName,
00147       const char* description,
00148       bool enableFlag,
00149       CreateObjectFunctionBase* createFunction);
00150     
00154   virtual LightObject::Pointer CreateObject(const char* itkclassname );
00155   
00156   ObjectFactoryBase();
00157   virtual ~ObjectFactoryBase();
00158 
00159 private:
00160   OverRideMap* m_OverrideMap;
00161 
00162   ObjectFactoryBase(const Self&); //purposely not implemented
00163   void operator=(const Self&); //purposely not implemented
00164 
00167   static void Initialize();
00168 
00170   static void RegisterDefaults();
00171 
00173   static void LoadDynamicFactories();
00174 
00176   static void LoadLibrariesInPath( const char*);
00177   
00179   static std::list<ObjectFactoryBase*>* m_RegisteredFactories; 
00180   
00183   void* m_LibraryHandle;
00184   unsigned long m_LibraryDate;
00185   std::string m_LibraryPath;
00186   };
00187 
00188 } // end namespace itk
00189 
00190 #endif

Generated at Wed May 24 23:47:49 2006 for ITK by doxygen 1.3.5 written by Dimitri van Heesch, © 1997-2000