I think this is the proper way doing PIMPL

This commit is contained in:
Li-Ta Lo 2023-05-10 20:05:34 -06:00
parent 6e75be33ec
commit 066e6a6969
2 changed files with 14 additions and 5 deletions

@ -42,6 +42,8 @@ ScalarRenderer::ScalarRenderer()
{
}
ScalarRenderer::ScalarRenderer(ScalarRenderer&&) noexcept = default;
ScalarRenderer& ScalarRenderer::operator=(ScalarRenderer&&) noexcept = default;
ScalarRenderer::~ScalarRenderer() = default;
void ScalarRenderer::SetWidth(const vtkm::Int32 width)

@ -25,11 +25,18 @@ class VTKM_RENDERING_EXPORT ScalarRenderer
public:
ScalarRenderer();
// Note: since we are using std::unique_ptr<T> for PIMPL, the compiler does
// not know the real size of std::unique_ptr<T> at this point. Thus, we
// can not have the definition of the destructor here. We need to declare it
// here and have an implementation in .cxx. The implementation could just
// be = default.
// Disable copying due to unique_ptr;
ScalarRenderer(const ScalarRenderer&) = delete;
ScalarRenderer& operator=(const ScalarRenderer&) = delete;
// Note: we are using std::unique_ptr<SomeIncompleteType> with default deleter for PIMPL,
// the compiler does not know how to delete SomeIncompleteType* at this point. Thus, we
// can not omit the declaration of destructor, move assignment operator and let the
// compiler generate implicit default version (which it can't.) We also can not have
// inline definitions of them here. We need to declare them here and have definitions in
// .cxx where SomeIncompleteType becomes complete. The implementations could just be = default.
ScalarRenderer(ScalarRenderer&&) noexcept;
ScalarRenderer& operator=(ScalarRenderer&&) noexcept;
~ScalarRenderer();
void SetInput(vtkm::cont::DataSet& dataSet);