libcryfs/implementations/onblocks/BlobStoreOnBlocks.cpp

53 lines
1.6 KiB
C++
Raw Normal View History

2015-04-16 14:10:58 +02:00
#include <messmer/blockstore/implementations/parallelaccess/ParallelAccessBlockStore.h>
2015-02-17 00:40:34 +01:00
#include "datanodestore/DataLeafNode.h"
#include "datanodestore/DataNodeStore.h"
#include "datatreestore/DataTreeStore.h"
#include "datatreestore/DataTree.h"
#include "cachingdatatreestore/CachingDataTreeStore.h"
#include "cachingdatatreestore/CachedDataTreeRef.h"
2014-12-09 17:56:48 +01:00
#include "BlobStoreOnBlocks.h"
#include "BlobOnBlocks.h"
#include <messmer/cpp-utils/pointer.h>
2014-12-09 17:56:48 +01:00
using std::unique_ptr;
using std::make_unique;
using blockstore::BlockStore;
2015-04-16 14:10:58 +02:00
using blockstore::parallelaccess::ParallelAccessBlockStore;
using blockstore::Key;
using cpputils::dynamic_pointer_move;
namespace blobstore {
namespace onblocks {
using datanodestore::DataNodeStore;
using datatreestore::DataTreeStore;
using cachingdatatreestore::CachingDataTreeStore;
BlobStoreOnBlocks::BlobStoreOnBlocks(unique_ptr<BlockStore> blockStore, uint32_t blocksizeBytes)
2015-04-16 14:10:58 +02:00
: _dataTreeStore(make_unique<CachingDataTreeStore>(make_unique<DataTreeStore>(make_unique<DataNodeStore>(make_unique<ParallelAccessBlockStore>(std::move(blockStore)), blocksizeBytes)))) {
}
BlobStoreOnBlocks::~BlobStoreOnBlocks() {
}
unique_ptr<Blob> BlobStoreOnBlocks::create() {
return make_unique<BlobOnBlocks>(_dataTreeStore->createNewTree());
2014-12-09 17:56:48 +01:00
}
unique_ptr<Blob> BlobStoreOnBlocks::load(const Key &key) {
auto tree = _dataTreeStore->load(key);
if (tree == nullptr) {
return nullptr;
}
return make_unique<BlobOnBlocks>(std::move(tree));
}
void BlobStoreOnBlocks::remove(unique_ptr<Blob> blob) {
auto _blob = dynamic_pointer_move<BlobOnBlocks>(blob);
_dataTreeStore->remove(_blob->releaseTree());
2014-12-09 17:56:48 +01:00
}
}
}