38 #ifndef vtkObjectFactory_h
39 #define vtkObjectFactory_h
41 #include "vtkCommonCoreModule.h"
43 #include "vtkFeatures.h"
48 VTK_ABI_NAMESPACE_BEGIN
213 const char*
description,
int enableFlag, CreateFunction createFunction);
239 void GrowOverrideArray();
249 static void RegisterDefaults();
253 static void LoadDynamicFactories();
257 static void LoadLibrariesInPath(
const std::string&);
265 char* LibraryVTKVersion;
288 #define VTK_CREATE_CREATE_FUNCTION(classname) \
289 static vtkObject* vtkObjectFactoryCreate##classname() { return classname::New(); }
291 VTK_ABI_NAMESPACE_END
294 #define VTK_FACTORY_INTERFACE_EXPORT VTKCOMMONCORE_EXPORT
301 #define VTK_FACTORY_INTERFACE_IMPLEMENT(factoryName) \
302 extern "C" VTK_FACTORY_INTERFACE_EXPORT const char* vtkGetFactoryVersion() \
304 return VTK_SOURCE_VERSION; \
306 extern "C" VTK_FACTORY_INTERFACE_EXPORT vtkObjectFactory* vtkLoad() \
308 return factoryName ::New(); \
312 #define VTK_OBJECT_FACTORY_NEW_BODY(thisClass) \
313 vtkObject* ret = vtkObjectFactory::CreateInstance(#thisClass, false); \
316 return static_cast<thisClass*>(ret); \
318 auto result = new thisClass; \
319 result->InitializeObjectBase(); \
325 #define VTK_ABSTRACT_OBJECT_FACTORY_NEW_BODY(thisClass) \
326 vtkObject* ret = vtkObjectFactory::CreateInstance(#thisClass, true); \
329 return static_cast<thisClass*>(ret); \
331 vtkGenericWarningMacro("Error: no override found for '" #thisClass "'."); \
335 #if defined(VTK_ALL_NEW_OBJECT_FACTORY)
336 #define VTK_STANDARD_NEW_BODY(thisClass) VTK_OBJECT_FACTORY_NEW_BODY(thisClass)
338 #define VTK_STANDARD_NEW_BODY(thisClass) \
339 auto result = new thisClass; \
340 result->InitializeObjectBase(); \
345 #define vtkStandardNewMacro(thisClass) \
346 thisClass* thisClass::New() { VTK_STANDARD_NEW_BODY(thisClass); }
350 #define vtkStandardExtendedNewMacro(thisClass) \
351 thisClass* thisClass::ExtendedNew() \
353 auto mkhold = vtkMemkindRAII(true); \
355 return thisClass::New(); \
359 #define vtkObjectFactoryNewMacro(thisClass) \
360 thisClass* thisClass::New() { VTK_OBJECT_FACTORY_NEW_BODY(thisClass); }
365 #define vtkAbstractObjectFactoryNewMacro(thisClass) \
366 thisClass* thisClass::New() { 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()
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 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.
virtual vtkTypeBool GetEnableFlag(int index)
Return the enable flag for the class at the given index.
virtual vtkTypeBool HasOverride(const char *className)
Return 1 if this factory overrides the given class name, 0 otherwise.
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 vtkObject * CreateObject(const char *vtkclassname)
This method is provided by sub-classes of vtkObjectFactory.
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.
static vtkTypeBool HasOverrideAny(const char *className)
return 1 if one of the registered factories overrides the given class name
static vtkObjectFactoryCollection * GetRegisteredFactories()
Return the list of all registered factories.
OverrideInformation * OverrideArray
virtual vtkTypeBool HasOverride(const char *className, const char *subclassName)
Return 1 if this factory overrides the given class name, 0 otherwise.
virtual const char * GetDescription()=0
Return a descriptive string describing the factory.
static void UnRegisterFactory(vtkObjectFactory *)
Remove a factory from the list of registered factories.
virtual const char * GetVTKSourceVersion()=0
All sub-classes of vtkObjectFactory should must return the version of VTK they were built with.
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)
Set and Get the Enable flag for the specific override of className.
static vtkObject * CreateInstance(const char *vtkclassname, bool isAbstract=false)
Create and return an instance of the named vtk object.
virtual const char * GetClassOverrideName(int index)
Return the name of a class override at the given index.
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.
vtkGetFilePathMacro(LibraryPath)
This returns the path to a dynamically loaded factory.
abstract base class for most VTK objects
static vtkObjectFactoryRegistryCleanup vtkObjectFactoryRegistryCleanupInstance