From d9a9fe7a74878f483e50801f97303d438bd46874 Mon Sep 17 00:00:00 2001 From: Green Sky Date: Tue, 16 Jul 2024 15:56:30 +0200 Subject: [PATCH] add file2 experimentally to the backend interface --- src/solanaceae/object_store/object_store.cpp | 6 ++++++ src/solanaceae/object_store/object_store.hpp | 12 +++++++++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/src/solanaceae/object_store/object_store.cpp b/src/solanaceae/object_store/object_store.cpp index e459e94..26ed0c9 100644 --- a/src/solanaceae/object_store/object_store.cpp +++ b/src/solanaceae/object_store/object_store.cpp @@ -4,6 +4,8 @@ #include "./serializer_json.hpp" +#include + #include // this sucks #include @@ -70,6 +72,10 @@ bool StorageBackendI::write(Object o, const ByteSpan data) { return write(o, fn_cb); } +std::unique_ptr StorageBackendI::file2(Object o, FILE2_FLAGS flags) { + return nullptr; +} + ObjectStore2::ObjectStore2(void) { // HACK: set them up independently auto& sjc = _reg.ctx().emplace>(); diff --git a/src/solanaceae/object_store/object_store.hpp b/src/solanaceae/object_store/object_store.hpp index ebbb8f7..3d36410 100644 --- a/src/solanaceae/object_store/object_store.hpp +++ b/src/solanaceae/object_store/object_store.hpp @@ -15,6 +15,7 @@ using ObjectHandle = entt::basic_handle; // fwd struct ObjectStore2; +struct File2I; struct StorageBackendI { // OR or OS ? @@ -35,6 +36,15 @@ struct StorageBackendI { using read_from_storage_put_data_cb = void(const ByteSpan buffer); virtual bool read(Object o, std::function& data_cb) = 0; + // ========== File2 interop ========== + enum FILE2_FLAGS : uint32_t { + FILE2_READ = 1u << 0, + FILE2_WRITE = 1u << 1, + }; + // TODO: stronger requirements + // the backend might decide to not support writing using file2, if it's eg. zstd compressed + // backends might only support a single file2 instance per object! + std::unique_ptr file2(Object o, FILE2_FLAGS flags); // default does nothing }; namespace ObjectStore::Events { @@ -71,7 +81,7 @@ struct ObjectStoreEventI { using ObjectStoreEventProviderI = EventProviderI; struct ObjectStore2 : public ObjectStoreEventProviderI { - static constexpr const char* version {"2"}; + static constexpr const char* version {"3"}; ObjectRegistry _reg;