From ad5014aa4c299b7fb26dc069f75a60d67eb2a57c Mon Sep 17 00:00:00 2001 From: Frederick Roy Date: Wed, 4 Feb 2026 15:58:11 +0900 Subject: [PATCH] remove virtual keyword for final classes --- .../Core/src/sofa/core/objectmodel/DataLink.h | 2 +- .../CompressedRowSparseMatrixMechanical.h | 96 +++++++++---------- 2 files changed, 49 insertions(+), 49 deletions(-) diff --git a/Sofa/framework/Core/src/sofa/core/objectmodel/DataLink.h b/Sofa/framework/Core/src/sofa/core/objectmodel/DataLink.h index 342bb50d8b3..d068a5acaf3 100644 --- a/Sofa/framework/Core/src/sofa/core/objectmodel/DataLink.h +++ b/Sofa/framework/Core/src/sofa/core/objectmodel/DataLink.h @@ -39,7 +39,7 @@ class SOFA_CORE_API DataLink final : public AbstractDataLink public: DataLink(T& owner) : m_owner{owner} { } - virtual ~DataLink() {} + ~DataLink() = default; T* getTarget() const { diff --git a/Sofa/framework/LinearAlgebra/src/sofa/linearalgebra/CompressedRowSparseMatrixMechanical.h b/Sofa/framework/LinearAlgebra/src/sofa/linearalgebra/CompressedRowSparseMatrixMechanical.h index 5dd349255a6..3815c318a4d 100644 --- a/Sofa/framework/LinearAlgebra/src/sofa/linearalgebra/CompressedRowSparseMatrixMechanical.h +++ b/Sofa/framework/LinearAlgebra/src/sofa/linearalgebra/CompressedRowSparseMatrixMechanical.h @@ -446,28 +446,28 @@ class CompressedRowSparseMatrixMechanical final // final is used to allow the co /// @{ /// @return type of elements stored in this matrix - virtual ElementType getElementType() const override { return traits::getElementType(); } + ElementType getElementType() const override { return traits::getElementType(); } /// @return size of elements stored in this matrix - virtual std::size_t getElementSize() const override { return sizeof(Real); } + std::size_t getElementSize() const override { return sizeof(Real); } /// @return the category of this matrix - virtual MatrixCategory getCategory() const override { return MATRIX_SPARSE; } + MatrixCategory getCategory() const override { return MATRIX_SPARSE; } /// @return the number of rows in each block, or 1 of there are no fixed block size - virtual Index getBlockRows() const override { return NL; } + Index getBlockRows() const override { return NL; } /// @return the number of columns in each block, or 1 of there are no fixed block size - virtual Index getBlockCols() const override { return NC; } + Index getBlockCols() const override { return NC; } /// @return the number of rows of blocks - virtual Index bRowSize() const override{ return this->rowBSize(); } + Index bRowSize() const override{ return this->rowBSize(); } /// @return the number of columns of blocks - virtual Index bColSize() const override { return this->colBSize(); } + Index bColSize() const override { return this->colBSize(); } /// @return the width of the band on each side of the diagonal (only for band matrices) - virtual Index getBandWidth() const override { return NC-1; } + Index getBandWidth() const override { return NC-1; } /// @} @@ -641,23 +641,23 @@ class CompressedRowSparseMatrixMechanical final // final is used to allow the co /// @{ protected: - virtual void bAccessorDelete(const InternalBlockAccessor* /*b*/) const override {} - virtual void bAccessorCopy(InternalBlockAccessor* /*b*/) const override {} - virtual SReal bAccessorElement(const InternalBlockAccessor* b, Index i, Index j) const override + void bAccessorDelete(const InternalBlockAccessor* /*b*/) const override {} + void bAccessorCopy(InternalBlockAccessor* /*b*/) const override {} + SReal bAccessorElement(const InternalBlockAccessor* b, Index i, Index j) const override { //return element(b->row * getBlockRows() + i, b->col * getBlockCols() + j); Index index = b->data; const Block& data = (index >= 0) ? this->colsValue[index] : this->btemp[-index-1].value; return static_cast(traits::v(data, i, j)); } - virtual void bAccessorSet(InternalBlockAccessor* b, Index i, Index j, double v) override + void bAccessorSet(InternalBlockAccessor* b, Index i, Index j, double v) override { //set(b->row * getBlockRows() + i, b->col * getBlockCols() + j, v); Index index = b->data; Block& data = (index >= 0) ? this->colsValue[index] : this->btemp[-index-1].value; traits::vset(data, i, j, static_cast(v) ); } - virtual void bAccessorAdd(InternalBlockAccessor* b, Index i, Index j, double v) override + void bAccessorAdd(InternalBlockAccessor* b, Index i, Index j, double v) override { //add(b->row * getBlockRows() + i, b->col * getBlockCols() + j, v); Index index = b->data; @@ -675,15 +675,15 @@ class CompressedRowSparseMatrixMechanical final // final is used to allow the co buffer[l*NC+c] = static_cast(traits::v(data, l, c)); return buffer; } - virtual const float* bAccessorElements(const InternalBlockAccessor* b, float* buffer) const override + const float* bAccessorElements(const InternalBlockAccessor* b, float* buffer) const override { return bAccessorElementsCSRImpl(b, buffer); } - virtual const double* bAccessorElements(const InternalBlockAccessor* b, double* buffer) const override + const double* bAccessorElements(const InternalBlockAccessor* b, double* buffer) const override { return bAccessorElementsCSRImpl(b, buffer); } - virtual const int* bAccessorElements(const InternalBlockAccessor* b, int* buffer) const override + const int* bAccessorElements(const InternalBlockAccessor* b, int* buffer) const override { return bAccessorElementsCSRImpl(b, buffer); } @@ -697,15 +697,15 @@ class CompressedRowSparseMatrixMechanical final // final is used to allow the co for (Index c=0; c < (Index)NC; ++c) traits::vset(data, l, c, static_cast(buffer[l*NC+c]) ); } - virtual void bAccessorSet(InternalBlockAccessor* b, const float* buffer) override + void bAccessorSet(InternalBlockAccessor* b, const float* buffer) override { bAccessorSetCSRImpl(b, buffer); } - virtual void bAccessorSet(InternalBlockAccessor* b, const double* buffer) override + void bAccessorSet(InternalBlockAccessor* b, const double* buffer) override { bAccessorSetCSRImpl(b, buffer); } - virtual void bAccessorSet(InternalBlockAccessor* b, const int* buffer) override + void bAccessorSet(InternalBlockAccessor* b, const int* buffer) override { bAccessorSetCSRImpl(b, buffer); } @@ -719,15 +719,15 @@ class CompressedRowSparseMatrixMechanical final // final is used to allow the co for (Index c=0; c < (Index)NC; ++c) traits::vadd(data, l, c,static_cast(buffer[l*NC+c]) ); } - virtual void bAccessorAdd(InternalBlockAccessor* b, const float* buffer) override + void bAccessorAdd(InternalBlockAccessor* b, const float* buffer) override { bAccessorAddCSRImpl(b, buffer); } - virtual void bAccessorAdd(InternalBlockAccessor* b, const double* buffer) override + void bAccessorAdd(InternalBlockAccessor* b, const double* buffer) override { bAccessorAddCSRImpl(b, buffer); } - virtual void bAccessorAdd(InternalBlockAccessor* b, const int* buffer) override + void bAccessorAdd(InternalBlockAccessor* b, const int* buffer) override { bAccessorAddCSRImpl(b, buffer); } @@ -735,7 +735,7 @@ class CompressedRowSparseMatrixMechanical final // final is used to allow the co public: /// Get read access to a block - virtual BlockConstAccessor blockGet(Index i, Index j) const + BlockConstAccessor blockGet(Index i, Index j) const { if constexpr (Policy::AutoCompress) const_cast(this)->compress(); /// \warning this violates the const-ness of the method ! @@ -753,7 +753,7 @@ class CompressedRowSparseMatrixMechanical final // final is used to allow the co } /// Get write access to a block - virtual BlockAccessor blockGetW(Index i, Index j) + BlockAccessor blockGetW(Index i, Index j) { if constexpr (Policy::AutoCompress) compress(); @@ -771,7 +771,7 @@ class CompressedRowSparseMatrixMechanical final // final is used to allow the co } /// Get write access to a block, possibly creating it - virtual BlockAccessor blockCreate(Index i, Index j) + BlockAccessor blockCreate(Index i, Index j) { Index rowId = Index(i * this->rowIndex.size() / this->nBlockRow); if (this->sortedFind(this->rowIndex, i, rowId)) @@ -792,9 +792,9 @@ class CompressedRowSparseMatrixMechanical final // final is used to allow the co } protected: - virtual void itCopyColBlock(InternalColBlockIterator* /*it*/) const override {} - virtual void itDeleteColBlock(const InternalColBlockIterator* /*it*/) const override {} - virtual void itAccessColBlock(InternalColBlockIterator* it, BlockConstAccessor* b) const override + void itCopyColBlock(InternalColBlockIterator* /*it*/) const override {} + void itDeleteColBlock(const InternalColBlockIterator* /*it*/) const override {} + void itAccessColBlock(InternalColBlockIterator* it, BlockConstAccessor* b) const override { Index index = it->data; setMatrix(b); @@ -802,25 +802,25 @@ class CompressedRowSparseMatrixMechanical final // final is used to allow the co getInternal(b)->data = index; getInternal(b)->col = this->colsIndex[index]; } - virtual void itIncColBlock(InternalColBlockIterator* it) const override + void itIncColBlock(InternalColBlockIterator* it) const override { Index index = it->data; ++index; it->data = index; } - virtual void itDecColBlock(InternalColBlockIterator* it) const override + void itDecColBlock(InternalColBlockIterator* it) const override { Index index = it->data; --index; it->data = index; } - virtual bool itEqColBlock(const InternalColBlockIterator* it, const InternalColBlockIterator* it2) const override + bool itEqColBlock(const InternalColBlockIterator* it, const InternalColBlockIterator* it2) const override { Index index = it->data; Index index2 = it2->data; return index == index2; } - virtual bool itLessColBlock(const InternalColBlockIterator* it, const InternalColBlockIterator* it2) const override + bool itLessColBlock(const InternalColBlockIterator* it, const InternalColBlockIterator* it2) const override { Index index = it->data; Index index2 = it2->data; @@ -829,7 +829,7 @@ class CompressedRowSparseMatrixMechanical final // final is used to allow the co public: /// Get the iterator corresponding to the beginning of the given row of blocks - virtual ColBlockConstIterator bRowBegin(Index ib) const override + ColBlockConstIterator bRowBegin(Index ib) const override { if constexpr (Policy::AutoCompress) const_cast(this)->compress(); /// \warning this violates the const-ness of the method ! Index rowId = Index(ib * this->rowIndex.size() / this->nBlockRow); @@ -842,7 +842,7 @@ class CompressedRowSparseMatrixMechanical final // final is used to allow the co } /// Get the iterator corresponding to the end of the given row of blocks - virtual ColBlockConstIterator bRowEnd(Index ib) const override + ColBlockConstIterator bRowEnd(Index ib) const override { if constexpr (Policy::AutoCompress) const_cast(this)->compress(); /// \warning this violates the const-ness of the method ! Index rowId = Index(ib * this->rowIndex.size() / this->nBlockRow); @@ -855,7 +855,7 @@ class CompressedRowSparseMatrixMechanical final // final is used to allow the co } /// Get the iterators corresponding to the beginning and end of the given row of blocks - virtual std::pair bRowRange(Index ib) const override + std::pair bRowRange(Index ib) const override { if constexpr (Policy::AutoCompress) const_cast(this)->compress(); /// \warning this violates the const-ness of the method ! Index rowId = Index(ib * this->rowIndex.size() / this->nBlockRow); @@ -871,28 +871,28 @@ class CompressedRowSparseMatrixMechanical final // final is used to allow the co protected: - virtual void itCopyRowBlock(InternalRowBlockIterator* /*it*/) const override {} - virtual void itDeleteRowBlock(const InternalRowBlockIterator* /*it*/) const override {} - virtual Index itAccessRowBlock(InternalRowBlockIterator* it) const override + void itCopyRowBlock(InternalRowBlockIterator* /*it*/) const override {} + void itDeleteRowBlock(const InternalRowBlockIterator* /*it*/) const override {} + Index itAccessRowBlock(InternalRowBlockIterator* it) const override { Index rowId = it->data[0]; return this->rowIndex[rowId]; } - virtual ColBlockConstIterator itBeginRowBlock(InternalRowBlockIterator* it) const override + ColBlockConstIterator itBeginRowBlock(InternalRowBlockIterator* it) const override { Index rowId = it->data[0]; Index row = this->rowIndex[rowId]; Index index = this->rowBegin[rowId]; return createColBlockConstIterator(row, index); } - virtual ColBlockConstIterator itEndRowBlock(InternalRowBlockIterator* it) const override + ColBlockConstIterator itEndRowBlock(InternalRowBlockIterator* it) const override { Index rowId = it->data[0]; Index row = this->rowIndex[rowId]; Index index2 = this->rowBegin[rowId+1]; return createColBlockConstIterator(row, index2); } - virtual std::pair itRangeRowBlock(InternalRowBlockIterator* it) const override + std::pair itRangeRowBlock(InternalRowBlockIterator* it) const override { Index rowId = it->data[0]; Index row = this->rowIndex[rowId]; @@ -902,25 +902,25 @@ class CompressedRowSparseMatrixMechanical final // final is used to allow the co createColBlockConstIterator(row, index2)); } - virtual void itIncRowBlock(InternalRowBlockIterator* it) const override + void itIncRowBlock(InternalRowBlockIterator* it) const override { Index rowId = it->data[0]; ++rowId; it->data[0] = rowId; } - virtual void itDecRowBlock(InternalRowBlockIterator* it) const override + void itDecRowBlock(InternalRowBlockIterator* it) const override { Index rowId = it->data[0]; --rowId; it->data[0] = rowId; } - virtual bool itEqRowBlock(const InternalRowBlockIterator* it, const InternalRowBlockIterator* it2) const override + bool itEqRowBlock(const InternalRowBlockIterator* it, const InternalRowBlockIterator* it2) const override { Index rowId = it->data[0]; Index rowId2 = it2->data[0]; return rowId == rowId2; } - virtual bool itLessRowBlock(const InternalRowBlockIterator* it, const InternalRowBlockIterator* it2) const override + bool itLessRowBlock(const InternalRowBlockIterator* it, const InternalRowBlockIterator* it2) const override { Index rowId = it->data[0]; Index rowId2 = it2->data[0]; @@ -929,21 +929,21 @@ class CompressedRowSparseMatrixMechanical final // final is used to allow the co public: /// Get the iterator corresponding to the beginning of the rows of blocks - virtual RowBlockConstIterator bRowsBegin() const override + RowBlockConstIterator bRowsBegin() const override { if constexpr (Policy::AutoCompress) const_cast(this)->compress(); /// \warning this violates the const-ness of the method ! return createRowBlockConstIterator(0, 0); } /// Get the iterator corresponding to the end of the rows of blocks - virtual RowBlockConstIterator bRowsEnd() const override + RowBlockConstIterator bRowsEnd() const override { if constexpr (Policy::AutoCompress) const_cast(this)->compress(); /// \warning this violates the const-ness of the method ! return createRowBlockConstIterator(Index(this->rowIndex.size()), 0); } /// Get the iterators corresponding to the beginning and end of the given row of blocks - virtual std::pair bRowsRange() const override + std::pair bRowsRange() const override { if constexpr (Policy::AutoCompress) const_cast(this)->compress(); /// \warning this violates the const-ness of the method ! return std::make_pair(createRowBlockConstIterator(0, 0),