Created basic class structure for blobstore
This commit is contained in:
parent
93a624b228
commit
532431f8e3
3
src/blobstore/CMakeLists.txt
Normal file
3
src/blobstore/CMakeLists.txt
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
#add_subdirectory(interface)
|
||||||
|
#add_subdirectory(utils)
|
||||||
|
add_subdirectory(implementations)
|
1
src/blobstore/implementations/CMakeLists.txt
Normal file
1
src/blobstore/implementations/CMakeLists.txt
Normal file
@ -0,0 +1 @@
|
|||||||
|
add_subdirectory(onblocks)
|
14
src/blobstore/implementations/onblocks/BlobOnBlocks.cpp
Normal file
14
src/blobstore/implementations/onblocks/BlobOnBlocks.cpp
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
#include <blobstore/implementations/onblocks/BlobOnBlocks.h>
|
||||||
|
|
||||||
|
namespace blobstore {
|
||||||
|
namespace onblocks {
|
||||||
|
|
||||||
|
BlobOnBlocks::BlobOnBlocks() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
BlobOnBlocks::~BlobOnBlocks() {
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
17
src/blobstore/implementations/onblocks/BlobOnBlocks.h
Normal file
17
src/blobstore/implementations/onblocks/BlobOnBlocks.h
Normal 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
|
13
src/blobstore/implementations/onblocks/BlobStoreOnBlocks.cpp
Normal file
13
src/blobstore/implementations/onblocks/BlobStoreOnBlocks.cpp
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
#include <blobstore/implementations/onblocks/BlobStoreOnBlocks.h>
|
||||||
|
|
||||||
|
namespace blobstore {
|
||||||
|
namespace onblocks {
|
||||||
|
|
||||||
|
BlobStoreOnBlocks::BlobStoreOnBlocks() {
|
||||||
|
}
|
||||||
|
|
||||||
|
BlobStoreOnBlocks::~BlobStoreOnBlocks() {
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
17
src/blobstore/implementations/onblocks/BlobStoreOnBlocks.h
Normal file
17
src/blobstore/implementations/onblocks/BlobStoreOnBlocks.h
Normal 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
|
3
src/blobstore/implementations/onblocks/CMakeLists.txt
Normal file
3
src/blobstore/implementations/onblocks/CMakeLists.txt
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
add_library(blobstore_onblocks BlobOnBlocks.cpp BlobStoreOnBlocks)
|
||||||
|
|
||||||
|
target_link_libraries(blobstore_onblocks blockstore_interface)
|
24
src/blobstore/interface/Blob.h
Normal file
24
src/blobstore/interface/Blob.h
Normal 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
|
27
src/blobstore/interface/BlobStore.h
Normal file
27
src/blobstore/interface/BlobStore.h
Normal 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
|
20
src/blobstore/utils/BlobWithKey.h
Normal file
20
src/blobstore/utils/BlobWithKey.h
Normal 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
|
Loading…
x
Reference in New Issue
Block a user