VTK
vtkInstantiator.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkInstantiator.h
5 
6  Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
7  All rights reserved.
8  See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
9 
10  This software is distributed WITHOUT ANY WARRANTY; without even
11  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12  PURPOSE. See the above copyright notice for more information.
13 
14 =========================================================================*/
58 #ifndef vtkInstantiator_h
59 #define vtkInstantiator_h
60 
61 #include "vtkCommonCoreModule.h" // For export macro
62 #include "vtkObject.h"
63 
64 // The vtkDebugLeaks singleton must be initialized before and
65 // destroyed after the vtkInstantiator singleton.
66 #include "vtkDebugLeaksManager.h" // Needed for proper singleton initialization
67 
69 class vtkInstantiatorHashTable;
70 
72 {
73 public:
74  static vtkInstantiator* New();
75  vtkTypeMacro(vtkInstantiator,vtkObject);
76  void PrintSelf(ostream& os, vtkIndent indent);
77 
80  static vtkObject* CreateInstance(const char* className);
81 
82  //BTX
83  typedef vtkObject* (*CreateFunction)();
84 
86 
90  static void RegisterInstantiator(const char* className,
91  CreateFunction createFunction);
93 
95 
98  static void UnRegisterInstantiator(const char* className,
99  CreateFunction createFunction);
100  //ETX
102 
103 protected:
104  vtkInstantiator();
105  ~vtkInstantiator();
106 
107  // Internal storage for registered creation functions.
108  static vtkInstantiatorHashTable* CreatorTable;
109 
110  static void ClassInitialize();
111  static void ClassFinalize();
112 
113  //BTX
115  //ETX
116 
117 private:
118  vtkInstantiator(const vtkInstantiator&); // Not implemented.
119  void operator=(const vtkInstantiator&); // Not implemented.
120 };
121 
122 //BTX
123 // Utility class to make sure vtkInstantiator is initialized before it
124 // is used.
126 {
127 public:
130 private:
131  static unsigned int Count;
132 private:
133  vtkInstantiatorInitialize(const vtkInstantiatorInitialize& other); // no copy constructor
134  vtkInstantiatorInitialize& operator=(const vtkInstantiatorInitialize& rhs); // no copy assignment
135 };
136 
137 // This instance will show up in any translation unit that uses
138 // vtkInstantiator. It will make sure vtkInstantiator is initialized
139 // before it is used.
141 //ETX
142 
143 #endif
abstract base class for most VTK objects
Definition: vtkObject.h:61
static vtkInstantiatorHashTable * CreatorTable
#define VTKCOMMONCORE_EXPORT
create an instance of any VTK class from its name.
virtual void PrintSelf(ostream &os, vtkIndent indent)
a simple class to control print indentation
Definition: vtkIndent.h:38
static vtkInstantiatorInitialize vtkInstantiatorInitializer
static vtkObject * New()