Streamline instrument flags (#7227)

## Instrument flags as a property of an instrument
The instruments flags (single streamed, MIDI based, not bendable) are properties of an instrument that do not change over time. Therefore the flags are made a property of the instrument which is initialized at construction time.

Adjust the constructors of all instruments which overrode the `flags` method to pass their flags into the `Instrument` constructor.

## Add helper methods for flags
Add helper methods for the flags. This makes the code more concise and readable and clients do not need to know the technical details on how to evaluate a flag.

## Remove the flags methods
Remove the flags methods to make it an implementation detail on how the flags are managed.
This commit is contained in:
Michael Gregorius
2024-04-27 17:45:55 +02:00
committed by GitHub
parent 6c846684cd
commit 5c0db46a60
26 changed files with 43 additions and 76 deletions

View File

@@ -62,7 +62,8 @@ public:
Instrument(InstrumentTrack * _instrument_track,
const Descriptor * _descriptor,
const Descriptor::SubPluginFeatures::Key * key = nullptr);
const Descriptor::SubPluginFeatures::Key * key = nullptr,
Flags flags = Flag::NoFlags);
~Instrument() override = default;
// --------------------------------------------------------------------
@@ -114,9 +115,19 @@ public:
sample_rate_t getSampleRate() const;
virtual Flags flags() const
bool isSingleStreamed() const
{
return Flag::NoFlags;
return m_flags.testFlag(Instrument::Flag::IsSingleStreamed);
}
bool isMidiBased() const
{
return m_flags.testFlag(Instrument::Flag::IsMidiBased);
}
bool isBendable() const
{
return !m_flags.testFlag(Instrument::Flag::IsNotBendable);
}
// sub-classes can re-implement this for receiving all incoming
@@ -161,8 +172,8 @@ protected:
private:
InstrumentTrack * m_instrumentTrack;
} ;
Flags m_flags;
};
LMMS_DECLARE_OPERATORS_FOR_FLAGS(Instrument::Flag)