libcryfs/implementations/onblocks/BlobOnBlocks.h

53 lines
1.4 KiB
C
Raw Normal View History

#pragma once
2015-10-15 13:10:20 +02:00
#ifndef MESSMER_BLOBSTORE_IMPLEMENTATIONS_ONBLOCKS_BLOBONBLOCKS_H_
#define MESSMER_BLOBSTORE_IMPLEMENTATIONS_ONBLOCKS_BLOBONBLOCKS_H_
2015-02-17 00:40:34 +01:00
#include "../../interface/Blob.h"
2014-12-09 17:56:48 +01:00
#include <memory>
#include <boost/optional.hpp>
2014-12-09 17:56:48 +01:00
namespace blobstore {
namespace onblocks {
namespace datanodestore {
class DataLeafNode;
}
namespace parallelaccessdatatreestore {
class DataTreeRef;
}
class BlobOnBlocks final: public Blob {
public:
2015-06-26 15:59:18 +02:00
BlobOnBlocks(cpputils::unique_ref<parallelaccessdatatreestore::DataTreeRef> datatree);
~BlobOnBlocks();
2014-12-09 17:56:48 +01:00
const blockstore::Key &key() const override;
2015-02-27 00:18:26 +01:00
uint64_t size() const override;
void resize(uint64_t numBytes) override;
2014-12-09 17:56:48 +01:00
cpputils::Data readAll() const override;
void read(void *target, uint64_t offset, uint64_t size) const override;
2015-03-11 01:04:48 +01:00
uint64_t tryRead(void *target, uint64_t offset, uint64_t size) const override;
void write(const void *source, uint64_t offset, uint64_t size) override;
2015-04-09 23:41:51 +02:00
void flush() override;
2015-06-26 15:59:18 +02:00
cpputils::unique_ref<parallelaccessdatatreestore::DataTreeRef> releaseTree();
2014-12-09 17:56:48 +01:00
private:
void _read(void *target, uint64_t offset, uint64_t count) const;
void traverseLeaves(uint64_t offsetBytes, uint64_t sizeBytes, std::function<void (uint64_t, datanodestore::DataLeafNode *, uint32_t, uint32_t)>) const;
2015-06-26 15:59:18 +02:00
cpputils::unique_ref<parallelaccessdatatreestore::DataTreeRef> _datatree;
mutable boost::optional<uint64_t> _sizeCache;
DISALLOW_COPY_AND_ASSIGN(BlobOnBlocks);
};
}
}
#endif