Commit 11bb6a4d authored by Ben Boeckel's avatar Ben Boeckel
Browse files

vtkInstantiator: deprecate

Only warn on the `CreateInstance` method since that is the user-facing
API.
parent 9c463378
......@@ -221,7 +221,6 @@ SET(Module_SRCS
vtkInformationVariantKey.cxx
vtkInformationVariantVectorKey.cxx
vtkInformationVector.cxx
vtkInstantiator.cxx
vtkIntArray.cxx
vtkLargeInteger.cxx
vtkLongArray.cxx
......@@ -292,6 +291,11 @@ SET(Module_SRCS
${CMAKE_CURRENT_BINARY_DIR}/vtkVersionMacros.h
)
if (NOT VTK_LEGACY_REMOVE)
list(APPEND Module_SRCS
vtkInstantiator.cxx)
endif ()
set(${vtk-module}_HDRS
vtkABI.h
vtkAngularPeriodicDataArray.h
......
......@@ -262,6 +262,7 @@ void vtkInstantiator::PrintSelf(ostream& os, vtkIndent indent)
//----------------------------------------------------------------------------
vtkObject* vtkInstantiator::CreateInstance(const char* className)
{
VTK_LEGACY_BODY(vtkInstantiator::CreateInstance, "VTK 8.1");
CreateFunction function = vtkInstantiator::CreatorTable->Find(className);
if(function) { return function(); }
return nullptr;
......
......@@ -59,6 +59,8 @@
#include "vtkCommonCoreModule.h" // For export macro
#include "vtkObject.h"
#ifndef VTK_LEGACY_REMOVE
// The vtkDebugLeaks singleton must be initialized before and
// destroyed after the vtkInstantiator singleton.
#include "vtkDebugLeaksManager.h" // Needed for proper singleton initialization
......@@ -136,3 +138,4 @@ private:
static vtkInstantiatorInitialize vtkInstantiatorInitializer;
#endif
#endif
......@@ -716,6 +716,7 @@ virtual double *Get##name() \
} \
public:
#ifndef VTK_LEGACY_REMOVE
// Macro to implement the instantiator's wrapper around the New()
// method. Use this macro if and only if vtkStandardNewMacro or
// vtkObjectFactoryNewMacro is not used by the class.
......@@ -725,6 +726,7 @@ virtual double *Get##name() \
{ \
return thisClass::New(); \
}
#endif
// NOTE: This is no longer the prefer method for dispatching an array to a
// worker template. See vtkArrayDispatch for the new approach.
......
......@@ -14,7 +14,9 @@ PURPOSE. See the above copyright notice for more information.
=========================================================================*/
#include "vtkDataObjectTypes.h"
#ifndef VTK_LEGACY_REMOVE
#include "vtkInstantiator.h"
#endif
#include "vtkObjectFactory.h"
#include "vtkAnnotation.h"
......@@ -274,6 +276,7 @@ vtkDataObject* vtkDataObjectTypes::NewDataObject(const char* type)
{
return vtkPath::New();
}
#ifndef VTK_LEGACY_REMOVE
else if(vtkObject* obj = vtkInstantiator::CreateInstance(type))
{
vtkDataObject* data = vtkDataObject::SafeDownCast(obj);
......@@ -289,6 +292,7 @@ vtkDataObject* vtkDataObjectTypes::NewDataObject(const char* type)
}
return data;
}
#endif
vtkGenericWarningMacro("NewDataObject(): You are trying to instantiate DataObjectType \"" << type
<< "\" which does not exist.");
......
......@@ -31,7 +31,6 @@
#include "vtkInformationRequestKey.h"
#include "vtkInformationUnsignedLongKey.h"
#include "vtkInformationVector.h"
#include "vtkInstantiator.h"
#include "vtkObjectFactory.h"
#include "vtkPointData.h"
......
......@@ -24,7 +24,9 @@
#include "vtkInformationIntegerKey.h"
#include "vtkInformationIntegerVectorKey.h"
#include "vtkInformationVector.h"
#ifndef VTK_LEGACY_REMOVE
#include "vtkInstantiator.h"
#endif
#include "vtkMultiBlockDataSet.h"
#include "vtkNew.h"
#include "vtkObjectFactory.h"
......@@ -192,11 +194,13 @@ vtkXMLReader* vtkXMLCompositeDataReader::GetReaderOfType(const char* type)
{
reader = vtkXMLStructuredGridReader::New();
}
#ifndef VTK_LEGACY_REMOVE
if (!reader)
{
// If all fails, Use the instantiator to create the reader.
reader = vtkXMLReader::SafeDownCast(vtkInstantiator::CreateInstance(type));
}
#endif
if (reader)
{
if (this->GetParserErrorObserver())
......
......@@ -32,7 +32,9 @@
#include "vtkInformationStringVectorKey.h"
#include "vtkInformationUnsignedLongKey.h"
#include "vtkInformationVector.h"
#ifndef VTK_LEGACY_REMOVE
#include "vtkInstantiator.h"
#endif
#include "vtkLZ4DataCompressor.h"
#include "vtkObjectFactory.h"
#include "vtkQuadratureSchemeDefinition.h"
......@@ -402,7 +404,11 @@ void vtkXMLReader::SetupCompressor(const char* type)
vtkErrorMacro("Compressor has no type.");
return;
}
#ifndef VTK_LEGACY_REMOVE
vtkObject* object = vtkInstantiator::CreateInstance(type);
#else
vtkObject* object = nullptr;
#endif
vtkDataCompressor* compressor = vtkDataCompressor::SafeDownCast(object);
// In static builds, the vtkZLibDataCompressor may not have been
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment