vtkObjectFactory.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00051 #ifndef __vtkObjectFactory_h
00052 #define __vtkObjectFactory_h
00053
00054
00055
00056
00057 #include "vtkObject.h"
00058
00059 class vtkObjectFactoryCollection;
00060 class vtkOverrideInformationCollection;
00061 class vtkCollection;
00062
00063 class VTK_COMMON_EXPORT vtkObjectFactory : public vtkObject
00064 {
00065 public:
00066
00067
00072 static vtkObject* CreateInstance(const char* vtkclassname);
00073
00075
00078 static void CreateAllInstance(const char* vtkclassname,
00079 vtkCollection* retList);
00080
00081
00082
00083 static void ReHash();
00084
00085
00086 static void RegisterFactory(vtkObjectFactory* );
00087
00088
00089 static void UnRegisterFactory(vtkObjectFactory*);
00090
00091
00092 static void UnRegisterAllFactories();
00094
00097 static vtkObjectFactoryCollection* GetRegisteredFactories();
00098
00101 static int HasOverrideAny(const char* className);
00102
00104
00106 static void GetOverrideInformation(const char* name,
00107 vtkOverrideInformationCollection*);
00109
00111
00113 static void SetAllEnableFlags(int flag,
00114 const char* className);
00115
00116
00117
00118 static void SetAllEnableFlags(int flag,
00119 const char* className,
00120 const char* subclassName);
00122
00123
00124
00125
00126 vtkTypeRevisionMacro(vtkObjectFactory,vtkObject);
00128 virtual void PrintSelf(ostream& os, vtkIndent indent);
00129
00136 virtual const char* GetVTKSourceVersion() = 0;
00137
00139 virtual const char* GetDescription() = 0;
00140
00142 virtual int GetNumberOfOverrides();
00143
00145 virtual const char* GetClassOverrideName(int index);
00146
00149 virtual const char* GetClassOverrideWithName(int index);
00150
00152 virtual int GetEnableFlag(int index);
00153
00155 virtual const char* GetOverrideDescription(int index);
00156
00158
00160 virtual void SetEnableFlag(int flag,
00161 const char* className,
00162 const char* subclassName);
00163 virtual int GetEnableFlag(const char* className,
00164 const char* subclassName);
00166
00168
00169 virtual int HasOverride(const char* className);
00170
00171
00172 virtual int HasOverride(const char* className, const char* subclassName);
00174
00177 virtual void Disable(const char* className);
00178
00180
00181 vtkGetStringMacro(LibraryPath);
00183
00184
00185 typedef vtkObject* (*CreateFunction)();
00186
00187 protected:
00188
00189
00191
00192 void RegisterOverride(const char* classOverride,
00193 const char* overrideClassName,
00194 const char* description,
00195 int enableFlag,
00196 CreateFunction createFunction);
00198
00199
00200
00201
00205 virtual vtkObject* CreateObject(const char* vtkclassname );
00206
00207 vtkObjectFactory();
00208 ~vtkObjectFactory();
00209
00210 struct OverrideInformation
00211 {
00212 char* Description;
00213 char* OverrideWithName;
00214 int EnabledFlag;
00215 CreateFunction CreateCallback;
00216 };
00217
00218 OverrideInformation* OverrideArray;
00219 char** OverrideClassNames;
00220 int SizeOverrideArray;
00221 int OverrideArrayLength;
00222
00223 private:
00224 void GrowOverrideArray();
00225
00227
00229 static void Init();
00230
00231
00232 static void RegisterDefaults();
00233
00234
00235 static void LoadDynamicFactories();
00236
00237
00238 static void LoadLibrariesInPath( const char*);
00240
00241
00242 static vtkObjectFactoryCollection* RegisteredFactories;
00243
00244
00245
00246 void* LibraryHandle;
00247 char* LibraryVTKVersion;
00248 char* LibraryCompilerUsed;
00249 char* LibraryPath;
00250 private:
00251 vtkObjectFactory(const vtkObjectFactory&);
00252 void operator=(const vtkObjectFactory&);
00253 };
00254
00255
00256
00257
00258 #define VTK_CREATE_CREATE_FUNCTION(classname) \
00259 static vtkObject* vtkObjectFactoryCreate##classname() \
00260 { return classname::New(); }
00261
00262 #endif
00263
00264
00265 #ifdef _WIN32
00266 #define VTK_FACTORY_INTERFACE_EXPORT __declspec( dllexport )
00267 #else
00268 #define VTK_FACTORY_INTERFACE_EXPORT
00269 #endif
00270
00271
00272
00273
00274
00275
00276 #define VTK_FACTORY_INTERFACE_IMPLEMENT(factoryName) \
00277 extern "C" \
00278 VTK_FACTORY_INTERFACE_EXPORT \
00279 const char* vtkGetFactoryCompilerUsed() \
00280 { \
00281 return VTK_CXX_COMPILER; \
00282 } \
00283 extern "C" \
00284 VTK_FACTORY_INTERFACE_EXPORT \
00285 const char* vtkGetFactoryVersion() \
00286 { \
00287 return VTK_SOURCE_VERSION; \
00288 } \
00289 extern "C" \
00290 VTK_FACTORY_INTERFACE_EXPORT \
00291 vtkObjectFactory* vtkLoad() \
00292 { \
00293 return factoryName ::New(); \
00294 }