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 =========================================================================*/
61 #ifndef __vtkInstantiator_h
62 #define __vtkInstantiator_h
63 
64 #include "vtkCommonCoreModule.h" // For export macro
65 #include "vtkObject.h"
66 
67 // The vtkDebugLeaks singleton must be initialized before and
68 // destroyed after the vtkInstantiator singleton.
69 #include "vtkDebugLeaksManager.h" // Needed for proper singleton initialization
70 
72 class vtkInstantiatorHashTable;
73 
75 {
76 public:
77  static vtkInstantiator* New();
79  void PrintSelf(ostream& os, vtkIndent indent);
80 
83  static vtkObject* CreateInstance(const char* className);
84 
85  //BTX
86  typedef vtkObject* (*CreateFunction)();
87 
89 
93  static void RegisterInstantiator(const char* className,
94  CreateFunction createFunction);
96 
98 
101  static void UnRegisterInstantiator(const char* className,
102  CreateFunction createFunction);
103  //ETX
105 
106 protected:
107  vtkInstantiator();
108  ~vtkInstantiator();
109 
110  // Internal storage for registered creation functions.
111  static vtkInstantiatorHashTable* CreatorTable;
112 
113  static void ClassInitialize();
114  static void ClassFinalize();
115 
116  //BTX
118  //ETX
119 
120 private:
121  vtkInstantiator(const vtkInstantiator&); // Not implemented.
122  void operator=(const vtkInstantiator&); // Not implemented.
123 };
124 
125 //BTX
126 // Utility class to make sure vtkInstantiator is initialized before it
127 // is used.
129 {
130 public:
133 private:
134  static unsigned int Count;
135 private:
136  vtkInstantiatorInitialize(const vtkInstantiatorInitialize& other); // no copy constructor
137  vtkInstantiatorInitialize& operator=(const vtkInstantiatorInitialize& rhs); // no copy assignment
138 };
139 
140 // This instance will show up in any translation unit that uses
141 // vtkInstantiator. It will make sure vtkInstantiator is initialized
142 // before it is used.
144 //ETX
145 
146 #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.
#define vtkTypeMacro(thisClass, superclass)
Definition: vtkSetGet.h:619
virtual void PrintSelf(ostream &os, vtkIndent indent)
a simple class to control print indentation
Definition: vtkIndent.h:38
static vtkInstantiatorInitialize vtkInstantiatorInitializer
static vtkObject * New()