153#ifndef vtkObjectFactory_h
154#define vtkObjectFactory_h
156#include "vtkCommonCoreModule.h"
158#include "vtkFeatures.h"
164VTK_ABI_NAMESPACE_BEGIN
298 const
char* className, const
char* subclassName) VTK_FUTURE_CONST;
363 const
char* description,
int enableFlag,
CreateFunction createFunction,
391 void GrowOverrideArray();
401 static void RegisterDefaults();
405 static void LoadDynamicFactories();
409 static void LoadLibrariesInPath(
const std::string&);
417 char* LibraryVTKVersion;
420 static std::string Preferences;
442#define VTK_CREATE_CREATE_FUNCTION(classname) \
443 static vtkObject* vtkObjectFactoryCreate##classname() \
445 return classname::New(); \
451#define VTK_FACTORY_INTERFACE_EXPORT VTKCOMMONCORE_EXPORT
458#define VTK_FACTORY_INTERFACE_IMPLEMENT(factoryName) \
459 extern "C" VTK_FACTORY_INTERFACE_EXPORT const char* vtkGetFactoryVersion() \
461 return VTK_SOURCE_VERSION; \
463 extern "C" VTK_FACTORY_INTERFACE_EXPORT vtkObjectFactory* vtkLoad() \
465 return factoryName ::New(); \
469#define VTK_OBJECT_FACTORY_NEW_BODY(thisClass) \
470 vtkObject* ret = vtkObjectFactory::CreateInstance(#thisClass, false); \
473 return static_cast<thisClass*>(ret); \
475 auto result = new thisClass; \
476 result->InitializeObjectBase(); \
482#define VTK_ABSTRACT_OBJECT_FACTORY_NEW_BODY(thisClass) \
483 vtkObject* ret = vtkObjectFactory::CreateInstance(#thisClass, true); \
486 return static_cast<thisClass*>(ret); \
488 vtkGenericWarningMacro("Error: no override found for '" #thisClass "'."); \
492#if defined(VTK_ALL_NEW_OBJECT_FACTORY)
493#define VTK_STANDARD_NEW_BODY(thisClass) VTK_OBJECT_FACTORY_NEW_BODY(thisClass)
495#define VTK_STANDARD_NEW_BODY(thisClass) \
496 auto result = new thisClass; \
497 result->InitializeObjectBase(); \
502#define vtkStandardNewMacro(thisClass) \
503 thisClass* thisClass::New() \
505 VTK_STANDARD_NEW_BODY(thisClass); \
510#define vtkStandardExtendedNewMacro(thisClass) \
511 thisClass* thisClass::ExtendedNew() \
513 auto mkhold = vtkMemkindRAII(true); \
515 return thisClass::New(); \
519#define vtkObjectFactoryNewMacro(thisClass) \
520 thisClass* thisClass::New() \
522 VTK_OBJECT_FACTORY_NEW_BODY(thisClass); \
528#define vtkAbstractObjectFactoryNewMacro(thisClass) \
529 thisClass* thisClass::New() \
531 VTK_ABSTRACT_OBJECT_FACTORY_NEW_BODY(thisClass); \
create and manipulate ordered lists of objects
a simple class to control print indentation
maintain a list of object factories
vtkObjectFactoryRegistryCleanup()
~vtkObjectFactoryRegistryCleanup()
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 vtkObject * CreateInstance(const char *vtkclassname, bool isAbstract=false)
Create and return an instance of the named vtk object.
static vtkObjectFactoryCollection * GetRegisteredFactories()
Return the list of all registered factories.
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 vtkTypeBool HasOverride(const char *className) VTK_FUTURE_CONST
Return 1 if this factory overrides the given class name, 0 otherwise.
virtual void SetEnableFlag(vtkTypeBool flag, const char *className, const char *subclassName)
Set and Get the Enable flag for the specific override of className.
vtkOverrideAttribute * GetOverrideAttributes(int index) const
Get override attributes if any for the factory at the given index.
virtual vtkTypeBool GetEnableFlag(int index) VTK_FUTURE_CONST
Return the enable flag for the class at the given index.
static void CreateAllInstance(const char *vtkclassname, vtkCollection *retList)
Create all possible instances of the named vtk object.
static vtkTypeBool HasOverrideAny(const char *className)
return 1 if one of the registered factories overrides the given class name
virtual const char * GetClassOverrideWithName(int index) VTK_FUTURE_CONST
Return the name of the class that will override the class at the given index.
OverrideInformation * OverrideArray
void RegisterOverride(const char *classOverride, const char *overrideClassName, const char *description, int enableFlag, CreateFunction createFunction, vtkOverrideAttribute *attributes=nullptr)
Register object creation information with the factory.
static void UnRegisterFactory(vtkObjectFactory *)
Remove a factory from the list of registered factories.
static std::string GetPreferences()
virtual const char * GetOverrideDescription(int index) VTK_FUTURE_CONST
Return the description for a the class override at the given index.
virtual const char * GetDescription() VTK_FUTURE_CONST=0
Return a descriptive string describing the factory.
vtkObject *(* CreateFunction)()
virtual vtkObject * CreateObject(const char *vtkclassname)
This method is provided by sub-classes of vtkObjectFactory.
static void ReHash()
Re-check the VTK_AUTOLOAD_PATH for new factory libraries.
static void SetPreferences(std::string preferences)
Set preferences string.
virtual int GetNumberOfOverrides() VTK_FUTURE_CONST
Return number of overrides this factory can create.
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.
static bool InitializePreferencesFromCommandLineArgs(int &argc, char *argv[])
Initialize preferences from command line arguments.
virtual const char * GetClassOverrideName(int index) VTK_FUTURE_CONST
Return the name of a class override at the given index.
static void RegisterFactory(vtkObjectFactory *)
Register a factory so it can be used to create vtk objects.
virtual const char * GetVTKSourceVersion() VTK_FUTURE_CONST=0
All sub-classes of vtkObjectFactory should must return the version of VTK they were built with.
vtkGetFilePathMacro(LibraryPath)
This returns the path to a dynamically loaded factory.
Attribute for vtkObjectFactory overrides.
Hold a reference to a vtkObjectBase instance.
static vtkObjectFactoryRegistryCleanup vtkObjectFactoryRegistryCleanupInstance