mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-31 21:15:33 +08:00
refs #893, Modulator added compareByPropertyIndex
This commit is contained in:
committed by
Mathew Sutcliffe
parent
f8b2e4f23f
commit
a68f9db2ec
@@ -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 <QtGlobal>
|
||||
|
||||
using BlackMisc::PhysicalQuantities::CFrequency;
|
||||
@@ -155,6 +155,30 @@ namespace BlackMisc
|
||||
}
|
||||
}
|
||||
|
||||
template <class AVIO>
|
||||
int CModulator<AVIO>::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<ColumnIndex>();
|
||||
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 <class AVIO>
|
||||
CModulator<AVIO>::CModulator() :
|
||||
m_name("default") {}
|
||||
@@ -265,19 +289,7 @@ namespace BlackMisc
|
||||
return f;
|
||||
}
|
||||
|
||||
template <class AVIO>
|
||||
AVIO const *CModulator<AVIO>::derived() const
|
||||
{
|
||||
return static_cast<AVIO const *>(this);
|
||||
}
|
||||
|
||||
template <class AVIO>
|
||||
AVIO *CModulator<AVIO>::derived()
|
||||
{
|
||||
return static_cast<AVIO *>(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<CComSystem>;
|
||||
|
||||
@@ -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<AVIO const *>(this);
|
||||
}
|
||||
|
||||
//! Easy access to derived class (CRTP template parameter)
|
||||
AVIO *derived();
|
||||
AVIO *derived()
|
||||
{
|
||||
return static_cast<AVIO *>(this);
|
||||
}
|
||||
|
||||
BLACK_METACLASS(
|
||||
CModulator,
|
||||
|
||||
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user