diff --git a/src/blackmisc/aviation/modulator.cpp b/src/blackmisc/aviation/modulator.cpp index 7e0eee279..ad70e1a68 100644 --- a/src/blackmisc/aviation/modulator.cpp +++ b/src/blackmisc/aviation/modulator.cpp @@ -8,14 +8,14 @@ */ #include "blackmisc/aviation/modulator.h" +#include "blackmisc/aviation/comsystem.h" +#include "blackmisc/aviation/navsystem.h" +#include "blackmisc/aviation/adfsystem.h" #include "blackmisc/math/mathutils.h" #include "blackmisc/pq/units.h" #include "blackmisc/propertyindex.h" #include "blackmisc/variant.h" -#include "blackmisc/aviation/comsystem.h" -#include "blackmisc/aviation/navsystem.h" -#include "blackmisc/aviation/adfsystem.h" - +#include "blackmisc/comparefunctions.h" #include using BlackMisc::PhysicalQuantities::CFrequency; @@ -155,6 +155,30 @@ namespace BlackMisc } } + template + int CModulator::comparePropertyByIndex(const CPropertyIndex &index, const AVIO &compareValue) const + { + if (index.isMyself()) { return this->m_frequencyActive.comparePropertyByIndex(index.copyFrontRemoved(), compareValue.m_frequencyActive); } + const ColumnIndex i = index.frontCasted(); + switch (i) + { + case IndexActiveFrequency: + return this->m_frequencyActive.comparePropertyByIndex(index.copyFrontRemoved(), compareValue.m_frequencyActive); + case IndexStandbyFrequency: + return this->m_frequencyStandby.comparePropertyByIndex(index.copyFrontRemoved(), compareValue.m_frequencyStandby); + case IndexEnabled: + return Compare::compare(this->isEnabled(), compareValue.isEnabled()); + case IndexInputVolume: + return Compare::compare(this->getVolumeInput(), compareValue.getVolumeInput()); + case IndexOutputVolume: + return Compare::compare(this->getVolumeOutput(), compareValue.getVolumeOutput()); + default: + break; + } + Q_ASSERT_X(false, Q_FUNC_INFO, "Compare failed"); + return 0; + } + template CModulator::CModulator() : m_name("default") {} @@ -265,19 +289,7 @@ namespace BlackMisc return f; } - template - AVIO const *CModulator::derived() const - { - return static_cast(this); - } - - template - AVIO *CModulator::derived() - { - return static_cast(this); - } - - // see here for the reason of thess forward instantiations + // see here for the reason of the forward instantiations // https://isocpp.org/wiki/faq/templates#separate-template-fn-defn-from-decl //! \cond PRIVATE template class BLACKMISC_EXPORT_DEFINE_TEMPLATE CModulator; diff --git a/src/blackmisc/aviation/modulator.h b/src/blackmisc/aviation/modulator.h index 3a1a6d17d..1e59c7e50 100644 --- a/src/blackmisc/aviation/modulator.h +++ b/src/blackmisc/aviation/modulator.h @@ -81,6 +81,9 @@ namespace BlackMisc //! \copydoc BlackMisc::Mixin::Index::setPropertyByIndex void setPropertyByIndex(const BlackMisc::CPropertyIndex &index, const CVariant &variant); + //! Compare by property index + int comparePropertyByIndex(const BlackMisc::CPropertyIndex &index, const AVIO &compareValue) const; + //! \copydoc BlackMisc::Mixin::String::toQString QString convertToQString(bool i18n = false) const; @@ -142,10 +145,16 @@ namespace BlackMisc bool m_enabled = true; //!< is enabled, used e.g. for mute etc. //! Easy access to derived class (CRTP template parameter) - AVIO const *derived() const; + AVIO const *derived() const + { + return static_cast(this); + } //! Easy access to derived class (CRTP template parameter) - AVIO *derived(); + AVIO *derived() + { + return static_cast(this); + } BLACK_METACLASS( CModulator, diff --git a/src/blackmisc/simulation/simulatedaircraft.cpp b/src/blackmisc/simulation/simulatedaircraft.cpp index fb01f3ef7..f80e6ca2c 100644 --- a/src/blackmisc/simulation/simulatedaircraft.cpp +++ b/src/blackmisc/simulation/simulatedaircraft.cpp @@ -420,9 +420,9 @@ namespace BlackMisc case IndexRelativeDistance: return this->m_relativeDistance.comparePropertyByIndex(index.copyFrontRemoved(), compareValue.getRelativeDistance()); case IndexCom1System: - return m_com1system.getFrequencyActive().comparePropertyByIndex(CPropertyIndex(), compareValue.getCom1System().getFrequencyActive()); + return this->m_com1system.comparePropertyByIndex(index.copyFrontRemoved(), compareValue.getCom1System()); case IndexCom2System: - return m_com2system.getFrequencyActive().comparePropertyByIndex(CPropertyIndex(), compareValue.getCom2System().getFrequencyActive()); + return this->m_com2system.comparePropertyByIndex(index.copyFrontRemoved(), compareValue.getCom2System()); case IndexTransponder: return Compare::compare(m_transponder.getTransponderCode(), compareValue.getTransponder().getTransponderCode()); case IndexLivery: