37 buffer_for(slot) = store_->serialize();
44 if (!store_)
return false;
45 const auto& buf = buffer_for(slot);
46 if (buf.empty())
return false;
47 if (!store_->deserialize(std::span<const uint8_t>(buf.data(), buf.size())))
61 if (src == dst)
return;
62 buffer_for(dst) = buffer_for(src);
71 bool has(
Slot slot)
const {
return !buffer_for(slot).empty(); }
79 const auto&
b = buffer_for(slot);
80 return {
b.data(),
b.size()};
84 std::vector<uint8_t>& buffer_for(
Slot slot) {
85 return slots_[
static_cast<size_t>(slot)];
87 const std::vector<uint8_t>& buffer_for(
Slot slot)
const {
88 return slots_[
static_cast<size_t>(slot)];
91 state::StateStore* store_ =
nullptr;
92 std::array<std::vector<uint8_t>, 2> slots_;
Centralized parameter storage with lock-free value access.
Definition store.hpp:164
void save_to(Slot slot)
Capture the StateStore's current state into slot.
Definition ab_compare.hpp:35
void swap()
Swap A and B.
Definition ab_compare.hpp:66
Slot
Definition ab_compare.hpp:26
@ A
Definition ab_compare.hpp:26
@ B
Definition ab_compare.hpp:26
void clear(Slot slot)
Drop any saved snapshot from slot.
Definition ab_compare.hpp:74
Slot current() const
Which slot is currently live (i.e.
Definition ab_compare.hpp:32
bool has(Slot slot) const
Does slot currently hold a snapshot?
Definition ab_compare.hpp:71
bool load_from(Slot slot)
Restore the StateStore from slot.
Definition ab_compare.hpp:43
bool toggle()
Toggle between A and B. Fails if the target slot has no snapshot.
Definition ab_compare.hpp:54
void copy(Slot src, Slot dst)
Overwrite dst with a copy of src's snapshot.
Definition ab_compare.hpp:60
ABCompare(state::StateStore *store)
Definition ab_compare.hpp:28
std::span< const uint8_t > snapshot(Slot slot) const
Raw snapshot bytes (exposed for serialization of the A/B pair itself — e.g.
Definition ab_compare.hpp:78
Hover-cursor tracking for platform window hosts.
Definition fwd.hpp:27
@ b
Definition input_events.hpp:39