2015-03-31 14:02:24 +02:00
|
|
|
#pragma once
|
2015-10-15 13:09:21 +02:00
|
|
|
#ifndef MESSMER_BLOCKSTORE_IMPLEMENTATIONS_PARALLELACCESS_BLOCKREF_H_
|
|
|
|
#define MESSMER_BLOCKSTORE_IMPLEMENTATIONS_PARALLELACCESS_BLOCKREF_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-11-27 14:06:40 +01:00
|
|
|
class BlockRef final: 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-27 18:20:51 +02:00
|
|
|
explicit 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
|
|
|
|
2015-12-14 17:16:54 +01:00
|
|
|
void resize(size_t newSize) override {
|
|
|
|
return _baseBlock->resize(newSize);
|
|
|
|
}
|
|
|
|
|
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
|