Files
reasampler/src/shell/bank_ops/bank_ops.h
T

65 lines
3.1 KiB
C++

#pragma once
// bank_ops — the promptless bank-verb seam. Each verb is a model op on the given
// session's BankBook + persistBankOp (undo-batched ext-state persist) — NO prompts,
// NO message boxes, NO panel-state nudges. Two UX surfaces consume these as thin
// skins: shell/panel/panel_bank_ops (menu prompts/confirms/repaints) and
// shell/actions/bank_actions (bindable family, text prompts/console feedback).
//
// The session arrives BY REFERENCE, so a missing session can never be
// half-reported as a model rejection from in here. Every verb returns whether the
// model accepted the mutation — a rejected op persists nothing and opens no undo
// point. REAPER-facing (persist + undo blocks + GUID minting) but SDK-free header.
#include <string>
#include <vector>
namespace reasampler {
class ReaSamplerSession;
// Returns "" when the model rejects the name (duplicate, trimmed + case-insensitive).
// Purely organizational — no generation bump.
std::string bankOpCreate(ReaSamplerSession& session, const std::string& name);
// False when the model rejects (pool un-renamable / name in use).
bool bankOpRename(ReaSamplerSession& session, const std::string& bankId,
const std::string& newName);
// False when the model rejects (pool un-deletable). `bumpGeneration` should be the
// member count read BEFORE any evacuate/delete (an evacuate-then-delete flow must
// still bump on the ORIGINAL membership).
bool bankOpDelete(ReaSamplerSession& session, const std::string& bankId,
bool bumpGeneration);
// False when the model rejects (the pool itself). Bumps the generation.
bool bankOpEvacuate(ReaSamplerSession& session, const std::string& bankId);
// False on an unknown id. No bump.
bool bankOpActivate(ReaSamplerSession& session, const std::string& bankId);
// Index-only; files never relocate. Returns whether the index actually mutated — a
// COPY collapse changes nothing (no undo point), a MOVE collapse did remove the
// source entry (counts). Persists one undo point only when mutated.
bool bankOpTransfer(ReaSamplerSession& session,
const std::vector<std::string>& sampleIds,
const std::string& srcBankId, const std::string& destBankId,
bool copy);
// Index-only, this-bank scope; never deletes bytes. Persists one undo point when
// anything was removed.
bool bankOpRemove(ReaSamplerSession& session,
const std::vector<std::string>& sampleIds,
const std::string& srcBankId);
// Wraps the session persist in a Begin/End undo block (UNDO_STATE_MISCCFG) so the
// bank op is one Ctrl-Z; on an unsaved/no-active project the block closes empty
// (REAPER discards it). Call ONLY after an effective mutation.
//
// `bumpGeneration = true` for a verb that changes what a live instance would PLAY;
// leave false for a purely organizational verb. The bump happens INSIDE the block,
// before the persist, so the stamped counter rides the same ext-state write.
void persistBankOp(ReaSamplerSession& session, const char* label,
bool bumpGeneration = false);
} // namespace reasampler