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:
committed by
GitHub
parent
6c846684cd
commit
5c0db46a60
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user