2015-03-31 14:02:24 +02:00
|
|
|
#pragma once
|
2015-04-02 13:12:29 +02:00
|
|
|
#ifndef BLOCKSTORE_IMPLEMENTATIONS_CACHING_CACHEDBLOCKREF_H_
|
|
|
|
#define BLOCKSTORE_IMPLEMENTATIONS_CACHING_CACHEDBLOCKREF_H_
|
2015-03-31 14:02:24 +02:00
|
|
|
|
2015-04-16 14:54:04 +02:00
|
|
|
#include <messmer/parallelaccessstore/ParallelAccessStore.h>
|
2015-03-31 14:02:24 +02:00
|
|
|
#include "../../interface/Block.h"
|
|
|
|
#include "messmer/cpp-utils/macros.h"
|
|
|
|
#include <memory>
|
|
|
|
|
|
|
|
namespace blockstore {
|
2015-04-16 13:59:52 +02:00
|
|
|
namespace parallelaccess {
|
|
|
|
class ParallelAccessBlockStore;
|
2015-03-31 14:02:24 +02:00
|
|
|
|
2015-04-16 14:54:04 +02:00
|
|
|
class BlockRef: public Block, public parallelaccessstore::ParallelAccessStore<Block, BlockRef, Key>::ResourceRefBase {
|
2015-03-31 14:02:24 +02:00
|
|
|
public:
|
2015-04-02 18:19:05 +02:00
|
|
|
//TODO Unneccessarily storing Key twice here (in parent class and in _baseBlock).
|
2015-04-16 13:59:52 +02:00
|
|
|
BlockRef(Block *baseBlock): Block(baseBlock->key()), _baseBlock(baseBlock) {}
|
2015-03-31 14:02:24 +02:00
|
|
|
|
2015-04-02 18:19:05 +02:00
|
|
|
const void *data() const override {
|
|
|
|
return _baseBlock->data();
|
|
|
|
}
|
2015-03-31 14:02:24 +02:00
|
|
|
|
2015-04-02 18:19:05 +02:00
|
|
|
void write(const void *source, uint64_t offset, uint64_t size) override {
|
|
|
|
return _baseBlock->write(source, offset, size);
|
|
|
|
}
|
|
|
|
|
|
|
|
void flush() override {
|
|
|
|
return _baseBlock->flush();
|
|
|
|
}
|
|
|
|
|
|
|
|
size_t size() const override {
|
|
|
|
return _baseBlock->size();
|
|
|
|
}
|
2015-03-31 14:02:24 +02:00
|
|
|
|
|
|
|
private:
|
|
|
|
Block *_baseBlock;
|
|
|
|
|
2015-04-16 13:59:52 +02:00
|
|
|
DISALLOW_COPY_AND_ASSIGN(BlockRef);
|
2015-03-31 14:02:24 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|