Main Page | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members | Related Pages

dox/Common/vtkInstantiator.h

Go to the documentation of this file.
00001 /*========================================================================= 00002 00003 Program: Visualization Toolkit 00004 Module: $RCSfile: vtkInstantiator.h,v $ 00005 Language: C++ 00006 00007 Copyright (c) 1993-2002 Ken Martin, Will Schroeder, Bill Lorensen 00008 All rights reserved. 00009 See Copyright.txt or http://www.kitware.com/Copyright.htm for details. 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 notice for more information. 00014 00015 =========================================================================*/ 00062 #ifndef __vtkInstantiator_h 00063 #define __vtkInstantiator_h 00064 00065 #include "vtkObject.h" 00066 00067 // The vtkDebugLeaks singleton must be initialized before and 00068 // destroyed after the vtkInstantiator singleton. 00069 #include "vtkDebugLeaksManager.h" // Needed for proper singleton initialization 00070 00071 class vtkInstantiatorInitialize; 00072 class vtkInstantiatorHashTable; 00073 00074 class VTK_COMMON_EXPORT vtkInstantiator : public vtkObject 00075 { 00076 public: 00077 static vtkInstantiator* New(); 00078 vtkTypeRevisionMacro(vtkInstantiator,vtkObject); 00079 void PrintSelf(ostream& os, vtkIndent indent); 00080 00083 static vtkObject* CreateInstance(const char* className); 00084 00085 //BTX 00086 typedef vtkObject* (*CreateFunction)(); 00087 00089 00093 static void RegisterInstantiator(const char* className, 00094 CreateFunction createFunction); 00096 00098 00101 static void UnRegisterInstantiator(const char* className, 00102 CreateFunction createFunction); 00103 //ETX 00105 00106 protected: 00107 vtkInstantiator(); 00108 ~vtkInstantiator(); 00109 00110 // Internal storage for registered creation functions. 00111 static vtkInstantiatorHashTable* CreatorTable; 00112 00113 static void ClassInitialize(); 00114 static void ClassFinalize(); 00115 00116 //BTX 00117 friend class vtkInstantiatorInitialize; 00118 //ETX 00119 00120 private: 00121 vtkInstantiator(const vtkInstantiator&); // Not implemented. 00122 void operator=(const vtkInstantiator&); // Not implemented. 00123 }; 00124 00125 //BTX 00126 // Utility class to make sure vtkInstantiator is initialized before it 00127 // is used. 00128 class VTK_COMMON_EXPORT vtkInstantiatorInitialize 00129 { 00130 public: 00131 vtkInstantiatorInitialize(); 00132 ~vtkInstantiatorInitialize(); 00133 private: 00134 static unsigned int Count; 00135 }; 00136 00137 // This instance will show up in any translation unit that uses 00138 // vtkInstantiator. It will make sure vtkInstantiator is initialized 00139 // before it is used. 00140 static vtkInstantiatorInitialize vtkInstantiatorInitializer; 00141 //ETX 00142 00143 #endif