Make constructors explicit where adequate

This commit is contained in:
Sebastian Messmer 2015-04-27 18:20:51 +02:00
parent 58f43f6929
commit 2110831374
9 changed files with 10 additions and 9 deletions

View File

@ -42,7 +42,7 @@ void Cache::push(unique_ptr<Block> 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() {

View File

@ -13,7 +13,7 @@ namespace caching {
class CacheEntry {
public:
CacheEntry(std::unique_ptr<Block> block): _lastAccess(currentTime()), _block(std::move(block)) {
explicit CacheEntry(std::unique_ptr<Block> block): _lastAccess(currentTime()), _block(std::move(block)) {
}
CacheEntry(CacheEntry &&) = default;

View File

@ -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<BlockStore> baseBlockStore);
explicit CachingBlockStore(std::unique_ptr<BlockStore> baseBlockStore);
Key createKey() override;
std::unique_ptr<Block> tryCreate(const Key &key, cpputils::Data data) override;

View File

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

View File

@ -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<Block> tryCreate(const Key &key, cpputils::Data data) override;
std::unique_ptr<Block> load(const Key &key) override;

View File

@ -14,7 +14,7 @@ class ParallelAccessBlockStore;
class BlockRef: public Block, public parallelaccessstore::ParallelAccessStore<Block, BlockRef, Key>::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();

View File

@ -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<BlockStore> baseBlockStore);
explicit ParallelAccessBlockStore(std::unique_ptr<BlockStore> baseBlockStore);
Key createKey() override;
std::unique_ptr<Block> tryCreate(const Key &key, cpputils::Data data) override;

View File

@ -10,7 +10,7 @@ namespace parallelaccess {
class ParallelAccessBlockStoreAdapter: public parallelaccessstore::ParallelAccessBaseStore<Block, Key> {
public:
ParallelAccessBlockStoreAdapter(BlockStore *baseBlockStore)
explicit ParallelAccessBlockStoreAdapter(BlockStore *baseBlockStore)
:_baseBlockStore(std::move(baseBlockStore)) {
}

View File

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