00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00043 #ifndef __vtkObjectFactory_h
00044 #define __vtkObjectFactory_h
00045
00046
00047
00048
00049 #include "vtkObject.h"
00050
00051 class vtkObjectFactoryCollection;
00052 class vtkOverrideInformationCollection;
00053 class vtkCollection;
00054
00055 class VTK_COMMON_EXPORT vtkObjectFactory : public vtkObject
00056 {
00057 public:
00058
00059
00064 static vtkObject* CreateInstance(const char* vtkclassname);
00065
00067
00070 static void CreateAllInstance(const char* vtkclassname,
00071 vtkCollection* retList);
00072
00073
00074
00075 static void ReHash();
00076
00077
00078 static void RegisterFactory(vtkObjectFactory* );
00079
00080
00081 static void UnRegisterFactory(vtkObjectFactory*);
00082
00083
00084 static void UnRegisterAllFactories();
00086
00089 static vtkObjectFactoryCollection* GetRegisteredFactories();
00090
00093 static int HasOverrideAny(const char* className);
00094
00096
00098 static void GetOverrideInformation(const char* name,
00099 vtkOverrideInformationCollection*);
00101
00103
00105 static void SetAllEnableFlags(int flag,
00106 const char* className);
00107
00108
00109
00110 static void SetAllEnableFlags(int flag,
00111 const char* className,
00112 const char* subclassName);
00114
00115
00116
00117
00118 vtkTypeRevisionMacro(vtkObjectFactory,vtkObject);
00120 virtual void PrintSelf(ostream& os, vtkIndent indent);
00121
00128 virtual const char* GetVTKSourceVersion() = 0;
00129
00131 virtual const char* GetDescription() = 0;
00132
00134 virtual int GetNumberOfOverrides();
00135
00137 virtual const char* GetClassOverrideName(int index);
00138
00141 virtual const char* GetClassOverrideWithName(int index);
00142
00144 virtual int GetEnableFlag(int index);
00145
00147 virtual const char* GetOverrideDescription(int index);
00148
00150
00152 virtual void SetEnableFlag(int flag,
00153 const char* className,
00154 const char* subclassName);
00155 virtual int GetEnableFlag(const char* className,
00156 const char* subclassName);
00158
00160
00161 virtual int HasOverride(const char* className);
00162
00163
00164 virtual int HasOverride(const char* className, const char* subclassName);
00166
00169 virtual void Disable(const char* className);
00170
00172
00173 vtkGetStringMacro(LibraryPath);
00175
00176
00177 typedef vtkObject* (*CreateFunction)();
00178
00179 protected:
00180
00181
00183
00184 void RegisterOverride(const char* classOverride,
00185 const char* overrideClassName,
00186 const char* description,
00187 int enableFlag,
00188 CreateFunction createFunction);
00190
00191
00192
00193
00197 virtual vtkObject* CreateObject(const char* vtkclassname );
00198
00199 vtkObjectFactory();
00200 ~vtkObjectFactory();
00201
00202 struct OverrideInformation
00203 {
00204 char* Description;
00205 char* OverrideWithName;
00206 int EnabledFlag;
00207 CreateFunction CreateCallback;
00208 };
00209
00210 OverrideInformation* OverrideArray;
00211 char** OverrideClassNames;
00212 int SizeOverrideArray;
00213 int OverrideArrayLength;
00214
00215 private:
00216 void GrowOverrideArray();
00217
00219
00221 static void Init();
00222
00223
00224 static void RegisterDefaults();
00225
00226
00227 static void LoadDynamicFactories();
00228
00229
00230 static void LoadLibrariesInPath( const char*);
00232
00233
00234 static vtkObjectFactoryCollection* RegisteredFactories;
00235
00236
00237
00238 void* LibraryHandle;
00239 char* LibraryVTKVersion;
00240 char* LibraryCompilerUsed;
00241 char* LibraryPath;
00242 private:
00243 vtkObjectFactory(const vtkObjectFactory&);
00244 void operator=(const vtkObjectFactory&);
00245 };
00246
00247
00248
00249
00250 #define VTK_CREATE_CREATE_FUNCTION(classname) \
00251 static vtkObject* vtkObjectFactoryCreate##classname() \
00252 { return classname::New(); }
00253
00254 #endif
00255
00256
00257 #ifdef _WIN32
00258 #define VTK_FACTORY_INTERFACE_EXPORT __declspec( dllexport )
00259 #else
00260 #define VTK_FACTORY_INTERFACE_EXPORT
00261 #endif
00262
00263
00264
00265
00266
00267
00268 #define VTK_FACTORY_INTERFACE_IMPLEMENT(factoryName) \
00269 extern "C" \
00270 VTK_FACTORY_INTERFACE_EXPORT \
00271 const char* vtkGetFactoryCompilerUsed() \
00272 { \
00273 return VTK_CXX_COMPILER; \
00274 } \
00275 extern "C" \
00276 VTK_FACTORY_INTERFACE_EXPORT \
00277 const char* vtkGetFactoryVersion() \
00278 { \
00279 return VTK_SOURCE_VERSION; \
00280 } \
00281 extern "C" \
00282 VTK_FACTORY_INTERFACE_EXPORT \
00283 vtkObjectFactory* vtkLoad() \
00284 { \
00285 return factoryName ::New(); \
00286 }