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

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 =========================================================================*/
00072 #ifndef __vtkInstantiator_h
00073 #define __vtkInstantiator_h
00074 
00075 #include "vtkObject.h"
00076 
00077 // The vtkDebugLeaks singleton must be initialized before and
00078 // destroyed after the vtkInstantiator singleton.
00079 #include "vtkDebugLeaksManager.h" // Needed for proper singleton initialization
00080 
00081 class vtkInstantiatorInitialize;
00082 class vtkInstantiatorHashTable;
00083 
00084 class VTK_COMMON_EXPORT vtkInstantiator : public vtkObject
00085 {
00086 public:
00087   static vtkInstantiator* New();
00088   vtkTypeRevisionMacro(vtkInstantiator,vtkObject);
00089   void PrintSelf(ostream& os, vtkIndent indent);
00090   
00093   static vtkObject* CreateInstance(const char* className);
00094   
00095   //BTX
00096   typedef vtkObject* (*CreateFunction)();
00097 
00099 
00103   static void RegisterInstantiator(const char* className,
00104                                    CreateFunction createFunction);
00106 
00108 
00111   static void UnRegisterInstantiator(const char* className,
00112                                      CreateFunction createFunction);
00113   //ETX
00115   
00116 protected:
00117   vtkInstantiator();
00118   ~vtkInstantiator();
00119   
00120   // Internal storage for registered creation functions.
00121   static vtkInstantiatorHashTable* CreatorTable;
00122   
00123   static void ClassInitialize();
00124   static void ClassFinalize();
00125   
00126   //BTX
00127   friend class vtkInstantiatorInitialize;
00128   //ETX
00129   
00130 private:
00131   vtkInstantiator(const vtkInstantiator&);  // Not implemented.
00132   void operator=(const vtkInstantiator&);  // Not implemented.
00133 };
00134 
00135 //BTX
00136 // Utility class to make sure vtkInstantiator is initialized before it
00137 // is used.
00138 class VTK_COMMON_EXPORT vtkInstantiatorInitialize
00139 {
00140 public:
00141   vtkInstantiatorInitialize();
00142   ~vtkInstantiatorInitialize();
00143 private:
00144   static unsigned int Count;
00145 };
00146 
00147 // This instance will show up in any translation unit that uses
00148 // vtkInstantiator.  It will make sure vtkInstantiator is initialized
00149 // before it is used.
00150 static vtkInstantiatorInitialize vtkInstantiatorInitializer;
00151 //ETX
00152 
00153 #endif