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

vtkInstantiator.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Visualization Toolkit
00004   Module:    $RCSfile: vtkInstantiator.h,v $
00005 
00006   Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
00007   All rights reserved.
00008   See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
00009 
00010      This software is distributed WITHOUT ANY WARRANTY; without even
00011      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
00012      PURPOSE.  See the above copyright notice for more information.
00013 
00014 =========================================================================*/
00068 #ifndef __vtkInstantiator_h
00069 #define __vtkInstantiator_h
00070 
00071 #include "vtkObject.h"
00072 
00073 // The vtkDebugLeaks singleton must be initialized before and
00074 // destroyed after the vtkInstantiator singleton.
00075 #include "vtkDebugLeaksManager.h" // Needed for proper singleton initialization
00076 
00077 class vtkInstantiatorInitialize;
00078 class vtkInstantiatorHashTable;
00079 
00080 class VTK_COMMON_EXPORT vtkInstantiator : public vtkObject
00081 {
00082 public:
00083   static vtkInstantiator* New();
00084   vtkTypeRevisionMacro(vtkInstantiator,vtkObject);
00085   void PrintSelf(ostream& os, vtkIndent indent);
00086   
00089   static vtkObject* CreateInstance(const char* className);
00090   
00091   //BTX
00092   typedef vtkObject* (*CreateFunction)();
00093 
00095 
00099   static void RegisterInstantiator(const char* className,
00100                                    CreateFunction createFunction);
00102 
00104 
00107   static void UnRegisterInstantiator(const char* className,
00108                                      CreateFunction createFunction);
00109   //ETX
00111   
00112 protected:
00113   vtkInstantiator();
00114   ~vtkInstantiator();
00115   
00116   // Internal storage for registered creation functions.
00117   static vtkInstantiatorHashTable* CreatorTable;
00118   
00119   static void ClassInitialize();
00120   static void ClassFinalize();
00121   
00122   //BTX
00123   friend class vtkInstantiatorInitialize;
00124   //ETX
00125   
00126 private:
00127   vtkInstantiator(const vtkInstantiator&);  // Not implemented.
00128   void operator=(const vtkInstantiator&);  // Not implemented.
00129 };
00130 
00131 //BTX
00132 // Utility class to make sure vtkInstantiator is initialized before it
00133 // is used.
00134 class VTK_COMMON_EXPORT vtkInstantiatorInitialize
00135 {
00136 public:
00137   vtkInstantiatorInitialize();
00138   ~vtkInstantiatorInitialize();
00139 private:
00140   static unsigned int Count;
00141 };
00142 
00143 // This instance will show up in any translation unit that uses
00144 // vtkInstantiator.  It will make sure vtkInstantiator is initialized
00145 // before it is used.
00146 static vtkInstantiatorInitialize vtkInstantiatorInitializer;
00147 //ETX
00148 
00149 #endif