2014-12-09 17:19:59 +01:00
|
|
|
#pragma once
|
|
|
|
#ifndef BLOCKSTORE_IMPLEMENTATIONS_INMEMORY_INMEMORYBLOCKSTORE_H_
|
|
|
|
#define BLOCKSTORE_IMPLEMENTATIONS_INMEMORY_INMEMORYBLOCKSTORE_H_
|
|
|
|
|
2015-03-12 14:27:51 +01:00
|
|
|
#include "../../interface/helpers/BlockStoreWithRandomKeys.h"
|
2015-02-17 00:23:33 +01:00
|
|
|
#include <messmer/cpp-utils/macros.h>
|
2014-12-09 17:19:59 +01:00
|
|
|
|
|
|
|
#include <mutex>
|
|
|
|
#include <map>
|
|
|
|
|
|
|
|
namespace blockstore {
|
|
|
|
namespace inmemory {
|
|
|
|
class InMemoryBlock;
|
|
|
|
|
|
|
|
class InMemoryBlockStore: public BlockStoreWithRandomKeys {
|
|
|
|
public:
|
|
|
|
InMemoryBlockStore();
|
|
|
|
|
2015-04-25 02:48:41 +02:00
|
|
|
std::unique_ptr<Block> tryCreate(const Key &key, cpputils::Data data) override;
|
2014-12-09 20:36:32 +01:00
|
|
|
std::unique_ptr<Block> load(const Key &key) override;
|
2015-02-22 16:53:49 +01:00
|
|
|
void remove(std::unique_ptr<Block> block) override;
|
2015-02-23 21:07:07 +01:00
|
|
|
uint64_t numBlocks() const override;
|
2014-12-09 17:19:59 +01:00
|
|
|
|
|
|
|
private:
|
|
|
|
std::map<std::string, InMemoryBlock> _blocks;
|
|
|
|
|
|
|
|
DISALLOW_COPY_AND_ASSIGN(InMemoryBlockStore);
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|