27 using SlotNo = std::uint_fast8_t;
29 friend auto operator<=> (
const PluginSlot &lhs,
const PluginSlot &rhs)
31 if (lhs.type_ != rhs.type_)
32 return lhs.type_ <=> rhs.type_;
34 return lhs.slot_ <=> rhs.slot_;
38 friend bool operator== (
const PluginSlot &lhs,
const PluginSlot &rhs)
40 return (lhs <=> rhs) == 0;
44 PluginSlot () =
default;
50 : type_ (type), slot_ (slot)
57 explicit PluginSlot (PluginSlotType type) : type_ (type) { }
59 bool has_slot_index ()
const {
return slot_.has_value (); }
61 auto get_slot_with_index ()
const
63 if (!has_slot_index ())
65 throw std::invalid_argument (
"Slot has no index");
67 return std::make_pair (type_, slot_.value ());
69 auto get_slot_type_only ()
const
71 if (slot_.has_value ())
73 throw std::invalid_argument (
"Slot has index");
78 PluginSlot get_slot_after_n (PluginSlot::SlotNo n)
const
80 if (!slot_.has_value ())
82 throw std::invalid_argument (
"Slot has no index");
84 return PluginSlot (type_, slot_.value () + n);
87 size_t get_hash ()
const;
89 bool is_modulator ()
const {
return type_ == PluginSlotType::Modulator; }
96 if (type_ == PluginSlotType::Invalid)
99 return (type_ == PluginSlotType::Instrument && !slot_.has_value ())
100 || (type_ != PluginSlotType::Instrument && slot_.has_value ());
103 NLOHMANN_DEFINE_TYPE_INTRUSIVE (
PluginSlot, type_, slot_)
106 PluginSlotType type_{ PluginSlotType::Invalid };
107 std::optional<SlotNo> slot_;