libcryfs/implementations/parallelaccess/ParallelAccessBlockStoreAdapter.h

37 lines
1.2 KiB
C
Raw Normal View History

#ifndef MESSMER_BLOCKSTORE_IMPLEMENTATIONS_PARALLELACCESS_PARALLELACCESSBLOCKSTOREADAPTER_H_
#define MESSMER_BLOCKSTORE_IMPLEMENTATIONS_PARALLELACCESS_PARALLELACCESSBLOCKSTOREADAPTER_H_
2015-04-02 18:19:05 +02:00
#include <messmer/cpp-utils/macros.h>
#include <messmer/parallelaccessstore/ParallelAccessStore.h>
2015-04-02 18:19:05 +02:00
#include "../../interface/BlockStore.h"
namespace blockstore {
namespace parallelaccess {
2015-04-02 18:19:05 +02:00
class ParallelAccessBlockStoreAdapter: public parallelaccessstore::ParallelAccessBaseStore<Block, Key> {
2015-04-02 18:19:05 +02:00
public:
explicit ParallelAccessBlockStoreAdapter(BlockStore *baseBlockStore)
2015-04-02 18:19:05 +02:00
:_baseBlockStore(std::move(baseBlockStore)) {
}
boost::optional<cpputils::unique_ref<Block>> loadFromBaseStore(const Key &key) override {
//TODO Don't use nullcheck but make blockstore use unique_ref
return cpputils::nullcheck(_baseBlockStore->load(key));
2015-04-02 18:19:05 +02:00
}
void removeFromBaseStore(cpputils::unique_ref<Block> block) override {
//TODO Don't use to_unique_ptr but make blockstore use unique_ref
return _baseBlockStore->remove(cpputils::to_unique_ptr(std::move(block)));
2015-04-02 18:19:05 +02:00
}
private:
BlockStore *_baseBlockStore;
DISALLOW_COPY_AND_ASSIGN(ParallelAccessBlockStoreAdapter);
2015-04-02 18:19:05 +02:00
};
}
}
#endif