Repository navigation
fix(orchestrators): route stream assemble through the loader-based assemble #417
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
f681f8c
4f2975f
d53ef44
bdf6a1b
b880a31
acde405
17e71f1
f990121
4ae0098
abd6cce
dc3287b
dea70e8
efedbed
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -17,8 +17,69 @@ | |
| #pragma once | ||
|
|
||
| #include "svs/lib/misc.h" | ||
| #include "svs/lib/saveload/load.h" | ||
| #include "svs/lib/threads.h" | ||
|
|
||
| #include <filesystem> | ||
| #include <istream> | ||
| #include <tuple> | ||
| #include <type_traits> | ||
| #include <utility> | ||
|
|
||
| namespace svs { | ||
|
|
||
| /// | ||
| /// @brief Selects the element type and loader arguments for one component of an index. | ||
| /// | ||
| /// The orchestrator supplies the stream for native streams, or the unpacked component | ||
| /// directory for directory archives. | ||
| /// | ||
| /// @tparam T The type loaded from the component. | ||
| /// @tparam Args The types of the arguments forwarded to the load function (e.g. | ||
| /// allocators). | ||
| /// | ||
| template <typename T, typename... Args> struct StreamLoader { | ||
| using return_type = T; | ||
|
|
||
| explicit StreamLoader(Args... args) | ||
| : args_{std::move(args)...} {} | ||
|
|
||
| T load(std::istream& stream) const { | ||
| return std::apply( | ||
| [&](const Args&... args) { return lib::load_from_stream<T>(stream, args...); }, | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. what if one of
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It works so long it's passed as an |
||
| args_ | ||
| ); | ||
| } | ||
|
|
||
| T load(const std::filesystem::path& path) const { | ||
| return std::apply( | ||
| [&](const Args&... args) { return lib::load_from_disk<T>(path, args...); }, | ||
| args_ | ||
| ); | ||
| } | ||
|
|
||
| std::tuple<Args...> args_; | ||
| }; | ||
|
|
||
| /// | ||
| /// @brief Build a ``StreamLoader`` for ``T``, deducing the loader argument types. | ||
| /// | ||
| /// @tparam T The type loaded from the component. | ||
| /// | ||
| /// @param args Arguments forwarded to the load function, stored by value. | ||
| /// | ||
| template <typename T, typename... Args> | ||
| StreamLoader<T, std::decay_t<Args>...> make_stream_loader(Args&&... args) { | ||
| return StreamLoader<T, std::decay_t<Args>...>{std::forward<Args>(args)...}; | ||
| } | ||
|
|
||
| template <typename T> inline constexpr bool is_stream_loader_v = false; | ||
|
|
||
| template <typename T, typename... Args> | ||
| inline constexpr bool is_stream_loader_v<StreamLoader<T, Args...>> = true; | ||
|
|
||
| } // namespace svs | ||
|
|
||
| namespace svs::detail { | ||
|
|
||
| /// | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.