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 =========================================================================*/
61 #ifndef vtkInstantiator_h
62 #define vtkInstantiator_h
63 
64 #include "vtkCommonCoreModule.h" // For export macro
65 #include "vtkObject.h"
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 
75 {
76 public:
77  static vtkInstantiator* New();
79  void PrintSelf(ostream& os, vtkIndent indent);
80 
83  static vtkObject* CreateInstance(const char* className);
84 
85  //BTX
86  typedef vtkObject* (*CreateFunction)();
87 
89 
93  static void RegisterInstantiator(const char* className,
94  CreateFunction createFunction);
96 
98 
101  static void UnRegisterInstantiator(const char* className,
102  CreateFunction createFunction);
103  //ETX
105 
106 protected:
109 
110  // Internal storage for registered creation functions.
111  static vtkInstantiatorHashTable* CreatorTable;
112 
113  static void ClassInitialize();
114  static void ClassFinalize();
115 
116  //BTX
118  //ETX
119 
120 private:
121  vtkInstantiator(const vtkInstantiator&); // Not implemented.
122  void operator=(const vtkInstantiator&); // Not implemented.
123 };
124 
125 //BTX
126 // Utility class to make sure vtkInstantiator is initialized before it
127 // is used.
129 {
130 public:
133 private:
134  static unsigned int Count;
135 private:
136  vtkInstantiatorInitialize(const vtkInstantiatorInitialize& other); // no copy constructor
137  vtkInstantiatorInitialize& operator=(const vtkInstantiatorInitialize& rhs); // no copy assignment
138 };
139 
140 // This instance will show up in any translation unit that uses
141 // vtkInstantiator. It will make sure vtkInstantiator is initialized
142 // before it is used.
144 //ETX
145 
146 #endif
VTKCOMMONCORE_EXPORT
#define VTKCOMMONCORE_EXPORT
Definition: vtkCommonCoreModule.h:15
vtkInstantiator::CreatorTable
static vtkInstantiatorHashTable * CreatorTable
Definition: vtkInstantiator.h:111
vtkInstantiatorInitializer
static vtkInstantiatorInitialize vtkInstantiatorInitializer
Definition: vtkInstantiator.h:143
vtkInstantiator::UnRegisterInstantiator
static void UnRegisterInstantiator(const char *className, CreateFunction createFunction)
vtkTypeMacro
#define vtkTypeMacro(thisClass, superclass)
Definition: vtkSetGet.h:642
vtkObject
abstract base class for most VTK objects
Definition: vtkObject.h:62
vtkInstantiator::RegisterInstantiator
static void RegisterInstantiator(const char *className, CreateFunction createFunction)
vtkInstantiator
create an instance of any VTK class from its name.
Definition: vtkInstantiator.h:75
vtkDebugLeaksManager.h
vtkInstantiatorInitialize::~vtkInstantiatorInitialize
~vtkInstantiatorInitialize()
vtkInstantiator::ClassInitialize
static void ClassInitialize()
vtkCommonCoreModule.h
vtkInstantiatorInitialize
Definition: vtkInstantiator.h:129
vtkIndent
a simple class to control print indentation
Definition: vtkIndent.h:39
vtkInstantiator::PrintSelf
void PrintSelf(ostream &os, vtkIndent indent)
vtkInstantiator::CreateInstance
static vtkObject * CreateInstance(const char *className)
vtkInstantiator::~vtkInstantiator
~vtkInstantiator()
vtkObject.h
vtkInstantiator::vtkInstantiator
vtkInstantiator()
vtkInstantiatorInitialize::vtkInstantiatorInitialize
vtkInstantiatorInitialize()
vtkInstantiator::ClassFinalize
static void ClassFinalize()
vtkInstantiator::New
static vtkInstantiator * New()