2015-04-02 08:59:43 +02:00
|
|
|
#include <messmer/blockstore/implementations/caching/CachedBlockRef.h>
|
|
|
|
#include <messmer/blockstore/implementations/caching/CachingBlockStore.h>
|
2015-03-31 14:02:24 +02:00
|
|
|
|
|
|
|
using std::shared_ptr;
|
|
|
|
using std::make_unique;
|
|
|
|
using std::function;
|
|
|
|
|
|
|
|
namespace blockstore {
|
2015-04-02 08:59:43 +02:00
|
|
|
namespace caching {
|
2015-03-31 14:02:24 +02:00
|
|
|
|
2015-04-02 13:12:29 +02:00
|
|
|
CachedBlockRef::CachedBlockRef(Block *baseBlock)
|
2015-03-31 14:02:24 +02:00
|
|
|
:Block(baseBlock->key()),
|
2015-04-02 13:12:29 +02:00
|
|
|
_baseBlock(baseBlock) {
|
2015-03-31 14:02:24 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
CachedBlockRef::~CachedBlockRef() {
|
|
|
|
_baseBlock->flush();
|
|
|
|
}
|
|
|
|
|
|
|
|
const void *CachedBlockRef::data() const {
|
|
|
|
return _baseBlock->data();
|
|
|
|
}
|
|
|
|
|
|
|
|
void CachedBlockRef::write(const void *source, uint64_t offset, uint64_t size) {
|
|
|
|
return _baseBlock->write(source, offset, size);
|
|
|
|
}
|
|
|
|
|
|
|
|
size_t CachedBlockRef::size() const {
|
|
|
|
return _baseBlock->size();
|
|
|
|
}
|
|
|
|
|
|
|
|
void CachedBlockRef::flush() {
|
|
|
|
return _baseBlock->flush();
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|