diff --git a/include/openPMD/LoadStoreChunk.hpp b/include/openPMD/LoadStoreChunk.hpp index 7818ce0137..197e3459fc 100644 --- a/include/openPMD/LoadStoreChunk.hpp +++ b/include/openPMD/LoadStoreChunk.hpp @@ -121,6 +121,10 @@ class ConfigureLoadStore : protected internal::ConfigureLoadStoreData template [[nodiscard]] auto enqueueLoad() -> std::shared_ptr; + + using shared_ptr_dataset_types = auxiliary::detail:: + map_variant::type; + [[nodiscard]] auto enqueueLoadVariant() -> shared_ptr_dataset_types; }; template diff --git a/src/LoadStoreChunk.cpp b/src/LoadStoreChunk.cpp index c229844dab..4d81371604 100644 --- a/src/LoadStoreChunk.cpp +++ b/src/LoadStoreChunk.cpp @@ -133,6 +133,29 @@ auto ConfigureLoadStore::enqueueLoad() -> std::shared_ptr return m_rc.loadChunkAllocate_impl(storeChunkConfig()); } +namespace +{ + template + struct VisitorEnqueueLoadVariant + { + template + static auto call(RecordComponent const &, ConfigureLoadStore_t &cfg) -> + typename ConfigureLoadStore_t::shared_ptr_dataset_types + { + return cfg.template enqueueLoad(); + } + }; +} // namespace + +template +auto ConfigureLoadStore::enqueueLoadVariant() + -> shared_ptr_dataset_types +{ + return m_rc + .visit>>( + *this); +} + template ConfigureStoreChunkFromBuffer:: ConfigureStoreChunkFromBuffer(Ptr_Type buffer, parent_t &&parent) diff --git a/test/SerialIOTest.cpp b/test/SerialIOTest.cpp index bbb8225d4a..1e201580e2 100644 --- a/test/SerialIOTest.cpp +++ b/test/SerialIOTest.cpp @@ -1659,13 +1659,17 @@ inline void write_test(const std::string &backend) auto opaqueTypeDataset = rc.visit(); auto variantTypeDataset = rc.loadChunkVariant(); + auto variantTypeDataset2 = rc.prepareLoadStore().enqueueLoadVariant(); rc.seriesFlush(); - std::visit( - [](auto &&shared_ptr) { - std::cout << "First value in loaded chunk: '" << shared_ptr.get()[0] - << '\'' << std::endl; - }, - variantTypeDataset); + for (auto ptr : {&variantTypeDataset, &variantTypeDataset2}) + { + std::visit( + [](auto &&shared_ptr) { + std::cout << "First value in loaded chunk: '" + << shared_ptr.get()[0] << '\'' << std::endl; + }, + *ptr); + } } TEST_CASE("write_test", "[serial]")