Created basic class structure for blobstore

This commit is contained in:
Sebastian Messmer 2014-12-09 17:45:33 +01:00
parent 93a624b228
commit 532431f8e3
10 changed files with 139 additions and 0 deletions

View File

@ -0,0 +1,3 @@
#add_subdirectory(interface)
#add_subdirectory(utils)
add_subdirectory(implementations)

View File

@ -0,0 +1 @@
add_subdirectory(onblocks)

View File

@ -0,0 +1,14 @@
#include <blobstore/implementations/onblocks/BlobOnBlocks.h>
namespace blobstore {
namespace onblocks {
BlobOnBlocks::BlobOnBlocks() {
}
BlobOnBlocks::~BlobOnBlocks() {
}
}
}

View File

@ -0,0 +1,17 @@
#pragma once
#ifndef BLOBSTORE_IMPLEMENTATIONS_ONBLOCKS_BLOBONBLOCKS_H_
#define BLOBSTORE_IMPLEMENTATIONS_ONBLOCKS_BLOBONBLOCKS_H_
namespace blobstore {
namespace onblocks {
class BlobOnBlocks {
public:
BlobOnBlocks();
virtual ~BlobOnBlocks();
};
}
}
#endif

View File

@ -0,0 +1,13 @@
#include <blobstore/implementations/onblocks/BlobStoreOnBlocks.h>
namespace blobstore {
namespace onblocks {
BlobStoreOnBlocks::BlobStoreOnBlocks() {
}
BlobStoreOnBlocks::~BlobStoreOnBlocks() {
}
}
}

View File

@ -0,0 +1,17 @@
#pragma once
#ifndef BLOBSTORE_IMPLEMENTATIONS_BLOCKED_BLOBSTOREONBLOCKS_H_
#define BLOBSTORE_IMPLEMENTATIONS_BLOCKED_BLOBSTOREONBLOCKS_H_
namespace blobstore {
namespace onblocks {
class BlobStoreOnBlocks {
public:
BlobStoreOnBlocks();
virtual ~BlobStoreOnBlocks();
};
}
}
#endif

View File

@ -0,0 +1,3 @@
add_library(blobstore_onblocks BlobOnBlocks.cpp BlobStoreOnBlocks)
target_link_libraries(blobstore_onblocks blockstore_interface)

View File

@ -0,0 +1,24 @@
#pragma once
#ifndef BLOBSTORE_INTERFACE_BLOB_H_
#define BLOBSTORE_INTERFACE_BLOB_H_
#include <cstring>
namespace blobstore {
class Blob {
public:
virtual ~Blob() {}
virtual void *data() = 0;
virtual const void *data() const = 0;
virtual void flush() = 0;
virtual size_t size() const = 0;
};
}
#endif

View File

@ -0,0 +1,27 @@
#pragma once
#ifndef FSPP_BLOBSTORE_BLOBSTORE_H_
#define FSPP_BLOBSTORE_BLOBSTORE_H_
#include "Blob.h"
#include "blobstore/utils/BlobWithKey.h"
#include <string>
#include <memory>
namespace blobstore {
class BlobStore {
public:
virtual ~BlobStore() {}
virtual BlobWithKey create(size_t size) = 0;
//TODO Use boost::optional (if key doesn't exist)
// Return nullptr if block with this key doesn't exists
virtual std::unique_ptr<Blob> load(const std::string &key) = 0;
//TODO Needed for performance? Or is deleting loaded blocks enough?
//virtual void remove(const std::string &key) = 0;
};
}
#endif

View File

@ -0,0 +1,20 @@
#pragma once
#ifndef BLOBSTORE_INTERFACE_BLOBWITHKEY_H_
#define BLOBSTORE_INTERFACE_BLOBWITHKEY_H_
#include <blobstore/interface/Blob.h>
#include <memory>
#include "fspp/utils/macros.h"
namespace blobstore {
struct BlobWithKey {
BlobWithKey(const std::string &key_, std::unique_ptr<Blocb> blob_): key(key_), blob(std::move(blob_)) {}
std::string key;
std::unique_ptr<Block> blob;
};
}
#endif