2014-12-09 17:19:59 +01:00
|
|
|
#pragma once
|
|
|
|
#ifndef FSPP_BLOCKSTORE_BLOCKSTOREWITHRANDOMKEYS_H_
|
|
|
|
#define FSPP_BLOCKSTORE_BLOCKSTOREWITHRANDOMKEYS_H_
|
|
|
|
|
2015-03-12 14:27:51 +01:00
|
|
|
#include "../BlockStore.h"
|
2015-02-17 00:23:33 +01:00
|
|
|
#include "../Block.h"
|
2014-12-09 17:19:59 +01:00
|
|
|
|
|
|
|
namespace blockstore {
|
|
|
|
|
|
|
|
// This is an implementation helpers for BlockStores that use random block keys.
|
|
|
|
// You should never give this static type to the client. The client should always
|
|
|
|
// work with the BlockStore interface instead.
|
|
|
|
class BlockStoreWithRandomKeys: public BlockStore {
|
|
|
|
public:
|
|
|
|
//TODO Use boost::optional (if key already exists)
|
|
|
|
// Return nullptr if key already exists
|
2014-12-09 20:36:32 +01:00
|
|
|
virtual std::unique_ptr<Block> create(const Key &key, size_t size) = 0;
|
2014-12-09 17:19:59 +01:00
|
|
|
|
2015-01-24 22:27:14 +01:00
|
|
|
std::unique_ptr<Block> create(size_t size) final;
|
2014-12-09 17:19:59 +01:00
|
|
|
|
|
|
|
private:
|
2015-01-24 22:27:14 +01:00
|
|
|
std::unique_ptr<Block> tryCreate(size_t size);
|
2014-12-09 17:19:59 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|