libcryfs/implementations/onblocks/datanodestore/DataNodeStore.h

61 lines
1.6 KiB
C
Raw Normal View History

#pragma once
2015-10-15 13:10:20 +02:00
#ifndef MESSMER_BLOBSTORE_IMPLEMENTATIONS_ONBLOCKS_DATANODESTORE_DATANODESTORE_H_
#define MESSMER_BLOBSTORE_IMPLEMENTATIONS_ONBLOCKS_DATANODESTORE_DATANODESTORE_H_
#include <memory>
2015-02-17 00:40:34 +01:00
#include "messmer/cpp-utils/macros.h"
#include "DataNodeView.h"
2015-04-09 20:07:21 +02:00
#include <messmer/blockstore/utils/Key.h>
namespace blockstore{
class Block;
class BlockStore;
}
namespace blobstore {
namespace onblocks {
namespace datanodestore {
class DataNode;
2014-12-13 17:58:11 +01:00
class DataLeafNode;
class DataInnerNode;
class DataNodeStore final {
public:
2015-06-26 15:59:18 +02:00
DataNodeStore(cpputils::unique_ref<blockstore::BlockStore> blockstore, uint32_t blocksizeBytes);
~DataNodeStore();
static constexpr uint8_t MAX_DEPTH = 10;
DataNodeLayout layout() const;
2015-06-26 15:59:18 +02:00
boost::optional<cpputils::unique_ref<DataNode>> load(const blockstore::Key &key);
2015-06-26 15:59:18 +02:00
cpputils::unique_ref<DataLeafNode> createNewLeafNode();
cpputils::unique_ref<DataInnerNode> createNewInnerNode(const DataNode &first_child);
2015-06-26 15:59:18 +02:00
cpputils::unique_ref<DataNode> createNewNodeAsCopyFrom(const DataNode &source);
2015-06-26 15:59:18 +02:00
cpputils::unique_ref<DataNode> overwriteNodeWith(cpputils::unique_ref<DataNode> target, const DataNode &source);
2015-06-26 15:59:18 +02:00
void remove(cpputils::unique_ref<DataNode> node);
2015-06-26 15:59:18 +02:00
void removeSubtree(cpputils::unique_ref<DataNode> node);
uint64_t numNodes() const;
//TODO Test overwriteNodeWith(), createNodeAsCopyFrom(), removeSubtree()
private:
cpputils::unique_ref<DataNode> load(cpputils::unique_ref<blockstore::Block> block);
2015-06-26 15:59:18 +02:00
cpputils::unique_ref<blockstore::BlockStore> _blockstore;
const DataNodeLayout _layout;
DISALLOW_COPY_AND_ASSIGN(DataNodeStore);
};
}
}
}
#endif