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 =========================================================================*/
58 #ifndef __vtkInstantiator_h
59 #define __vtkInstantiator_h
60 
61 #include "vtkObject.h"
62 
63 // The vtkDebugLeaks singleton must be initialized before and
64 // destroyed after the vtkInstantiator singleton.
65 #include "vtkDebugLeaksManager.h" // Needed for proper singleton initialization
66 
68 class vtkInstantiatorHashTable;
69 
71 {
72 public:
73  static vtkInstantiator* New();
74  vtkTypeMacro(vtkInstantiator,vtkObject);
75  void PrintSelf(ostream& os, vtkIndent indent);
76 
79  static vtkObject* CreateInstance(const char* className);
80 
81  //BTX
82  typedef vtkObject* (*CreateFunction)();
83 
85 
89  static void RegisterInstantiator(const char* className,
90  CreateFunction createFunction);
92 
94 
97  static void UnRegisterInstantiator(const char* className,
98  CreateFunction createFunction);
99  //ETX
101 
102 protected:
103  vtkInstantiator();
104  ~vtkInstantiator();
105 
106  // Internal storage for registered creation functions.
107  static vtkInstantiatorHashTable* CreatorTable;
108 
109  static void ClassInitialize();
110  static void ClassFinalize();
111 
112  //BTX
114  //ETX
115 
116 private:
117  vtkInstantiator(const vtkInstantiator&); // Not implemented.
118  void operator=(const vtkInstantiator&); // Not implemented.
119 };
120 
121 //BTX
122 // Utility class to make sure vtkInstantiator is initialized before it
123 // is used.
125 {
126 public:
129 private:
130  static unsigned int Count;
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 //ETX
138 
139 #endif
abstract base class for most VTK objects
Definition: vtkObject.h:60
static vtkInstantiatorHashTable * CreatorTable
create an instance of any VTK class from its name.
virtual void PrintSelf(ostream &os, vtkIndent indent)
a simple class to control print indentation
Definition: vtkIndent.h:37
#define VTK_COMMON_EXPORT
static vtkInstantiatorInitialize vtkInstantiatorInitializer
static vtkObject * New()