Commit bcf798e7 authored by Hans Johnson's avatar Hans Johnson

COMP: Add more C++11 override instrumentation

Providing override key work allows for extra checking
that the function signatures are correct.

https://stackoverflow.com/questions/39932391/virtual-override-or-both-c?answertab=active#tab-top

In the derived class the function is virtual by way of having the ¹same
type as the base class function.

However, an override can help avoid bugs by producing a compilation
error when the intended override isn't technically an override. E.g.
that the function type isn't exactly like the base class function. Or
that a maintenance of the base class changes that function's type, e.g.
adding a defaulted argument.

In the same way, a virtual keyword in the derived class can make such a
bug more subtle, by ensuring that the function is still virtual in
further derived classes.

The general advice is,
     -Use virtual for the base class function declaration.
      This is technically necessary.

     -Use override (only) for a derived class' override.
      This helps maintenance.
parent 9712f493
......@@ -128,7 +128,7 @@ public:
{
public:
StaticMemoryBlock(T* const storage);
virtual T* GetAddress();
T* GetAddress() override;
//@}
private:
......
......@@ -49,20 +49,20 @@ public:
void SetMappedUnstructuredGrid(vtkMappedUnstructuredGrid<I, ThisType> *grid);
virtual void PrintSelf(std::ostream& os, vtkIndent id) override;
void PrintSelf(std::ostream& os, vtkIndent id) override;
virtual bool IsDoneWithTraversal() override;
virtual vtkIdType GetCellId() override;
bool IsDoneWithTraversal() override;
vtkIdType GetCellId() override;
protected:
MappedCellIterator();
~MappedCellIterator() override;
virtual void ResetToFirstCell() override { this->CellId = 0; }
virtual void IncrementToNextCell() override { this->CellId++; }
virtual void FetchCellType() override;
virtual void FetchPointIds() override;
virtual void FetchPoints() override;
virtual void FetchFaces() override;
void ResetToFirstCell() override { this->CellId = 0; }
void IncrementToNextCell() override { this->CellId++; }
void FetchCellType() override;
void FetchPointIds() override;
void FetchPoints() override;
void FetchFaces() override;
private:
MappedCellIterator(const MappedCellIterator&) VTK_DELETE_FUNCTION;
......@@ -185,7 +185,7 @@ public:
protected:
MappedGridImpl(){}
virtual ~MappedGridImpl() override { _grid->UnRegister(this); }
~MappedGridImpl() override { _grid->UnRegister(this); }
private:
vtkUnstructuredGrid* _grid;
......
......@@ -126,11 +126,11 @@ public:
typedef typename Base::Parm1 Parm1;
FunctorHandler(Fun& fun) : f_(fun) {}
virtual ~FunctorHandler() {}
~FunctorHandler() override {}
ResultType operator()(Parm1& p1)
ResultType operator()(Parm1& p1) override
{ return f_(p1); }
virtual FunctorHandler* DoClone() const { return new FunctorHandler(*this); }
FunctorHandler* DoClone() const override { return new FunctorHandler(*this); }
private:
Fun f_;
......@@ -282,12 +282,12 @@ public:
typedef typename Base::Parm2 Parm2;
FunctorHandler(const Fun& fun) : f_(fun) {}
virtual ~FunctorHandler() {}
~FunctorHandler() override {}
ResultType operator()(Parm1& p1,Parm2& p2)
ResultType operator()(Parm1& p1,Parm2& p2) override
{ return f_(p1,p2); }
virtual FunctorHandler* DoClone() const { return new FunctorHandler(*this); }
FunctorHandler* DoClone() const override { return new FunctorHandler(*this); }
private:
Fun f_;
......
......@@ -290,7 +290,7 @@ struct CellProcessor : public vtkCellProcessor
this->Offsets[this->NumBins] = this->NumFragments;
}
virtual ~CellProcessor()
~CellProcessor() override
{
delete [] this->Map;
delete [] this->Offsets;
......@@ -336,14 +336,14 @@ struct CellProcessor : public vtkCellProcessor
}
// Methods to satisfy vtkCellProcessor virtual API
virtual vtkIdType FindCell(double pos[3], vtkGenericCell *cell,
double pcoords[3], double* weights );
virtual void FindCellsWithinBounds(double *bbox, vtkIdList *cells);
virtual int IntersectWithLine(double a0[3], double a1[3], double tol,
vtkIdType FindCell(double pos[3], vtkGenericCell *cell,
double pcoords[3], double* weights ) override;
void FindCellsWithinBounds(double *bbox, vtkIdList *cells) override;
int IntersectWithLine(double a0[3], double a1[3], double tol,
double& t, double x[3], double pcoords[3],
int &subId, vtkIdType &cellId,
vtkGenericCell *cell);
virtual int IsEmpty(vtkIdType binId)
vtkGenericCell *cell) override;
int IsEmpty(vtkIdType binId) override
{
return ( this->GetNumberOfIds(static_cast<T>(binId)) > 0 ? 0 : 1 );
}
......
......@@ -85,7 +85,7 @@ public:
/**
* See vtkAlgorithm for details
*/
virtual int ProcessRequest( vtkInformation*,
int ProcessRequest( vtkInformation*,
vtkInformationVector**,
vtkInformationVector*) override;
......
......@@ -36,7 +36,7 @@ class GraphAnimate : public vtkCommand
public:
static GraphAnimate *New() { return new GraphAnimate(); }
vtkTypeMacro(GraphAnimate, vtkCommand);
virtual void Execute(vtkObject *, unsigned long, void *) override
void Execute(vtkObject *, unsigned long, void *) override
{
this->GraphItem->UpdatePositions();
this->View->Render();
......
......@@ -34,7 +34,7 @@ class vtkGraphItem : public vtkContextItem
{
public:
vtkTypeMacro(vtkGraphItem, vtkContextItem);
virtual void PrintSelf(ostream &os, vtkIndent indent) override;
void PrintSelf(ostream &os, vtkIndent indent) override;
static vtkGraphItem *New();
......@@ -44,37 +44,37 @@ public:
/**
* Paint event for the item.
*/
virtual bool Paint(vtkContext2D *painter) override;
bool Paint(vtkContext2D *painter) override;
/**
* Returns true if the supplied x, y coordinate is inside the item.
*/
virtual bool Hit(const vtkContextMouseEvent &mouse) override;
bool Hit(const vtkContextMouseEvent &mouse) override;
/**
* Mouse enter event.
*/
virtual bool MouseEnterEvent(const vtkContextMouseEvent &mouse) override;
bool MouseEnterEvent(const vtkContextMouseEvent &mouse) override;
/**
* Mouse move event.
*/
virtual bool MouseMoveEvent(const vtkContextMouseEvent &mouse) override;
bool MouseMoveEvent(const vtkContextMouseEvent &mouse) override;
/**
* Mouse leave event.
*/
virtual bool MouseLeaveEvent(const vtkContextMouseEvent &mouse) override;
bool MouseLeaveEvent(const vtkContextMouseEvent &mouse) override;
/**
* Mouse button down event.
*/
virtual bool MouseButtonPressEvent(const vtkContextMouseEvent &mouse) override;
bool MouseButtonPressEvent(const vtkContextMouseEvent &mouse) override;
/**
* Mouse button release event.
*/
virtual bool MouseButtonReleaseEvent(const vtkContextMouseEvent &mouse) override;
bool MouseButtonReleaseEvent(const vtkContextMouseEvent &mouse) override;
void UpdatePositions();
......
......@@ -39,7 +39,7 @@ public:
{ return new vtkResliceCursorCallback; }
void Execute( vtkObject *caller, unsigned long ev,
void *callData )
void *callData ) override
{
if (ev == vtkResliceCursorWidget::WindowLevelEvent ||
......
......@@ -18,7 +18,7 @@ public:
// Constructor/Destructor
QtVTKRenderWindows(int argc, char *argv[]);
~QtVTKRenderWindows() {}
~QtVTKRenderWindows() override {}
public slots:
......
......@@ -33,7 +33,7 @@ public:
// Constructor/Destructor
SimpleView();
~SimpleView();
~SimpleView() override;
public slots:
......
......@@ -53,7 +53,7 @@ public:
// Constructor/Destructor
CustomLinkView();
~CustomLinkView();
~CustomLinkView() override;
public slots:
......
......@@ -52,7 +52,7 @@ public:
// Constructor/Destructor
EasyView();
~EasyView();
~EasyView() override;
public slots:
......
......@@ -34,7 +34,7 @@ public:
// Constructor/Destructor
StatsView();
~StatsView();
~StatsView() override;
public slots:
......
......@@ -313,7 +313,7 @@ struct PointSetFunctor : public CuttingFunctor
{
}
~PointSetFunctor()
~PointSetFunctor() override
{
if(this->Interpolate)
{
......
......@@ -387,8 +387,8 @@ public:
protected:
vtkFiberSurface();
virtual int FillInputPortInformation(int port, vtkInformation* info) override;
virtual int RequestData(vtkInformation*, vtkInformationVector**, vtkInformationVector*) override;
int FillInputPortInformation(int port, vtkInformation* info) override;
int RequestData(vtkInformation*, vtkInformationVector**, vtkInformationVector*) override;
// name of the input array names.
char* Fields[2];
......
......@@ -162,7 +162,7 @@ class ComputeTemperatureFunctor : public ComputeFunctor
public:
ComputeTemperatureFunctor(vtkMultiBlockPLOT3DReader* reader, vtkStructuredGrid* grid) : ComputeFunctor(reader, grid) {}
void operator()(vtkIdType begin, vtkIdType end)
void operator()(vtkIdType begin, vtkIdType end) override
{
double e, rr, u, v, w, v2, p, d, rrgas, m[3];
rrgas = 1.0 / Reader->R;
......@@ -193,7 +193,7 @@ class ComputePressureFunctor : public ComputeFunctor
public:
ComputePressureFunctor(vtkMultiBlockPLOT3DReader* reader, vtkStructuredGrid* grid) : ComputeFunctor(reader, grid) {}
void operator()(vtkIdType begin, vtkIdType end)
void operator()(vtkIdType begin, vtkIdType end) override
{
double e, rr, u, v, w, v2, p, d, m[3];
for (vtkIdType i = begin; i < end; ++i)
......@@ -223,7 +223,7 @@ class ComputePressureCoefficientFunctor : public ComputeFunctor
public:
ComputePressureCoefficientFunctor(vtkMultiBlockPLOT3DReader* reader, vtkStructuredGrid* grid) : ComputeFunctor(reader, grid) {}
void operator()(vtkIdType begin, vtkIdType end)
void operator()(vtkIdType begin, vtkIdType end) override
{
double e, u, v, w, v2, p, d, rr, pc, gi, pi, fsm, den, m[3];
gi = Properties->GetComponent(0,4);
......@@ -258,7 +258,7 @@ class ComputeMachNumberFunctor : public ComputeFunctor
public:
ComputeMachNumberFunctor(vtkMultiBlockPLOT3DReader* reader, vtkStructuredGrid* grid) : ComputeFunctor(reader, grid) {}
void operator()(vtkIdType begin, vtkIdType end)
void operator()(vtkIdType begin, vtkIdType end) override
{
double e, u, v, w, v2, a2, d, g, rr, m[3];
for (vtkIdType i = begin; i < end; ++i)
......@@ -289,7 +289,7 @@ class ComputeSoundSpeedFunctor : public ComputeFunctor
public:
ComputeSoundSpeedFunctor(vtkMultiBlockPLOT3DReader* reader, vtkStructuredGrid* grid) : ComputeFunctor(reader, grid) {}
void operator()(vtkIdType begin, vtkIdType end)
void operator()(vtkIdType begin, vtkIdType end) override
{
double e, u, v, w, v2, p, d, g, rr, m[3];
for (vtkIdType i = begin; i < end; ++i)
......@@ -320,7 +320,7 @@ class ComputeEnthalpyFunctor : public ComputeFunctor
public:
ComputeEnthalpyFunctor(vtkMultiBlockPLOT3DReader* reader, vtkStructuredGrid* grid) : ComputeFunctor(reader, grid) {}
void operator()(vtkIdType begin, vtkIdType end)
void operator()(vtkIdType begin, vtkIdType end) override
{
double e, u, v, w, v2, d, rr, m[3];
for (vtkIdType i = begin; i < end; ++i)
......@@ -349,7 +349,7 @@ class ComputeKineticEnergyFunctor : public ComputeFunctor
public:
ComputeKineticEnergyFunctor(vtkMultiBlockPLOT3DReader* reader, vtkStructuredGrid* grid) : ComputeFunctor(reader, grid) {}
void operator()(vtkIdType begin, vtkIdType end)
void operator()(vtkIdType begin, vtkIdType end) override
{
double u, v, w, v2, d, rr, m[3];
for (vtkIdType i = begin; i < end; ++i)
......@@ -377,7 +377,7 @@ class ComputeVelocityMagnitudeFunctor : public ComputeFunctor
public:
ComputeVelocityMagnitudeFunctor(vtkMultiBlockPLOT3DReader* reader, vtkStructuredGrid* grid) : ComputeFunctor(reader, grid) {}
void operator()(vtkIdType begin, vtkIdType end)
void operator()(vtkIdType begin, vtkIdType end) override
{
double m[3], u, v, w, v2, d, rr;
for (vtkIdType i = begin; i < end; ++i)
......@@ -405,7 +405,7 @@ class ComputeEntropyFunctor : public ComputeFunctor
public:
ComputeEntropyFunctor(vtkMultiBlockPLOT3DReader* reader, vtkStructuredGrid* grid) : ComputeFunctor(reader, grid) {}
void operator()(vtkIdType begin, vtkIdType end)
void operator()(vtkIdType begin, vtkIdType end) override
{
double u, v, w, v2, d, rr, s, p, e, m[3];
double rhoinf = 1.0;
......@@ -440,7 +440,7 @@ class ComputeSwirlFunctor : public ComputeFunctor
public:
ComputeSwirlFunctor(vtkMultiBlockPLOT3DReader* reader, vtkStructuredGrid* grid) : ComputeFunctor(reader, grid) {}
void operator()(vtkIdType begin, vtkIdType end)
void operator()(vtkIdType begin, vtkIdType end) override
{
double d, rr, u, v, w, v2, s, m[3], vort[3];
for (vtkIdType i = begin; i < end; ++i)
......@@ -478,7 +478,7 @@ class ComputeVelocityFunctor : public ComputeFunctor
public:
ComputeVelocityFunctor(vtkMultiBlockPLOT3DReader* reader, vtkStructuredGrid* grid) : ComputeFunctor(reader, grid) {}
void operator()(vtkIdType begin, vtkIdType end)
void operator()(vtkIdType begin, vtkIdType end) override
{
double m[3], v[3], d, rr;
for (vtkIdType i = begin; i < end; ++i)
......@@ -505,7 +505,7 @@ class ComputeVorticityMagnitudeFunctor : public ComputeFunctor
public:
ComputeVorticityMagnitudeFunctor(vtkMultiBlockPLOT3DReader* reader, vtkStructuredGrid* grid) : ComputeFunctor(reader, grid) {}
void operator()(vtkIdType begin, vtkIdType end)
void operator()(vtkIdType begin, vtkIdType end) override
{
vtkDataArray* Vorticity = Grid->GetPointData()->GetArray("Vorticity");
double vort[3];
......@@ -529,7 +529,7 @@ class ComputePressureGradientFunctor : public ComputeFunctor
public:
ComputePressureGradientFunctor(vtkMultiBlockPLOT3DReader* reader, vtkStructuredGrid* grid) : ComputeFunctor(reader, grid) {}
void operator()(vtkIdType begin, vtkIdType end)
void operator()(vtkIdType begin, vtkIdType end) override
{
int dims[3], ijsize;
int i, j, k, idx, idx2, ii, temp;
......@@ -739,7 +739,7 @@ class ComputeVorticityFunctor : public ComputeFunctor
public:
ComputeVorticityFunctor(vtkMultiBlockPLOT3DReader* reader, vtkStructuredGrid* grid) : ComputeFunctor(reader, grid) {}
void operator()(vtkIdType begin, vtkIdType end)
void operator()(vtkIdType begin, vtkIdType end) override
{
int dims[3], ijsize;
int i, j, k, idx, idx2, ii, temp;
......@@ -956,7 +956,7 @@ class ComputeStrainRateFunctor : public ComputeFunctor
public:
ComputeStrainRateFunctor(vtkMultiBlockPLOT3DReader* reader, vtkStructuredGrid* grid) : ComputeFunctor(reader, grid) {}
void operator()(vtkIdType begin, vtkIdType end)
void operator()(vtkIdType begin, vtkIdType end) override
{
int dims[3], ijsize;
int i, j, k, idx, idx2, ii, temp;
......
......@@ -48,20 +48,20 @@ public:
void SetMappedUnstructuredGrid(vtkMappedUnstructuredGrid<I, ThisType> *grid);
virtual void PrintSelf(std::ostream& os, vtkIndent id) override;
void PrintSelf(std::ostream& os, vtkIndent id) override;
virtual bool IsDoneWithTraversal() override;
virtual vtkIdType GetCellId() override;
bool IsDoneWithTraversal() override;
vtkIdType GetCellId() override;
protected:
MappedCellIterator();
~MappedCellIterator() override;
virtual void ResetToFirstCell() override { this->CellId = 0; }
virtual void IncrementToNextCell() override { this->CellId++; }
virtual void FetchCellType() override;
virtual void FetchPointIds() override;
virtual void FetchPoints() override;
virtual void FetchFaces() override;
void ResetToFirstCell() override { this->CellId = 0; }
void IncrementToNextCell() override { this->CellId++; }
void FetchCellType() override;
void FetchPointIds() override;
void FetchPoints() override;
void FetchFaces() override;
private:
MappedCellIterator(const MappedCellIterator&) VTK_DELETE_FUNCTION;
......@@ -184,7 +184,7 @@ public:
protected:
MappedGridImpl(){}
virtual ~MappedGridImpl() override { _grid->UnRegister(this); }
~MappedGridImpl() override { _grid->UnRegister(this); }
private:
vtkUnstructuredGrid* _grid;
......
......@@ -463,7 +463,7 @@ public:
{
return new vtkButtonCallback;
}
virtual void Execute(vtkObject* caller, unsigned long, void*)
void Execute(vtkObject* caller, unsigned long, void*) override
{
vtkButtonWidget* buttonWidget = reinterpret_cast<vtkButtonWidget*>(caller);
vtkTexturedButtonRepresentation* rep =
......
......@@ -975,7 +975,7 @@ public:
{
return new vtkButtonWidgetMultipleViewportsCallback;
}
virtual void Execute(vtkObject* caller, unsigned long, void*)
void Execute(vtkObject* caller, unsigned long, void*) override
{
vtkButtonWidget* buttonWidget = reinterpret_cast<vtkButtonWidget*>(caller);
vtkTexturedButtonRepresentation* rep =
......
......@@ -50,7 +50,7 @@ public:
vtkTypeMacro(MouseInteractorStyle2, vtkInteractorStyleTrackballCamera);
virtual void OnLeftButtonDown() override
void OnLeftButtonDown() override
{
int* clickPos = this->GetInteractor()->GetEventPosition();
......
......@@ -75,8 +75,8 @@ public:
static SamplingDistanceCallback *New()
{ return new SamplingDistanceCallback; }
virtual void Execute(vtkObject* vtkNotUsed(caller), unsigned long event,
void* vtkNotUsed(data))
void Execute(vtkObject* vtkNotUsed(caller), unsigned long event,
void* vtkNotUsed(data)) override
{
switch (event)
{
......
......@@ -26,7 +26,7 @@ class vtkRegressionTester : public vtkTesting
{
protected:
vtkRegressionTester() {}
~vtkRegressionTester() {}
~vtkRegressionTester() override {}
private:
vtkRegressionTester(const vtkRegressionTester&) = delete;
void operator=(const vtkRegressionTester&) = delete;
......
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