2014-12-09 17:19:59 +01:00
|
|
|
#pragma once
|
|
|
|
#ifndef BLOCKSTORE_INTERFACE_BLOCK_H_
|
|
|
|
#define BLOCKSTORE_INTERFACE_BLOCK_H_
|
|
|
|
|
2015-03-12 14:27:51 +01:00
|
|
|
#include "../utils/Key.h"
|
2014-12-09 17:19:59 +01:00
|
|
|
#include <cstring>
|
|
|
|
|
|
|
|
namespace blockstore {
|
|
|
|
|
|
|
|
class Block {
|
|
|
|
public:
|
|
|
|
virtual ~Block() {}
|
|
|
|
|
|
|
|
virtual const void *data() const = 0;
|
2015-03-04 20:47:02 +01:00
|
|
|
virtual void write(const void *source, uint64_t offset, uint64_t size) = 0;
|
2014-12-09 17:19:59 +01:00
|
|
|
|
|
|
|
virtual void flush() = 0;
|
|
|
|
|
|
|
|
virtual size_t size() const = 0;
|
2015-01-24 22:08:41 +01:00
|
|
|
|
|
|
|
const Key &key() const {
|
|
|
|
return _key;
|
|
|
|
}
|
|
|
|
|
|
|
|
protected:
|
|
|
|
Block(const Key &key) : _key(key) {}
|
|
|
|
|
|
|
|
private:
|
|
|
|
const Key _key;
|
2014-12-09 17:19:59 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#endif
|