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 =========================================================================*/
56 #ifndef vtkInstantiator_h
57 #define vtkInstantiator_h
58 
59 #include "vtkCommonCoreModule.h" // For export macro
60 #include "vtkObject.h"
61 
62 // The vtkDebugLeaks singleton must be initialized before and
63 // destroyed after the vtkInstantiator singleton.
64 #include "vtkDebugLeaksManager.h" // Needed for proper singleton initialization
65 
67 class vtkInstantiatorHashTable;
68 
69 class VTKCOMMONCORE_EXPORT vtkInstantiator : public vtkObject
70 {
71 public:
72  static vtkInstantiator* New();
73  vtkTypeMacro(vtkInstantiator,vtkObject);
74  void PrintSelf(ostream& os, vtkIndent indent) VTK_OVERRIDE;
75 
81  static vtkObject* CreateInstance(const char* className);
82 
83  typedef vtkObject* (*CreateFunction)();
84 
91  static void RegisterInstantiator(const char* className,
92  CreateFunction createFunction);
93 
99  static void UnRegisterInstantiator(const char* className,
100  CreateFunction createFunction);
101 
102 protected:
103  vtkInstantiator();
104  ~vtkInstantiator() VTK_OVERRIDE;
105 
106  // Internal storage for registered creation functions.
107  static vtkInstantiatorHashTable* CreatorTable;
108 
109  static void ClassInitialize();
110  static void ClassFinalize();
111 
113 
114 private:
115  vtkInstantiator(const vtkInstantiator&) VTK_DELETE_FUNCTION;
116  void operator=(const vtkInstantiator&) VTK_DELETE_FUNCTION;
117 };
118 
119 // Utility class to make sure vtkInstantiator is initialized before it
120 // is used.
121 class VTKCOMMONCORE_EXPORT vtkInstantiatorInitialize
122 {
123 public:
126 private:
127  static unsigned int Count;
128 private:
129  vtkInstantiatorInitialize(const vtkInstantiatorInitialize& other) VTK_DELETE_FUNCTION;
130  vtkInstantiatorInitialize& operator=(const vtkInstantiatorInitialize& rhs) VTK_DELETE_FUNCTION;
131 };
132 
133 // This instance will show up in any translation unit that uses
134 // vtkInstantiator. It will make sure vtkInstantiator is initialized
135 // before it is used.
137 
138 #endif
abstract base class for most VTK objects
Definition: vtkObject.h:53
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:33
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...