From b8390f470cd684cb142d318475b029bf320159ef Mon Sep 17 00:00:00 2001 From: Klaus Basan Date: Sun, 15 Jun 2014 19:24:58 +0200 Subject: [PATCH] refs #267, extended ICAO class --- src/blackmisc/avaircrafticao.cpp | 11 +++++++++++ src/blackmisc/avaircrafticao.h | 14 +++++++++++++- 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/src/blackmisc/avaircrafticao.cpp b/src/blackmisc/avaircrafticao.cpp index 40a356fb6..df7992106 100644 --- a/src/blackmisc/avaircrafticao.cpp +++ b/src/blackmisc/avaircrafticao.cpp @@ -89,6 +89,17 @@ namespace BlackMisc return TupleConverter::toTuple(*this) == TupleConverter::toTuple(other); } + bool CAircraftIcao::matchesWildcardIcao(const CAircraftIcao &otherIcao) const + { + if ((*this) == otherIcao) return true; + if (otherIcao.hasAircraftDesignator() && otherIcao.getAircraftDesignator() != this->getAircraftDesignator()) return false; + if (otherIcao.hasAirlineDesignator() && otherIcao.getAirlineDesignator() != this->getAirlineDesignator()) return false; + if (otherIcao.hasAircraftCombinedType() && otherIcao.getAircraftCombinedType() != this->getAircraftCombinedType()) return false; + if (otherIcao.hasLivery() && otherIcao.getLivery() != this->getLivery()) return false; + if (otherIcao.hasAircraftColor() && otherIcao.getAircraftColor() != this->getAircraftColor()) return false; + return true; + } + /* * Unequal? */ diff --git a/src/blackmisc/avaircrafticao.h b/src/blackmisc/avaircrafticao.h index 1cd390cf2..de2bbe520 100644 --- a/src/blackmisc/avaircrafticao.h +++ b/src/blackmisc/avaircrafticao.h @@ -25,9 +25,18 @@ namespace BlackMisc //! Default constructor. CAircraftIcao() {} - //! Default constructor. + //! Constructor. explicit CAircraftIcao(const QString &icao) : m_aircraftDesignator(icao.trimmed().toUpper()) {} + /*! + * Constructor. + * \param icao "B737" + * \param airline "DLH" + */ + CAircraftIcao(const QString &icao, const QString &airline) + : m_aircraftDesignator(icao.trimmed().toUpper()), m_airlineDesignator(airline.trimmed().toUpper()) + {} + /*! * Constructor. * \param icao "B737" @@ -113,6 +122,9 @@ namespace BlackMisc //! Equal operator == bool operator ==(const CAircraftIcao &other) const; + //! Matches wildcard icao object + bool matchesWildcardIcao(const CAircraftIcao &otherIcao) const; + //! Unequal operator != bool operator !=(const CAircraftIcao &other) const;