From 6dc03a50cb8dff9885df734cfe81148ccf968a27 Mon Sep 17 00:00:00 2001 From: Sebastian Messmer Date: Fri, 27 Nov 2015 14:06:48 +0100 Subject: [PATCH] Make classes final if they're not meant to be derived from --- implementations/onblocks/BlobOnBlocks.h | 6 ++++-- implementations/onblocks/BlobStoreOnBlocks.h | 6 ++++-- implementations/onblocks/datanodestore/DataInnerNode.h | 6 ++++-- .../onblocks/datanodestore/DataInnerNode_ChildEntry.h | 3 ++- implementations/onblocks/datanodestore/DataLeafNode.h | 6 ++++-- implementations/onblocks/datanodestore/DataNodeStore.h | 4 ++-- implementations/onblocks/datanodestore/DataNodeView.h | 6 +++--- implementations/onblocks/datatreestore/DataTree.h | 4 ++-- implementations/onblocks/datatreestore/DataTreeStore.h | 4 ++-- .../onblocks/parallelaccessdatatreestore/DataTreeRef.h | 2 +- .../ParallelAccessDataTreeStore.h | 4 ++-- .../ParallelAccessDataTreeStoreAdapter.h | 2 +- 12 files changed, 31 insertions(+), 22 deletions(-) diff --git a/implementations/onblocks/BlobOnBlocks.h b/implementations/onblocks/BlobOnBlocks.h index 9956b92b..7d73db39 100644 --- a/implementations/onblocks/BlobOnBlocks.h +++ b/implementations/onblocks/BlobOnBlocks.h @@ -16,10 +16,10 @@ namespace parallelaccessdatatreestore { class DataTreeRef; } -class BlobOnBlocks: public Blob { +class BlobOnBlocks final: public Blob { public: BlobOnBlocks(cpputils::unique_ref datatree); - virtual ~BlobOnBlocks(); + ~BlobOnBlocks(); const blockstore::Key &key() const override; @@ -42,6 +42,8 @@ private: cpputils::unique_ref _datatree; mutable boost::optional _sizeCache; + + DISALLOW_COPY_AND_ASSIGN(BlobOnBlocks); }; } diff --git a/implementations/onblocks/BlobStoreOnBlocks.h b/implementations/onblocks/BlobStoreOnBlocks.h index ec9f2012..cbb3651a 100644 --- a/implementations/onblocks/BlobStoreOnBlocks.h +++ b/implementations/onblocks/BlobStoreOnBlocks.h @@ -13,10 +13,10 @@ class ParallelAccessDataTreeStore; //TODO Make blobstore able to cope with incomplete data (some blocks missing, because they're not synchronized yet) and write test cases for that -class BlobStoreOnBlocks: public BlobStore { +class BlobStoreOnBlocks final: public BlobStore { public: BlobStoreOnBlocks(cpputils::unique_ref blockStore, uint32_t blocksizeBytes); - virtual ~BlobStoreOnBlocks(); + ~BlobStoreOnBlocks(); cpputils::unique_ref create() override; boost::optional> load(const blockstore::Key &key) override; @@ -25,6 +25,8 @@ public: private: cpputils::unique_ref _dataTreeStore; + + DISALLOW_COPY_AND_ASSIGN(BlobStoreOnBlocks); }; } diff --git a/implementations/onblocks/datanodestore/DataInnerNode.h b/implementations/onblocks/datanodestore/DataInnerNode.h index 8755fce6..967d6746 100644 --- a/implementations/onblocks/datanodestore/DataInnerNode.h +++ b/implementations/onblocks/datanodestore/DataInnerNode.h @@ -9,12 +9,12 @@ namespace blobstore { namespace onblocks { namespace datanodestore { -class DataInnerNode: public DataNode { +class DataInnerNode final: public DataNode { public: static cpputils::unique_ref InitializeNewNode(cpputils::unique_ref block, const DataNode &first_child_key); DataInnerNode(DataNodeView block); - virtual ~DataInnerNode(); + ~DataInnerNode(); using ChildEntry = DataInnerNode_ChildEntry; @@ -38,6 +38,8 @@ private: ChildEntry *ChildrenEnd(); const ChildEntry *ChildrenBegin() const; const ChildEntry *ChildrenEnd() const; + + DISALLOW_COPY_AND_ASSIGN(DataInnerNode); }; } diff --git a/implementations/onblocks/datanodestore/DataInnerNode_ChildEntry.h b/implementations/onblocks/datanodestore/DataInnerNode_ChildEntry.h index 3b2c9bec..33813657 100644 --- a/implementations/onblocks/datanodestore/DataInnerNode_ChildEntry.h +++ b/implementations/onblocks/datanodestore/DataInnerNode_ChildEntry.h @@ -8,7 +8,7 @@ namespace blobstore{ namespace onblocks{ namespace datanodestore{ -struct DataInnerNode_ChildEntry { +struct DataInnerNode_ChildEntry final { public: blockstore::Key key() const { return blockstore::Key::FromBinary(_keydata); @@ -19,6 +19,7 @@ private: } friend class DataInnerNode; uint8_t _keydata[blockstore::Key::BINARY_LENGTH]; + DISALLOW_COPY_AND_ASSIGN(DataInnerNode_ChildEntry); }; diff --git a/implementations/onblocks/datanodestore/DataLeafNode.h b/implementations/onblocks/datanodestore/DataLeafNode.h index 71596711..00f332c9 100644 --- a/implementations/onblocks/datanodestore/DataLeafNode.h +++ b/implementations/onblocks/datanodestore/DataLeafNode.h @@ -9,12 +9,12 @@ namespace onblocks { namespace datanodestore { class DataInnerNode; -class DataLeafNode: public DataNode { +class DataLeafNode final: public DataNode { public: static cpputils::unique_ref InitializeNewNode(cpputils::unique_ref block); DataLeafNode(DataNodeView block); - virtual ~DataLeafNode(); + ~DataLeafNode(); uint32_t maxStoreableBytes() const; @@ -27,6 +27,8 @@ public: private: void fillDataWithZeroesFromTo(off_t begin, off_t end); + + DISALLOW_COPY_AND_ASSIGN(DataLeafNode); }; } diff --git a/implementations/onblocks/datanodestore/DataNodeStore.h b/implementations/onblocks/datanodestore/DataNodeStore.h index c8017b8f..6c267c90 100644 --- a/implementations/onblocks/datanodestore/DataNodeStore.h +++ b/implementations/onblocks/datanodestore/DataNodeStore.h @@ -19,10 +19,10 @@ class DataNode; class DataLeafNode; class DataInnerNode; -class DataNodeStore { +class DataNodeStore final { public: DataNodeStore(cpputils::unique_ref blockstore, uint32_t blocksizeBytes); - virtual ~DataNodeStore(); + ~DataNodeStore(); static constexpr uint8_t MAX_DEPTH = 10; diff --git a/implementations/onblocks/datanodestore/DataNodeView.h b/implementations/onblocks/datanodestore/DataNodeView.h index c92aa661..42053af6 100644 --- a/implementations/onblocks/datanodestore/DataNodeView.h +++ b/implementations/onblocks/datanodestore/DataNodeView.h @@ -17,7 +17,7 @@ namespace onblocks { namespace datanodestore { //TODO Move DataNodeLayout into own file -class DataNodeLayout { +class DataNodeLayout final { public: constexpr DataNodeLayout(uint32_t blocksizeBytes) :_blocksizeBytes( @@ -57,11 +57,11 @@ private: uint32_t _blocksizeBytes; }; -class DataNodeView { +class DataNodeView final { public: DataNodeView(cpputils::unique_ref block): _block(std::move(block)) { } - virtual ~DataNodeView() {} + ~DataNodeView() {} DataNodeView(DataNodeView &&rhs) = default; diff --git a/implementations/onblocks/datatreestore/DataTree.h b/implementations/onblocks/datatreestore/DataTree.h index e1e73caf..b43d712a 100644 --- a/implementations/onblocks/datatreestore/DataTree.h +++ b/implementations/onblocks/datatreestore/DataTree.h @@ -21,10 +21,10 @@ class DataNode; namespace datatreestore { //TODO It is strange that DataLeafNode is still part in the public interface of DataTree. This should be separated somehow. -class DataTree { +class DataTree final { public: DataTree(datanodestore::DataNodeStore *nodeStore, cpputils::unique_ref rootNode); - virtual ~DataTree(); + ~DataTree(); const blockstore::Key &key() const; uint32_t maxBytesPerLeaf() const; diff --git a/implementations/onblocks/datatreestore/DataTreeStore.h b/implementations/onblocks/datatreestore/DataTreeStore.h index 97ed0fc5..1ed023a4 100644 --- a/implementations/onblocks/datatreestore/DataTreeStore.h +++ b/implementations/onblocks/datatreestore/DataTreeStore.h @@ -16,10 +16,10 @@ class DataNodeStore; namespace datatreestore { class DataTree; -class DataTreeStore { +class DataTreeStore final { public: DataTreeStore(cpputils::unique_ref nodeStore); - virtual ~DataTreeStore(); + ~DataTreeStore(); boost::optional> load(const blockstore::Key &key); diff --git a/implementations/onblocks/parallelaccessdatatreestore/DataTreeRef.h b/implementations/onblocks/parallelaccessdatatreestore/DataTreeRef.h index 78f907d1..d3bc6d14 100644 --- a/implementations/onblocks/parallelaccessdatatreestore/DataTreeRef.h +++ b/implementations/onblocks/parallelaccessdatatreestore/DataTreeRef.h @@ -9,7 +9,7 @@ namespace blobstore { namespace onblocks { namespace parallelaccessdatatreestore { -class DataTreeRef: public parallelaccessstore::ParallelAccessStore::ResourceRefBase { +class DataTreeRef final: public parallelaccessstore::ParallelAccessStore::ResourceRefBase { public: DataTreeRef(datatreestore::DataTree *baseTree): _baseTree(baseTree) {} diff --git a/implementations/onblocks/parallelaccessdatatreestore/ParallelAccessDataTreeStore.h b/implementations/onblocks/parallelaccessdatatreestore/ParallelAccessDataTreeStore.h index 0a39c51b..61de0285 100644 --- a/implementations/onblocks/parallelaccessdatatreestore/ParallelAccessDataTreeStore.h +++ b/implementations/onblocks/parallelaccessdatatreestore/ParallelAccessDataTreeStore.h @@ -18,10 +18,10 @@ class DataTreeRef; //TODO Test CachingDataTreeStore -class ParallelAccessDataTreeStore { +class ParallelAccessDataTreeStore final { public: ParallelAccessDataTreeStore(cpputils::unique_ref dataTreeStore); - virtual ~ParallelAccessDataTreeStore(); + ~ParallelAccessDataTreeStore(); boost::optional> load(const blockstore::Key &key); diff --git a/implementations/onblocks/parallelaccessdatatreestore/ParallelAccessDataTreeStoreAdapter.h b/implementations/onblocks/parallelaccessdatatreestore/ParallelAccessDataTreeStoreAdapter.h index 5c76ff99..cdb3dc67 100644 --- a/implementations/onblocks/parallelaccessdatatreestore/ParallelAccessDataTreeStoreAdapter.h +++ b/implementations/onblocks/parallelaccessdatatreestore/ParallelAccessDataTreeStoreAdapter.h @@ -11,7 +11,7 @@ namespace blobstore { namespace onblocks { namespace parallelaccessdatatreestore { -class ParallelAccessDataTreeStoreAdapter: public parallelaccessstore::ParallelAccessBaseStore { +class ParallelAccessDataTreeStoreAdapter final: public parallelaccessstore::ParallelAccessBaseStore { public: ParallelAccessDataTreeStoreAdapter(datatreestore::DataTreeStore *baseDataTreeStore) :_baseDataTreeStore(std::move(baseDataTreeStore)) {