00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00072 #ifndef __vtkObjectFactory_h
00073 #define __vtkObjectFactory_h
00074
00075
00076
00077
00078 #include "vtkObject.h"
00079
00080 class vtkObjectFactoryCollection;
00081 class vtkOverrideInformationCollection;
00082
00083 class VTK_COMMON_EXPORT vtkObjectFactory : public vtkObject
00084 {
00085 public:
00086
00087
00089
00093 static vtkObject* CreateInstance(const char* vtkclassname);
00094
00095
00096
00097 static void ReHash();
00098
00099
00100 static void RegisterFactory(vtkObjectFactory* );
00101
00102
00103 static void UnRegisterFactory(vtkObjectFactory*);
00104
00105
00106 static void UnRegisterAllFactories();
00108
00111 static vtkObjectFactoryCollection* GetRegisteredFactories();
00112
00115 static int HasOverrideAny(const char* className);
00116
00118
00120 static void GetOverrideInformation(const char* name,
00121 vtkOverrideInformationCollection*);
00123
00125
00127 static void SetAllEnableFlags(int flag,
00128 const char* className);
00129
00130
00131
00132 static void SetAllEnableFlags(int flag,
00133 const char* className,
00134 const char* subclassName);
00136
00137
00138
00139
00140 vtkTypeMacro(vtkObjectFactory,vtkObject);
00142 virtual void PrintSelf(ostream& os, vtkIndent indent);
00143
00150 virtual const char* GetVTKSourceVersion() = 0;
00151
00153 virtual const char* GetDescription() = 0;
00154
00156 virtual int GetNumberOfOverrides();
00157
00159 virtual const char* GetClassOverrideName(int index);
00160
00163 virtual const char* GetClassOverrideWithName(int index);
00164
00166 virtual int GetEnableFlag(int index);
00167
00169 virtual const char* GetOverrideDescription(int index);
00170
00172
00174 virtual void SetEnableFlag(int flag,
00175 const char* className,
00176 const char* subclassName);
00177 virtual int GetEnableFlag(const char* className,
00178 const char* subclassName);
00180
00182
00183 virtual int HasOverride(const char* className);
00184
00185
00186 virtual int HasOverride(const char* className, const char* subclassName);
00188
00191 virtual void Disable(const char* className);
00192
00194
00195 vtkGetStringMacro(LibraryPath);
00197
00198
00199 typedef vtkObject* (*CreateFunction)();
00200
00201 protected:
00202
00203
00205
00206 void RegisterOverride(const char* classOverride,
00207 const char* overrideClassName,
00208 const char* description,
00209 int enableFlag,
00210 CreateFunction createFunction);
00212
00213
00214
00215
00219 virtual vtkObject* CreateObject(const char* vtkclassname );
00220
00221 vtkObjectFactory();
00222 ~vtkObjectFactory();
00223
00224 struct OverrideInformation
00225 {
00226 char* Description;
00227 char* OverrideWithName;
00228 int EnabledFlag;
00229 CreateFunction CreateCallback;
00230 };
00231
00232 OverrideInformation* OverrideArray;
00233 char** OverrideClassNames;
00234 int SizeOverrideArray;
00235 int OverrideArrayLength;
00236
00237 private:
00238 void GrowOverrideArray();
00239
00241
00243 static void Init();
00244
00245
00246 static void RegisterDefaults();
00247
00248
00249 static void LoadDynamicFactories();
00250
00251
00252 static void LoadLibrariesInPath( const char*);
00254
00255
00256 static vtkObjectFactoryCollection* RegisteredFactories;
00257
00258
00259
00260 void* LibraryHandle;
00261 char* LibraryVTKVersion;
00262 char* LibraryCompilerUsed;
00263 char* LibraryPath;
00264 private:
00265 vtkObjectFactory(const vtkObjectFactory&);
00266 void operator=(const vtkObjectFactory&);
00267 };
00268
00269
00270
00271
00272 #define VTK_CREATE_CREATE_FUNCTION(classname) \
00273 static vtkObject* vtkObjectFactoryCreate##classname() \
00274 { return classname::New(); }
00275
00276 #endif
00277
00278
00279 #ifdef _WIN32
00280 #define VTK_FACTORY_INTERFACE_EXPORT __declspec( dllexport )
00281 #else
00282 #define VTK_FACTORY_INTERFACE_EXPORT
00283 #endif
00284
00285
00286
00287
00288
00289
00290 #define VTK_FACTORY_INTERFACE_IMPLEMENT(factoryName) \
00291 extern "C" \
00292 VTK_FACTORY_INTERFACE_EXPORT \
00293 const char* vtkGetFactoryCompilerUsed() \
00294 { \
00295 return VTK_CXX_COMPILER; \
00296 } \
00297 extern "C" \
00298 VTK_FACTORY_INTERFACE_EXPORT \
00299 const char* vtkGetFactoryVersion() \
00300 { \
00301 return VTK_SOURCE_VERSION; \
00302 } \
00303 extern "C" \
00304 VTK_FACTORY_INTERFACE_EXPORT \
00305 vtkObjectFactory* vtkLoad() \
00306 { \
00307 return factoryName ::New(); \
00308 }