41#ifndef vtkObjectFactory_h
42#define vtkObjectFactory_h
45#include "vtkCommonCoreModule.h"
68 bool isAbstract =
false);
128 const char* className);
134 const char* className,
135 const char* subclassName);
193 const char* className,
194 const char* subclassName);
196 const char* subclassName);
206 virtual int HasOverride(
const char* className,
const char* subclassName);
230 const char* overrideClassName,
233 CreateFunction createFunction);
259 void GrowOverrideArray();
269 static void RegisterDefaults();
273 static void LoadDynamicFactories();
277 static void LoadLibrariesInPath(
const char*);
285 char* LibraryVTKVersion;
286 char* LibraryCompilerUsed;
310#define VTK_CREATE_CREATE_FUNCTION(classname) \
311static vtkObject* vtkObjectFactoryCreate##classname() \
312{ return classname::New(); }
316#define VTK_FACTORY_INTERFACE_EXPORT VTKCOMMONCORE_EXPORT
323#define VTK_FACTORY_INTERFACE_IMPLEMENT(factoryName) \
325VTK_FACTORY_INTERFACE_EXPORT \
326const char* vtkGetFactoryCompilerUsed() \
328 return VTK_CXX_COMPILER; \
331VTK_FACTORY_INTERFACE_EXPORT \
332const char* vtkGetFactoryVersion() \
334 return VTK_SOURCE_VERSION; \
337VTK_FACTORY_INTERFACE_EXPORT \
338vtkObjectFactory* vtkLoad() \
340 return factoryName ::New(); \
344#define VTK_OBJECT_FACTORY_NEW_BODY(thisClass) \
345 vtkObject* ret = vtkObjectFactory::CreateInstance(#thisClass, false); \
348 return static_cast<thisClass*>(ret); \
350 thisClass *result = new thisClass; \
351 result->InitializeObjectBase(); \
357#define VTK_ABSTRACT_OBJECT_FACTORY_NEW_BODY(thisClass) \
358 vtkObject* ret = vtkObjectFactory::CreateInstance(#thisClass, true); \
361 return static_cast<thisClass*>(ret); \
363 vtkGenericWarningMacro("Error: no override found for '" #thisClass "'."); \
367#if defined(VTK_ALL_NEW_OBJECT_FACTORY)
368# define VTK_STANDARD_NEW_BODY(thisClass) \
369 VTK_OBJECT_FACTORY_NEW_BODY(thisClass)
371# define VTK_STANDARD_NEW_BODY(thisClass) \
372 thisClass *result = new thisClass; \
373 result->InitializeObjectBase(); \
378#define vtkStandardNewMacro(thisClass) \
379 thisClass* thisClass::New() \
381 VTK_STANDARD_NEW_BODY(thisClass) \
385#define vtkObjectFactoryNewMacro(thisClass) \
386 thisClass* thisClass::New() \
388 VTK_OBJECT_FACTORY_NEW_BODY(thisClass) \
394#define vtkAbstractObjectFactoryNewMacro(thisClass) \
395 thisClass* thisClass::New() \
397 VTK_ABSTRACT_OBJECT_FACTORY_NEW_BODY(thisClass) \
create and manipulate unsorted lists of objects
a simple class to control print indentation
maintain a list of object factories
vtkObjectFactoryRegistryCleanup()
~vtkObjectFactoryRegistryCleanup()
abstract base class for vtkObjectFactories
virtual const char * GetClassOverrideWithName(int index)
Return the name of the class that will override the class at the given index.
virtual const char * GetDescription()=0
Return a descriptive string describing the factory.
virtual void Disable(const char *className)
Set all enable flags for the given class to 0.
void PrintSelf(ostream &os, vtkIndent indent) override
Print ObjectFactory to stream.
static void SetAllEnableFlags(vtkTypeBool flag, const char *className)
Set the enable flag for a given named class for all registered factories.
static void ConstructInstance(const char *vtkclassname)
No longer used.
virtual vtkTypeBool GetEnableFlag(int index)
Return the enable flag for the class at the given index.
virtual const char * GetVTKSourceVersion()=0
All sub-classes of vtkObjectFactory should must return the version of VTK they were built with.
virtual const char * GetClassOverrideName(int index)
Return the name of a class override at the given index.
static vtkObjectFactoryCollection * GetRegisteredFactories()
Return the list of all registered factories.
virtual int GetNumberOfOverrides()
Return number of overrides this factory can create.
static void GetOverrideInformation(const char *name, vtkOverrideInformationCollection *)
Fill the given collection with all the overrides for the class with the given name.
char ** OverrideClassNames
virtual void SetEnableFlag(vtkTypeBool flag, const char *className, const char *subclassName)
Set and Get the Enable flag for the specific override of className.
virtual const char * GetOverrideDescription(int index)
Return the description for a the class override at the given index.
static void CreateAllInstance(const char *vtkclassname, vtkCollection *retList)
Create all possible instances of the named vtk object.
OverrideInformation * OverrideArray
static void UnRegisterFactory(vtkObjectFactory *)
Remove a factory from the list of registered factories.
void RegisterOverride(const char *classOverride, const char *overrideClassName, const char *description, int enableFlag, CreateFunction createFunction)
Register object creation information with the factory.
virtual vtkTypeBool GetEnableFlag(const char *className, const char *subclassName)
static int HasOverrideAny(const char *className)
return 1 if one of the registered factories overrides the given class name
virtual vtkObject * CreateObject(const char *vtkclassname)
This method is provided by sub-classes of vtkObjectFactory.
virtual int HasOverride(const char *className)
Return 1 if this factory overrides the given class name, 0 otherwise.
static void ReHash()
Re-check the VTK_AUTOLOAD_PATH for new factory libraries.
static void UnRegisterAllFactories()
Unregister all factories.
static void SetAllEnableFlags(vtkTypeBool flag, const char *className, const char *subclassName)
Set the enable flag for a given named class subclass pair for all registered factories.
~vtkObjectFactory() override
static void RegisterFactory(vtkObjectFactory *)
Register a factory so it can be used to create vtk objects.
virtual int HasOverride(const char *className, const char *subclassName)
Return 1 if this factory overrides the given class name, 0 otherwise.
static VTK_NEWINSTANCE vtkObject * CreateInstance(const char *vtkclassname, bool isAbstract=false)
Create and return an instance of the named vtk object.
abstract base class for most VTK objects
static vtkObjectFactoryRegistryCleanup vtkObjectFactoryRegistryCleanupInstance
vtkGetStringMacro(ExtensionsString)
Returns a string listing all available extensions.