From 211083137425e9016b0bbc125d94f92d69990c4b Mon Sep 17 00:00:00 2001 From: Sebastian Messmer Date: Mon, 27 Apr 2015 18:20:51 +0200 Subject: [PATCH] Make constructors explicit where adequate --- implementations/caching/Cache.cpp | 2 +- implementations/caching/CacheEntry.h | 2 +- implementations/caching/CachingBlockStore.h | 2 +- implementations/ondisk/FileAlreadyExistsException.h | 3 ++- implementations/ondisk/OnDiskBlockStore.h | 2 +- implementations/parallelaccess/BlockRef.h | 2 +- implementations/parallelaccess/ParallelAccessBlockStore.h | 2 +- .../parallelaccess/ParallelAccessBlockStoreAdapter.h | 2 +- utils/FileDoesntExistException.h | 2 +- 9 files changed, 10 insertions(+), 9 deletions(-) diff --git a/implementations/caching/Cache.cpp b/implementations/caching/Cache.cpp index 45b5b281..0a5943a4 100644 --- a/implementations/caching/Cache.cpp +++ b/implementations/caching/Cache.cpp @@ -42,7 +42,7 @@ void Cache::push(unique_ptr block) { assert(_cachedBlocks.size() == MAX_ENTRIES-1); } Key key = block->key(); - _cachedBlocks.push(key, std::move(block)); + _cachedBlocks.push(key, CacheEntry(std::move(block))); } void Cache::_popOldEntries() { diff --git a/implementations/caching/CacheEntry.h b/implementations/caching/CacheEntry.h index cbe03af8..5ca2c6bc 100644 --- a/implementations/caching/CacheEntry.h +++ b/implementations/caching/CacheEntry.h @@ -13,7 +13,7 @@ namespace caching { class CacheEntry { public: - CacheEntry(std::unique_ptr block): _lastAccess(currentTime()), _block(std::move(block)) { + explicit CacheEntry(std::unique_ptr block): _lastAccess(currentTime()), _block(std::move(block)) { } CacheEntry(CacheEntry &&) = default; diff --git a/implementations/caching/CachingBlockStore.h b/implementations/caching/CachingBlockStore.h index ae298f24..a30eb4c7 100644 --- a/implementations/caching/CachingBlockStore.h +++ b/implementations/caching/CachingBlockStore.h @@ -11,7 +11,7 @@ namespace caching { //TODO Check that this blockstore allows parallel destructing of blocks (otherwise we won't encrypt blocks in parallel) class CachingBlockStore: public BlockStore { public: - CachingBlockStore(std::unique_ptr baseBlockStore); + explicit CachingBlockStore(std::unique_ptr baseBlockStore); Key createKey() override; std::unique_ptr tryCreate(const Key &key, cpputils::Data data) override; diff --git a/implementations/ondisk/FileAlreadyExistsException.h b/implementations/ondisk/FileAlreadyExistsException.h index 2a23fdd1..85cf18e5 100644 --- a/implementations/ondisk/FileAlreadyExistsException.h +++ b/implementations/ondisk/FileAlreadyExistsException.h @@ -9,9 +9,10 @@ namespace blockstore { namespace ondisk { +//TODO We probably don't want an exception for that class FileAlreadyExistsException: public std::runtime_error { public: - FileAlreadyExistsException(const boost::filesystem::path &filepath); + explicit FileAlreadyExistsException(const boost::filesystem::path &filepath); virtual ~FileAlreadyExistsException(); }; diff --git a/implementations/ondisk/OnDiskBlockStore.h b/implementations/ondisk/OnDiskBlockStore.h index 98ba7163..af7f72fc 100644 --- a/implementations/ondisk/OnDiskBlockStore.h +++ b/implementations/ondisk/OnDiskBlockStore.h @@ -12,7 +12,7 @@ namespace ondisk { class OnDiskBlockStore: public BlockStoreWithRandomKeys { public: - OnDiskBlockStore(const boost::filesystem::path &rootdir); + explicit OnDiskBlockStore(const boost::filesystem::path &rootdir); std::unique_ptr tryCreate(const Key &key, cpputils::Data data) override; std::unique_ptr load(const Key &key) override; diff --git a/implementations/parallelaccess/BlockRef.h b/implementations/parallelaccess/BlockRef.h index a379ef7f..588b3c6e 100644 --- a/implementations/parallelaccess/BlockRef.h +++ b/implementations/parallelaccess/BlockRef.h @@ -14,7 +14,7 @@ class ParallelAccessBlockStore; class BlockRef: public Block, public parallelaccessstore::ParallelAccessStore::ResourceRefBase { public: //TODO Unneccessarily storing Key twice here (in parent class and in _baseBlock). - BlockRef(Block *baseBlock): Block(baseBlock->key()), _baseBlock(baseBlock) {} + explicit BlockRef(Block *baseBlock): Block(baseBlock->key()), _baseBlock(baseBlock) {} const void *data() const override { return _baseBlock->data(); diff --git a/implementations/parallelaccess/ParallelAccessBlockStore.h b/implementations/parallelaccess/ParallelAccessBlockStore.h index 8ba08ba6..2f896b09 100644 --- a/implementations/parallelaccess/ParallelAccessBlockStore.h +++ b/implementations/parallelaccess/ParallelAccessBlockStore.h @@ -12,7 +12,7 @@ namespace parallelaccess { //TODO Check that this blockstore allows parallel destructing of blocks (otherwise we won't encrypt blocks in parallel) class ParallelAccessBlockStore: public BlockStore { public: - ParallelAccessBlockStore(std::unique_ptr baseBlockStore); + explicit ParallelAccessBlockStore(std::unique_ptr baseBlockStore); Key createKey() override; std::unique_ptr tryCreate(const Key &key, cpputils::Data data) override; diff --git a/implementations/parallelaccess/ParallelAccessBlockStoreAdapter.h b/implementations/parallelaccess/ParallelAccessBlockStoreAdapter.h index 56c9d7de..d4784f16 100644 --- a/implementations/parallelaccess/ParallelAccessBlockStoreAdapter.h +++ b/implementations/parallelaccess/ParallelAccessBlockStoreAdapter.h @@ -10,7 +10,7 @@ namespace parallelaccess { class ParallelAccessBlockStoreAdapter: public parallelaccessstore::ParallelAccessBaseStore { public: - ParallelAccessBlockStoreAdapter(BlockStore *baseBlockStore) + explicit ParallelAccessBlockStoreAdapter(BlockStore *baseBlockStore) :_baseBlockStore(std::move(baseBlockStore)) { } diff --git a/utils/FileDoesntExistException.h b/utils/FileDoesntExistException.h index d4c0a521..9ae623db 100644 --- a/utils/FileDoesntExistException.h +++ b/utils/FileDoesntExistException.h @@ -10,7 +10,7 @@ namespace blockstore { class FileDoesntExistException: public std::runtime_error { public: - FileDoesntExistException(const boost::filesystem::path &filepath); + explicit FileDoesntExistException(const boost::filesystem::path &filepath); virtual ~FileDoesntExistException(); };