Pulp 1.88.0
Cross-platform audio plugin framework
Loading...
Searching...
No Matches
scripted_ui_swap_unit.hpp
Go to the documentation of this file.
1#pragma once
2
16
19
20#include <filesystem>
21#include <string>
22#include <utility>
23
24namespace pulp::format::reload {
25
27public:
29 std::filesystem::path new_script,
30 std::string stage_name = "ux")
31 : session_(session),
32 new_script_(std::move(new_script)),
33 name_(std::move(stage_name)) {}
34
35 std::string name() const override { return name_; }
36
37 SwapStage to_stage() override {
38 prev_script_ = session_.script_path(); // pre-transaction UI, for rollback
39 return SwapStage{
40 name_,
41 [this] { return session_.reload_from(new_script_); },
42 [this] {
43 // Re-apply the previous bundle if we actually changed it. (No-op
44 // when the swap targets the same path.) reload_from is last-good,
45 // so a failed rollback leaves a valid UI rather than a broken one.
46 if (prev_script_ != new_script_)
47 (void)session_.reload_from(prev_script_);
48 }};
49 }
50
51private:
53 std::filesystem::path new_script_;
54 std::filesystem::path prev_script_;
55 std::string name_;
56};
57
58} // namespace pulp::format::reload
ScriptedUiSwapUnit(view::ScriptedUiSession &session, std::filesystem::path new_script, std::string stage_name="ux")
Definition scripted_ui_swap_unit.hpp:28
SwapStage to_stage() override
Build the stage for this unit's pending swap, capturing the current state for rollback.
Definition scripted_ui_swap_unit.hpp:37
std::string name() const override
Human-readable identity, surfaced in LiveSwapResult::failed_stage.
Definition scripted_ui_swap_unit.hpp:35
The contract a swappable subsystem implements to join a live-swap transaction
Definition live_swap_transaction.hpp:102
Definition scripted_ui.hpp:125
One reload session = one atomic unit across UX + DSP.
Definition build_fingerprint.hpp:23
STL namespace.
One half of a live swap.
Definition live_swap_transaction.hpp:38