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 =========================================================================*/
62 #ifndef vtkInstantiator_h
63 #define vtkInstantiator_h
64 
65 #include "vtkCommonCoreModule.h" // For export macro
66 #include "vtkObject.h"
67 
68 // The vtkDebugLeaks singleton must be initialized before and
69 // destroyed after the vtkInstantiator singleton.
70 #include "vtkDebugLeaksManager.h" // Needed for proper singleton initialization
71 
73 class vtkInstantiatorHashTable;
74 
75 class VTKCOMMONCORE_EXPORT vtkInstantiator : public vtkObject
76 {
77 public:
78  static vtkInstantiator* New();
79  vtkTypeMacro(vtkInstantiator,vtkObject);
80  void PrintSelf(ostream& os, vtkIndent indent) VTK_OVERRIDE;
81 
87  static vtkObject* CreateInstance(const char* className);
88 
89  typedef vtkObject* (*CreateFunction)();
90 
97  static void RegisterInstantiator(const char* className,
98  CreateFunction createFunction);
99 
105  static void UnRegisterInstantiator(const char* className,
106  CreateFunction createFunction);
107 
108 protected:
110  ~vtkInstantiator() VTK_OVERRIDE;
111 
112  // Internal storage for registered creation functions.
113  static vtkInstantiatorHashTable* CreatorTable;
114 
115  static void ClassInitialize();
116  static void ClassFinalize();
117 
119 
120 private:
121  vtkInstantiator(const vtkInstantiator&) VTK_DELETE_FUNCTION;
122  void operator=(const vtkInstantiator&) VTK_DELETE_FUNCTION;
123 };
124 
125 // Utility class to make sure vtkInstantiator is initialized before it
126 // is used.
127 class VTKCOMMONCORE_EXPORT vtkInstantiatorInitialize
128 {
129 public:
132 private:
133  static unsigned int Count;
134 private:
135  vtkInstantiatorInitialize(const vtkInstantiatorInitialize& other) VTK_DELETE_FUNCTION;
136  vtkInstantiatorInitialize& operator=(const vtkInstantiatorInitialize& rhs) VTK_DELETE_FUNCTION;
137 };
138 
139 // This instance will show up in any translation unit that uses
140 // vtkInstantiator. It will make sure vtkInstantiator is initialized
141 // before it is used.
143 
144 #endif
a simple class to control print indentation
Definition: vtkIndent.h:40
create an instance of any VTK class from its name.
~vtkInstantiator() override
static vtkInstantiator * New()
static void UnRegisterInstantiator(const char *className, CreateFunction createFunction)
Unregister the instance creation of the class whose name is given.
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
static void RegisterInstantiator(const char *className, CreateFunction createFunction)
Register a function to create instances of the class whose name is given.
static VTK_NEWINSTANCE vtkObject * CreateInstance(const char *className)
Create an instance of the class whose name is given.
abstract base class for most VTK objects
Definition: vtkObject.h:60
static vtkInstantiatorInitialize vtkInstantiatorInitializer
#define VTK_NEWINSTANCE