Make classes final if they're not meant to be derived from

This commit is contained in:
Sebastian Messmer 2015-11-27 14:06:48 +01:00
parent 5ff133641c
commit 6dc03a50cb
12 changed files with 31 additions and 22 deletions

View File

@ -16,10 +16,10 @@ namespace parallelaccessdatatreestore {
class DataTreeRef;
}
class BlobOnBlocks: public Blob {
class BlobOnBlocks final: public Blob {
public:
BlobOnBlocks(cpputils::unique_ref<parallelaccessdatatreestore::DataTreeRef> datatree);
virtual ~BlobOnBlocks();
~BlobOnBlocks();
const blockstore::Key &key() const override;
@ -42,6 +42,8 @@ private:
cpputils::unique_ref<parallelaccessdatatreestore::DataTreeRef> _datatree;
mutable boost::optional<uint64_t> _sizeCache;
DISALLOW_COPY_AND_ASSIGN(BlobOnBlocks);
};
}

View File

@ -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::BlockStore> blockStore, uint32_t blocksizeBytes);
virtual ~BlobStoreOnBlocks();
~BlobStoreOnBlocks();
cpputils::unique_ref<Blob> create() override;
boost::optional<cpputils::unique_ref<Blob>> load(const blockstore::Key &key) override;
@ -25,6 +25,8 @@ public:
private:
cpputils::unique_ref<parallelaccessdatatreestore::ParallelAccessDataTreeStore> _dataTreeStore;
DISALLOW_COPY_AND_ASSIGN(BlobStoreOnBlocks);
};
}

View File

@ -9,12 +9,12 @@ namespace blobstore {
namespace onblocks {
namespace datanodestore {
class DataInnerNode: public DataNode {
class DataInnerNode final: public DataNode {
public:
static cpputils::unique_ref<DataInnerNode> InitializeNewNode(cpputils::unique_ref<blockstore::Block> 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);
};
}

View File

@ -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);
};

View File

@ -9,12 +9,12 @@ namespace onblocks {
namespace datanodestore {
class DataInnerNode;
class DataLeafNode: public DataNode {
class DataLeafNode final: public DataNode {
public:
static cpputils::unique_ref<DataLeafNode> InitializeNewNode(cpputils::unique_ref<blockstore::Block> 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);
};
}

View File

@ -19,10 +19,10 @@ class DataNode;
class DataLeafNode;
class DataInnerNode;
class DataNodeStore {
class DataNodeStore final {
public:
DataNodeStore(cpputils::unique_ref<blockstore::BlockStore> blockstore, uint32_t blocksizeBytes);
virtual ~DataNodeStore();
~DataNodeStore();
static constexpr uint8_t MAX_DEPTH = 10;

View File

@ -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<blockstore::Block> block): _block(std::move(block)) {
}
virtual ~DataNodeView() {}
~DataNodeView() {}
DataNodeView(DataNodeView &&rhs) = default;

View File

@ -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<datanodestore::DataNode> rootNode);
virtual ~DataTree();
~DataTree();
const blockstore::Key &key() const;
uint32_t maxBytesPerLeaf() const;

View File

@ -16,10 +16,10 @@ class DataNodeStore;
namespace datatreestore {
class DataTree;
class DataTreeStore {
class DataTreeStore final {
public:
DataTreeStore(cpputils::unique_ref<datanodestore::DataNodeStore> nodeStore);
virtual ~DataTreeStore();
~DataTreeStore();
boost::optional<cpputils::unique_ref<DataTree>> load(const blockstore::Key &key);

View File

@ -9,7 +9,7 @@ namespace blobstore {
namespace onblocks {
namespace parallelaccessdatatreestore {
class DataTreeRef: public parallelaccessstore::ParallelAccessStore<datatreestore::DataTree, DataTreeRef, blockstore::Key>::ResourceRefBase {
class DataTreeRef final: public parallelaccessstore::ParallelAccessStore<datatreestore::DataTree, DataTreeRef, blockstore::Key>::ResourceRefBase {
public:
DataTreeRef(datatreestore::DataTree *baseTree): _baseTree(baseTree) {}

View File

@ -18,10 +18,10 @@ class DataTreeRef;
//TODO Test CachingDataTreeStore
class ParallelAccessDataTreeStore {
class ParallelAccessDataTreeStore final {
public:
ParallelAccessDataTreeStore(cpputils::unique_ref<datatreestore::DataTreeStore> dataTreeStore);
virtual ~ParallelAccessDataTreeStore();
~ParallelAccessDataTreeStore();
boost::optional<cpputils::unique_ref<DataTreeRef>> load(const blockstore::Key &key);

View File

@ -11,7 +11,7 @@ namespace blobstore {
namespace onblocks {
namespace parallelaccessdatatreestore {
class ParallelAccessDataTreeStoreAdapter: public parallelaccessstore::ParallelAccessBaseStore<datatreestore::DataTree, blockstore::Key> {
class ParallelAccessDataTreeStoreAdapter final: public parallelaccessstore::ParallelAccessBaseStore<datatreestore::DataTree, blockstore::Key> {
public:
ParallelAccessDataTreeStoreAdapter(datatreestore::DataTreeStore *baseDataTreeStore)
:_baseDataTreeStore(std::move(baseDataTreeStore)) {