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 #ifndef VTK_LEGACY_REMOVE
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 
74 class VTKCOMMONCORE_EXPORT vtkInstantiator : public vtkObject
75 {
76 public:
77  static vtkInstantiator* New();
78  vtkTypeMacro(vtkInstantiator,vtkObject);
79  void PrintSelf(ostream& os, vtkIndent indent) override;
80 
86  static vtkObject* CreateInstance(const char* className);
87 
88  typedef vtkObject* (*CreateFunction)();
89 
96  static void RegisterInstantiator(const char* className,
97  CreateFunction createFunction);
98 
104  static void UnRegisterInstantiator(const char* className,
105  CreateFunction createFunction);
106 
107 protected:
108  vtkInstantiator();
109  ~vtkInstantiator() override;
110 
111  // Internal storage for registered creation functions.
112  static vtkInstantiatorHashTable* CreatorTable;
113 
114  static void ClassInitialize();
115  static void ClassFinalize();
116 
118 
119 private:
120  vtkInstantiator(const vtkInstantiator&) = delete;
121  void operator=(const vtkInstantiator&) = delete;
122 };
123 
124 // Utility class to make sure vtkInstantiator is initialized before it
125 // is used.
126 class VTKCOMMONCORE_EXPORT vtkInstantiatorInitialize
127 {
128 public:
131 private:
132  static unsigned int Count;
133 private:
135  vtkInstantiatorInitialize& operator=(const vtkInstantiatorInitialize& rhs) = delete;
136 };
137 
138 // This instance will show up in any translation unit that uses
139 // vtkInstantiator. It will make sure vtkInstantiator is initialized
140 // before it is used.
142 
143 #endif
144 #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.
static vtkInstantiatorHashTable * CreatorTable
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.