vtkObjectFactory.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00044 #ifndef __vtkObjectFactory_h
00045 #define __vtkObjectFactory_h
00046
00047
00048
00049
00050 #include "vtkObject.h"
00051
00052 class vtkObjectFactoryCollection;
00053 class vtkOverrideInformationCollection;
00054 class vtkCollection;
00055
00056 class VTK_COMMON_EXPORT vtkObjectFactory : public vtkObject
00057 {
00058 public:
00059
00060
00065 static vtkObject* CreateInstance(const char* vtkclassname);
00066
00068
00071 static void CreateAllInstance(const char* vtkclassname,
00072 vtkCollection* retList);
00073
00074
00075
00076 static void ReHash();
00077
00078
00079 static void RegisterFactory(vtkObjectFactory* );
00080
00081
00082 static void UnRegisterFactory(vtkObjectFactory*);
00083
00084
00085 static void UnRegisterAllFactories();
00087
00090 static vtkObjectFactoryCollection* GetRegisteredFactories();
00091
00094 static int HasOverrideAny(const char* className);
00095
00097
00099 static void GetOverrideInformation(const char* name,
00100 vtkOverrideInformationCollection*);
00102
00104
00106 static void SetAllEnableFlags(int flag,
00107 const char* className);
00108
00109
00110
00111 static void SetAllEnableFlags(int flag,
00112 const char* className,
00113 const char* subclassName);
00115
00116
00117
00118
00119 vtkTypeRevisionMacro(vtkObjectFactory,vtkObject);
00121 virtual void PrintSelf(ostream& os, vtkIndent indent);
00122
00129 virtual const char* GetVTKSourceVersion() = 0;
00130
00132 virtual const char* GetDescription() = 0;
00133
00135 virtual int GetNumberOfOverrides();
00136
00138 virtual const char* GetClassOverrideName(int index);
00139
00142 virtual const char* GetClassOverrideWithName(int index);
00143
00145 virtual int GetEnableFlag(int index);
00146
00148 virtual const char* GetOverrideDescription(int index);
00149
00151
00153 virtual void SetEnableFlag(int flag,
00154 const char* className,
00155 const char* subclassName);
00156 virtual int GetEnableFlag(const char* className,
00157 const char* subclassName);
00159
00161
00162 virtual int HasOverride(const char* className);
00163
00164
00165 virtual int HasOverride(const char* className, const char* subclassName);
00167
00170 virtual void Disable(const char* className);
00171
00173
00174 vtkGetStringMacro(LibraryPath);
00176
00177
00178 typedef vtkObject* (*CreateFunction)();
00179
00180 protected:
00181
00182
00184
00185 void RegisterOverride(const char* classOverride,
00186 const char* overrideClassName,
00187 const char* description,
00188 int enableFlag,
00189 CreateFunction createFunction);
00191
00192
00193
00194
00198 virtual vtkObject* CreateObject(const char* vtkclassname );
00199
00200 vtkObjectFactory();
00201 ~vtkObjectFactory();
00202
00203 struct OverrideInformation
00204 {
00205 char* Description;
00206 char* OverrideWithName;
00207 int EnabledFlag;
00208 CreateFunction CreateCallback;
00209 };
00210
00211 OverrideInformation* OverrideArray;
00212 char** OverrideClassNames;
00213 int SizeOverrideArray;
00214 int OverrideArrayLength;
00215
00216 private:
00217 void GrowOverrideArray();
00218
00220
00222 static void Init();
00223
00224
00225 static void RegisterDefaults();
00226
00227
00228 static void LoadDynamicFactories();
00229
00230
00231 static void LoadLibrariesInPath( const char*);
00233
00234
00235 static vtkObjectFactoryCollection* RegisteredFactories;
00236
00237
00238
00239 void* LibraryHandle;
00240 char* LibraryVTKVersion;
00241 char* LibraryCompilerUsed;
00242 char* LibraryPath;
00243 private:
00244 vtkObjectFactory(const vtkObjectFactory&);
00245 void operator=(const vtkObjectFactory&);
00246 };
00247
00248
00249
00250
00251 #define VTK_CREATE_CREATE_FUNCTION(classname) \
00252 static vtkObject* vtkObjectFactoryCreate##classname() \
00253 { return classname::New(); }
00254
00255 #endif
00256
00257
00258 #ifdef _WIN32
00259 #define VTK_FACTORY_INTERFACE_EXPORT __declspec( dllexport )
00260 #else
00261 #define VTK_FACTORY_INTERFACE_EXPORT
00262 #endif
00263
00264
00265
00266
00267
00268
00269 #define VTK_FACTORY_INTERFACE_IMPLEMENT(factoryName) \
00270 extern "C" \
00271 VTK_FACTORY_INTERFACE_EXPORT \
00272 const char* vtkGetFactoryCompilerUsed() \
00273 { \
00274 return VTK_CXX_COMPILER; \
00275 } \
00276 extern "C" \
00277 VTK_FACTORY_INTERFACE_EXPORT \
00278 const char* vtkGetFactoryVersion() \
00279 { \
00280 return VTK_SOURCE_VERSION; \
00281 } \
00282 extern "C" \
00283 VTK_FACTORY_INTERFACE_EXPORT \
00284 vtkObjectFactory* vtkLoad() \
00285 { \
00286 return factoryName ::New(); \
00287 }