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 =========================================================================*/
59 #ifndef vtkInstantiator_h
60 #define vtkInstantiator_h
61 
62 #include "vtkCommonCoreModule.h" // For export macro
63 #include "vtkObject.h"
64 
65 // The vtkDebugLeaks singleton must be initialized before and
66 // destroyed after the vtkInstantiator singleton.
67 #include "vtkDebugLeaksManager.h" // Needed for proper singleton initialization
68 
70 class vtkInstantiatorHashTable;
71 
72 class VTKCOMMONCORE_EXPORT vtkInstantiator : public vtkObject
73 {
74 public:
75  static vtkInstantiator* New();
76  vtkTypeMacro(vtkInstantiator,vtkObject);
77  void PrintSelf(ostream& os, vtkIndent indent) VTK_OVERRIDE;
78 
84  static vtkObject* CreateInstance(const char* className);
85 
86  typedef vtkObject* (*CreateFunction)();
87 
94  static void RegisterInstantiator(const char* className,
95  CreateFunction createFunction);
96 
102  static void UnRegisterInstantiator(const char* className,
103  CreateFunction createFunction);
104 
105 protected:
106  vtkInstantiator();
107  ~vtkInstantiator() VTK_OVERRIDE;
108 
109  // Internal storage for registered creation functions.
110  static vtkInstantiatorHashTable* CreatorTable;
111 
112  static void ClassInitialize();
113  static void ClassFinalize();
114 
116 
117 private:
118  vtkInstantiator(const vtkInstantiator&) VTK_DELETE_FUNCTION;
119  void operator=(const vtkInstantiator&) VTK_DELETE_FUNCTION;
120 };
121 
122 // Utility class to make sure vtkInstantiator is initialized before it
123 // is used.
124 class VTKCOMMONCORE_EXPORT vtkInstantiatorInitialize
125 {
126 public:
127  vtkInstantiatorInitialize();
128  ~vtkInstantiatorInitialize();
129 private:
130  static unsigned int Count;
131 private:
132  vtkInstantiatorInitialize(const vtkInstantiatorInitialize& other) VTK_DELETE_FUNCTION;
133  vtkInstantiatorInitialize& operator=(const vtkInstantiatorInitialize& rhs) VTK_DELETE_FUNCTION;
134 };
135 
136 // This instance will show up in any translation unit that uses
137 // vtkInstantiator. It will make sure vtkInstantiator is initialized
138 // before it is used.
140 
141 #endif
abstract base class for most VTK objects
Definition: vtkObject.h:59
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
create an instance of any VTK class from its name.
a simple class to control print indentation
Definition: vtkIndent.h:39
static vtkInstantiatorInitialize vtkInstantiatorInitializer
#define VTK_NEWINSTANCE
static vtkObject * New()
Create an object with Debug turned off, modified time initialized to zero, and reference counting on...