Sorry to reopen this thread 3 years later, I plan to update the coding_convention
of VTK to add the standard way to implement a PIMPL in VTK.
I also have a potential improvement for the Utkarsh approach. It concerns the vtkInternals
class which could be in his own header/source file and these files could be in a Private
folder. We will have something like that:
////-------------------------
/// vtkClass.h
#include <memory> // for std::unique_ptr
class vtkClassInternals;
class vtkClass : public vtkObject
{
private:
std::unique_ptr<vtkClassInternals> Internals;
}
////-------------------------
/// vtkClass.cpp
#include "Private/vtkClassInternals.h"
vtkClass::vtkClass()
: Internals(new vtkClass::vtkInternals())
{
this->Internals = std::make_unique<vtkClassInternals>();
}
vtkClass::~vtkClass() = default;
note that this is what it is already done in the WebGPU module to separate internals stuff which will not be part of the public API.
wdyt?