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 DataTreeRef;
} }
class BlobOnBlocks: public Blob { class BlobOnBlocks final: public Blob {
public: public:
BlobOnBlocks(cpputils::unique_ref<parallelaccessdatatreestore::DataTreeRef> datatree); BlobOnBlocks(cpputils::unique_ref<parallelaccessdatatreestore::DataTreeRef> datatree);
virtual ~BlobOnBlocks(); ~BlobOnBlocks();
const blockstore::Key &key() const override; const blockstore::Key &key() const override;
@ -42,6 +42,8 @@ private:
cpputils::unique_ref<parallelaccessdatatreestore::DataTreeRef> _datatree; cpputils::unique_ref<parallelaccessdatatreestore::DataTreeRef> _datatree;
mutable boost::optional<uint64_t> _sizeCache; 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 //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: public:
BlobStoreOnBlocks(cpputils::unique_ref<blockstore::BlockStore> blockStore, uint32_t blocksizeBytes); BlobStoreOnBlocks(cpputils::unique_ref<blockstore::BlockStore> blockStore, uint32_t blocksizeBytes);
virtual ~BlobStoreOnBlocks(); ~BlobStoreOnBlocks();
cpputils::unique_ref<Blob> create() override; cpputils::unique_ref<Blob> create() override;
boost::optional<cpputils::unique_ref<Blob>> load(const blockstore::Key &key) override; boost::optional<cpputils::unique_ref<Blob>> load(const blockstore::Key &key) override;
@ -25,6 +25,8 @@ public:
private: private:
cpputils::unique_ref<parallelaccessdatatreestore::ParallelAccessDataTreeStore> _dataTreeStore; cpputils::unique_ref<parallelaccessdatatreestore::ParallelAccessDataTreeStore> _dataTreeStore;
DISALLOW_COPY_AND_ASSIGN(BlobStoreOnBlocks);
}; };
} }

View File

@ -9,12 +9,12 @@ namespace blobstore {
namespace onblocks { namespace onblocks {
namespace datanodestore { namespace datanodestore {
class DataInnerNode: public DataNode { class DataInnerNode final: public DataNode {
public: public:
static cpputils::unique_ref<DataInnerNode> InitializeNewNode(cpputils::unique_ref<blockstore::Block> block, const DataNode &first_child_key); static cpputils::unique_ref<DataInnerNode> InitializeNewNode(cpputils::unique_ref<blockstore::Block> block, const DataNode &first_child_key);
DataInnerNode(DataNodeView block); DataInnerNode(DataNodeView block);
virtual ~DataInnerNode(); ~DataInnerNode();
using ChildEntry = DataInnerNode_ChildEntry; using ChildEntry = DataInnerNode_ChildEntry;
@ -38,6 +38,8 @@ private:
ChildEntry *ChildrenEnd(); ChildEntry *ChildrenEnd();
const ChildEntry *ChildrenBegin() const; const ChildEntry *ChildrenBegin() const;
const ChildEntry *ChildrenEnd() const; const ChildEntry *ChildrenEnd() const;
DISALLOW_COPY_AND_ASSIGN(DataInnerNode);
}; };
} }

View File

@ -8,7 +8,7 @@ namespace blobstore{
namespace onblocks{ namespace onblocks{
namespace datanodestore{ namespace datanodestore{
struct DataInnerNode_ChildEntry { struct DataInnerNode_ChildEntry final {
public: public:
blockstore::Key key() const { blockstore::Key key() const {
return blockstore::Key::FromBinary(_keydata); return blockstore::Key::FromBinary(_keydata);
@ -19,6 +19,7 @@ private:
} }
friend class DataInnerNode; friend class DataInnerNode;
uint8_t _keydata[blockstore::Key::BINARY_LENGTH]; uint8_t _keydata[blockstore::Key::BINARY_LENGTH];
DISALLOW_COPY_AND_ASSIGN(DataInnerNode_ChildEntry); DISALLOW_COPY_AND_ASSIGN(DataInnerNode_ChildEntry);
}; };

View File

@ -9,12 +9,12 @@ namespace onblocks {
namespace datanodestore { namespace datanodestore {
class DataInnerNode; class DataInnerNode;
class DataLeafNode: public DataNode { class DataLeafNode final: public DataNode {
public: public:
static cpputils::unique_ref<DataLeafNode> InitializeNewNode(cpputils::unique_ref<blockstore::Block> block); static cpputils::unique_ref<DataLeafNode> InitializeNewNode(cpputils::unique_ref<blockstore::Block> block);
DataLeafNode(DataNodeView block); DataLeafNode(DataNodeView block);
virtual ~DataLeafNode(); ~DataLeafNode();
uint32_t maxStoreableBytes() const; uint32_t maxStoreableBytes() const;
@ -27,6 +27,8 @@ public:
private: private:
void fillDataWithZeroesFromTo(off_t begin, off_t end); void fillDataWithZeroesFromTo(off_t begin, off_t end);
DISALLOW_COPY_AND_ASSIGN(DataLeafNode);
}; };
} }

View File

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

View File

@ -17,7 +17,7 @@ namespace onblocks {
namespace datanodestore { namespace datanodestore {
//TODO Move DataNodeLayout into own file //TODO Move DataNodeLayout into own file
class DataNodeLayout { class DataNodeLayout final {
public: public:
constexpr DataNodeLayout(uint32_t blocksizeBytes) constexpr DataNodeLayout(uint32_t blocksizeBytes)
:_blocksizeBytes( :_blocksizeBytes(
@ -57,11 +57,11 @@ private:
uint32_t _blocksizeBytes; uint32_t _blocksizeBytes;
}; };
class DataNodeView { class DataNodeView final {
public: public:
DataNodeView(cpputils::unique_ref<blockstore::Block> block): _block(std::move(block)) { DataNodeView(cpputils::unique_ref<blockstore::Block> block): _block(std::move(block)) {
} }
virtual ~DataNodeView() {} ~DataNodeView() {}
DataNodeView(DataNodeView &&rhs) = default; DataNodeView(DataNodeView &&rhs) = default;

View File

@ -21,10 +21,10 @@ class DataNode;
namespace datatreestore { namespace datatreestore {
//TODO It is strange that DataLeafNode is still part in the public interface of DataTree. This should be separated somehow. //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: public:
DataTree(datanodestore::DataNodeStore *nodeStore, cpputils::unique_ref<datanodestore::DataNode> rootNode); DataTree(datanodestore::DataNodeStore *nodeStore, cpputils::unique_ref<datanodestore::DataNode> rootNode);
virtual ~DataTree(); ~DataTree();
const blockstore::Key &key() const; const blockstore::Key &key() const;
uint32_t maxBytesPerLeaf() const; uint32_t maxBytesPerLeaf() const;

View File

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

View File

@ -9,7 +9,7 @@ namespace blobstore {
namespace onblocks { namespace onblocks {
namespace parallelaccessdatatreestore { 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: public:
DataTreeRef(datatreestore::DataTree *baseTree): _baseTree(baseTree) {} DataTreeRef(datatreestore::DataTree *baseTree): _baseTree(baseTree) {}

View File

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

View File

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