Kun Yi | 68c8114 | 2018-12-18 11:17:14 -0800 | [diff] [blame] | 1 | #pragma once |
| 2 | |
| 3 | #include <cstdint> |
| 4 | #include <string> |
| 5 | #include <vector> |
| 6 | |
| 7 | using std::size_t; |
| 8 | using std::uint16_t; |
| 9 | using std::uint32_t; |
| 10 | using std::uint64_t; |
| 11 | using std::uint8_t; |
| 12 | |
| 13 | namespace binstore |
| 14 | { |
| 15 | |
| 16 | /** |
| 17 | * @class BinaryStoreInterface is an abstraction for a storage location. |
| 18 | * Each instance would be uniquely identified by a baseId string. |
| 19 | */ |
| 20 | class BinaryStoreInterface |
| 21 | { |
| 22 | public: |
| 23 | virtual ~BinaryStoreInterface() = default; |
| 24 | |
| 25 | virtual std::string getBaseBlobId() const = 0; |
| 26 | virtual std::vector<std::string> getBlobIds() const = 0; |
| 27 | virtual bool canHandleBlob(const std::string& blobId) const = 0; |
Kun Yi | 38146a0 | 2018-12-18 21:54:26 -0800 | [diff] [blame] | 28 | virtual bool openOrCreateBlob(const std::string& blobId, |
| 29 | uint16_t flags) = 0; |
Kun Yi | c0adbc3 | 2018-12-18 22:35:29 -0800 | [diff] [blame^] | 30 | virtual bool deleteBlob(const std::string& blobId) = 0; |
Kun Yi | 68c8114 | 2018-12-18 11:17:14 -0800 | [diff] [blame] | 31 | virtual std::vector<uint8_t> read(uint32_t offset, |
| 32 | uint32_t requestedSize) = 0; |
| 33 | virtual bool write(uint32_t offset, const std::vector<uint8_t>& data) = 0; |
| 34 | virtual bool commit() = 0; |
| 35 | virtual bool close() = 0; |
| 36 | virtual bool stat() = 0; |
| 37 | }; |
| 38 | |
| 39 | } // namespace binstore |