diff --git a/src/blackmisc/avaltitude.cpp b/src/blackmisc/avaltitude.cpp index 3b20ad72d..604a654cd 100644 --- a/src/blackmisc/avaltitude.cpp +++ b/src/blackmisc/avaltitude.cpp @@ -16,38 +16,37 @@ namespace Aviation /* * Own implementation for streaming */ -QString CAltitude::convertToQString(bool /** i18n **/) const +QString CAltitude::convertToQString(bool /* i18n */) const { - QString s = CLength::convertToQString(); + QString s = this->CLength::convertToQString(); return s.append(this->m_msl ? " MSL" : " AGL"); } /* * Assigment */ -CAltitude &CAltitude::operator =(const CAltitude &otherAltitude) +CAltitude &CAltitude::operator =(const CAltitude &other) { - // Check for self-assignment! - if (this == &otherAltitude) return *this; - CLength::operator = (otherAltitude); - this->m_msl = otherAltitude.m_msl; - return (*this); + if (this == &other) return *this; + CLength::operator = (other); + this->m_msl = other.m_msl; + return *this; } /* * Equal? */ -bool CAltitude::operator ==(const CAltitude &otherAltitude) +bool CAltitude::operator ==(const CAltitude &other) { - return otherAltitude.m_msl == this->m_msl && CLength::operator ==(otherAltitude); + return other.m_msl == this->m_msl && this->CLength::operator ==(other); } /* * Unequal? */ -bool CAltitude::operator !=(const CAltitude &otherAltitude) +bool CAltitude::operator !=(const CAltitude &other) { - return !((*this) == otherAltitude); + return !((*this) == other); } /* diff --git a/src/blackmisc/avaltitude.h b/src/blackmisc/avaltitude.h index 3ddc1f8f3..43379510e 100644 --- a/src/blackmisc/avaltitude.h +++ b/src/blackmisc/avaltitude.h @@ -33,8 +33,9 @@ protected: * \brief Stream to DBus << * \param argument */ - virtual void marshallToDbus(QDBusArgument &argument) const { - CLength::marshallToDbus(argument); + virtual void marshallToDbus(QDBusArgument &argument) const + { + this->CLength::marshallToDbus(argument); argument << this->m_msl; } @@ -42,13 +43,13 @@ protected: * \brief Stream from DBus >> * \param argument */ - virtual void unmarshallFromDbus(const QDBusArgument &argument) { - CLength::unmarshallFromDbus(argument); + virtual void unmarshallFromDbus(const QDBusArgument &argument) + { + this->CLength::unmarshallFromDbus(argument); argument >> this->m_msl; } public: - /*! * \brief Default constructor: 0 Altitude true */ @@ -75,37 +76,34 @@ public: * \param altitude * \param msl */ - CAltitude(BlackMisc::PhysicalQuantities::CLength altitude, bool msl) : BlackMisc::PhysicalQuantities::CLength(), m_msl(msl) - { - BlackMisc::PhysicalQuantities::CLength::operator =(altitude); - } + CAltitude(BlackMisc::PhysicalQuantities::CLength altitude, bool msl) : BlackMisc::PhysicalQuantities::CLength(altitude), m_msl(msl) {} /*! * \brief Copy constructor - * \param otherAltitude + * \param other */ - CAltitude(const CAltitude &otherAltitude) : BlackMisc::PhysicalQuantities::CLength(otherAltitude), m_msl(otherAltitude.m_msl) {} + CAltitude(const CAltitude &other) : BlackMisc::PhysicalQuantities::CLength(other), m_msl(other.m_msl) {} /*! * \brief Assignment operator = - * \param otherAltitude + * \param other * @return */ - CAltitude &operator =(const CAltitude &otherAltitude); + CAltitude &operator =(const CAltitude &other); /*! * \brief Equal operator == - * \param otherAltitude + * \param other * @return */ - bool operator ==(const CAltitude &otherAltitude); + bool operator ==(const CAltitude &other); /*! * \brief Unequal operator == - * \param otherAltitude + * \param other * @return */ - bool operator !=(const CAltitude &otherAltitude); + bool operator !=(const CAltitude &other); /*! * \brief AGL Above ground level? @@ -129,11 +127,11 @@ public: * \brief Register metadata */ static void registerMetadata(); - }; } // namespace } // namespace + Q_DECLARE_METATYPE(BlackMisc::Aviation::CAltitude) #endif // guard diff --git a/src/blackmisc/avheading.cpp b/src/blackmisc/avheading.cpp index 1116b13f8..b1b4dd430 100644 --- a/src/blackmisc/avheading.cpp +++ b/src/blackmisc/avheading.cpp @@ -25,29 +25,28 @@ QString CHeading::convertToQString(bool i18n) const /* * Assigment */ -CHeading& CHeading::operator =(const CHeading &otherHeading) +CHeading& CHeading::operator =(const CHeading &other) { - // Check for self-assignment! - if (this == &otherHeading) return *this; - CAngle::operator = (otherHeading); - this->m_magnetic = otherHeading.m_magnetic; - return (*this); + if (this == &other) return *this; + this->CAngle::operator = (other); + this->m_magnetic = other.m_magnetic; + return *this; } /* * Equal? */ -bool CHeading::operator ==(const CHeading &otherHeading) +bool CHeading::operator ==(const CHeading &other) { - return otherHeading.m_magnetic == this->m_magnetic && CAngle::operator ==(otherHeading); + return other.m_magnetic == this->m_magnetic && this->CAngle::operator ==(other); } /* * Unequal? */ -bool CHeading::operator !=(const CHeading &otherHeading) +bool CHeading::operator !=(const CHeading &other) { - return !((*this) == otherHeading); + return !((*this) == other); } /*! diff --git a/src/blackmisc/avheading.h b/src/blackmisc/avheading.h index 224edd116..a75dd1c56 100644 --- a/src/blackmisc/avheading.h +++ b/src/blackmisc/avheading.h @@ -11,6 +11,7 @@ namespace BlackMisc { namespace Aviation { + /*! * \brief Heading as used in aviation, can be true or magnetic heading * \remarks Intentionally allowing +/- CAngle , and >= / <= CAngle. @@ -32,8 +33,9 @@ protected: * \brief Stream to DBus << * \param argument */ - virtual void marshallToDbus(QDBusArgument &argument) const { - CAngle::marshallToDbus(argument); + virtual void marshallToDbus(QDBusArgument &argument) const + { + this->CAngle::marshallToDbus(argument); argument << this->m_magnetic; } @@ -41,8 +43,9 @@ protected: * \brief Stream from DBus >> * \param argument */ - virtual void unmarshallFromDbus(const QDBusArgument &argument) { - CAngle::unmarshallFromDbus(argument); + virtual void unmarshallFromDbus(const QDBusArgument &argument) + { + this->CAngle::unmarshallFromDbus(argument); argument >> this->m_magnetic; } @@ -58,8 +61,8 @@ public: * \param magnetic * \param unit */ - CHeading(double value, bool magnetic, const BlackMisc::PhysicalQuantities::CAngleUnit &unit) : CAngle(value, unit), m_magnetic(magnetic) {} + /*! * \brief Constructor * \param value @@ -73,37 +76,34 @@ public: * \param heading * \param magnetic */ - CHeading(CAngle heading, bool magnetic) : CAngle(), m_magnetic(magnetic) - { - CAngle::operator =(heading); - } + CHeading(CAngle heading, bool magnetic) : CAngle(heading), m_magnetic(magnetic) {} /*! * \brief Copy constructor - * \param otherHeading + * \param other */ - CHeading(const CHeading &otherHeading) : CAngle(otherHeading), m_magnetic(otherHeading.m_magnetic) {} + CHeading(const CHeading &other) : CAngle(other), m_magnetic(other.m_magnetic) {} /*! * \brief Assignment operator = - * \param otherHeading + * \param other * @return */ - CHeading &operator =(const CHeading &otherHeading); + CHeading &operator =(const CHeading &other); /*! * \brief Equal operator == - * \param otherHeading + * \param other * @return */ - bool operator ==(const CHeading &otherHeading); + bool operator ==(const CHeading &other); /*! * \brief Unequal operator == - * \param otherHeading + * \param other * @return */ - bool operator !=(const CHeading &otherHeading); + bool operator !=(const CHeading &other); /*! * \brief Magnetic heading? @@ -118,14 +118,14 @@ public: bool isTrueHeading() const { return !this->m_magnetic; } /*! - * \brief Switch heading unit + * \brief Switch angle unit * \param newUnit * \return */ CHeading &switchUnit(const BlackMisc::PhysicalQuantities::CAngleUnit &newUnit) { - CAngle::switchUnit(newUnit); - return (*this); + this->CAngle::switchUnit(newUnit); + return *this; } /*! diff --git a/src/blackmisc/avioadfsystem.h b/src/blackmisc/avioadfsystem.h index 5cff56b5d..e74914ee5 100644 --- a/src/blackmisc/avioadfsystem.h +++ b/src/blackmisc/avioadfsystem.h @@ -29,6 +29,7 @@ private: double fr = f.valueRounded(PhysicalQuantities::CFrequencyUnit::kHz(), this->m_digits); return fr >= 190.0 && fr <= 1750.0; } + /*! * \brief Constructor * \param validate @@ -53,8 +54,8 @@ protected: { if (this->isDefaultValue()) return true; // special case return - (this->isValidFrequency(this->getFrequencyActive()) && - (this->isValidFrequency(this->getFrequencyStandby()))); + this->isValidFrequency(this->getFrequencyActive()) && + this->isValidFrequency(this->getFrequencyStandby()); } /*! @@ -73,16 +74,19 @@ protected: if (!valid) throw std::range_error("Illegal values in CAdfSystem::validate"); return true; } + public: /*! * Default constructor */ CAdfSystem() : CModulator() {} + /*! * \brief Copy constructor - * \param otherSystem + * \param other */ - CAdfSystem(const CAdfSystem &otherSystem) : CModulator(otherSystem) {} + CAdfSystem(const CAdfSystem &other) : CModulator(other) {} + /*! * \brief Constructor * \param name @@ -95,24 +99,27 @@ public: { this->validate(true); } + /*! * \brief Set active frequency * \param frequencyKHz */ void setFrequencyActiveKHz(double frequencyKHz) { - CModulator::setFrequencyActiveKHz(frequencyKHz); + this->CModulator::setFrequencyActiveKHz(frequencyKHz); this->validate(true); } + /*! * \brief Set standby frequency * \param frequencyKHz */ void setFrequencyStandbyKHz(double frequencyKHz) { - CModulator::setFrequencyStandbyKHz(frequencyKHz); + this->CModulator::setFrequencyStandbyKHz(frequencyKHz); this->validate(true); } + /*! * \brief Assigment operator = * \param otherSystem @@ -120,9 +127,10 @@ public: */ CAdfSystem &operator =(const CAdfSystem &otherSystem) { - CModulator::operator =(otherSystem); - return (*this); + this->CModulator::operator =(otherSystem); + return *this; } + /*! * \brief operator == * \param otherSystem @@ -130,8 +138,9 @@ public: */ bool operator ==(const CAdfSystem &otherSystem) const { - return CModulator::operator ==(otherSystem); + return this->CModulator::operator ==(otherSystem); } + /*! * \brief operator == * \param otherSystem @@ -139,42 +148,43 @@ public: */ bool operator !=(const CAdfSystem &otherSystem) const { - return CModulator::operator !=(otherSystem); + return this->CModulator::operator !=(otherSystem); } /*! * Try to get a ADF unit with given name and frequency. Returns true in case an object * has been sucessfully created, otherwise returns a default object and false. - * \param adfSystem + * \param[out] o_adfSystem * \param name * \param activeFrequencyKHz * \param standbyFrequencyKHz * \return */ - static bool tryGetAdfSystem(CAdfSystem &adfSystem, const QString &name, double activeFrequencyKHz, double standbyFrequencyKHz = -1) + static bool tryGetAdfSystem(CAdfSystem &o_adfSystem, const QString &name, double activeFrequencyKHz, double standbyFrequencyKHz = -1) { - adfSystem = CAdfSystem(false, name, PhysicalQuantities::CFrequency(activeFrequencyKHz, PhysicalQuantities::CFrequencyUnit::MHz()), PhysicalQuantities::CFrequency(standbyFrequencyKHz < 0 ? activeFrequencyKHz : standbyFrequencyKHz, PhysicalQuantities::CFrequencyUnit::MHz())); + o_adfSystem = CAdfSystem(false, name, PhysicalQuantities::CFrequency(activeFrequencyKHz, PhysicalQuantities::CFrequencyUnit::MHz()), PhysicalQuantities::CFrequency(standbyFrequencyKHz < 0 ? activeFrequencyKHz : standbyFrequencyKHz, PhysicalQuantities::CFrequencyUnit::MHz())); bool s; - if (!(s = adfSystem.validate(false))) adfSystem = CAdfSystem(); // reset to default + if (!(s = o_adfSystem.validate(false))) o_adfSystem = CAdfSystem(); // reset to default return s; } /*! * Try to get a ADF unit with given name and frequency. Returns true in case an object * has been sucessfully created, otherwise returns a default object. - * \param adfSystem + * \param[out] o_adfSystem * \param name * \param activeFrequency * \param standbyFrequency * \return */ - static bool tryGetAdfSystem(CAdfSystem &adfSystem, const QString &name, PhysicalQuantities::CFrequency activeFrequency, PhysicalQuantities::CFrequency standbyFrequency = CModulator::FrequencyNotSet()) + static bool tryGetAdfSystem(CAdfSystem &o_adfSystem, const QString &name, PhysicalQuantities::CFrequency activeFrequency, PhysicalQuantities::CFrequency standbyFrequency = CModulator::FrequencyNotSet()) { - adfSystem = CAdfSystem(false, name, activeFrequency, standbyFrequency); + o_adfSystem = CAdfSystem(false, name, activeFrequency, standbyFrequency); bool s; - if (!(s = adfSystem.validate(false))) adfSystem = CAdfSystem(); // reset to default + if (!(s = o_adfSystem.validate(false))) o_adfSystem = CAdfSystem(); // reset to default return s; } + /*! * \brief ADF1 unit * \param activeFrequencyKHz @@ -185,6 +195,7 @@ public: { return CAdfSystem(CModulator::NameCom1(), PhysicalQuantities::CFrequency(activeFrequencyKHz, PhysicalQuantities::CFrequencyUnit::MHz()), PhysicalQuantities::CFrequency(standbyFrequencyKHz < 0 ? activeFrequencyKHz : standbyFrequencyKHz, PhysicalQuantities::CFrequencyUnit::MHz())); } + /*! * \brief ADF1 unit * \param activeFrequency @@ -195,28 +206,31 @@ public: { return CAdfSystem(CModulator::NameCom1(), activeFrequency, standbyFrequency == CModulator::FrequencyNotSet() ? activeFrequency : standbyFrequency); } + /*! * \brief Try to get ADF unit - * \param adfSystem + * \param[out] o_adfSystem * \param activeFrequencyKHz * \param standbyFrequencyKHz * \return */ - static bool tryGetAdf1Unit(CAdfSystem &adfSystem, double activeFrequencyKHz, double standbyFrequencyKHz = -1) + static bool tryGetAdf1Unit(CAdfSystem &o_adfSystem, double activeFrequencyKHz, double standbyFrequencyKHz = -1) { - return CAdfSystem::tryGetAdfSystem(adfSystem, CModulator::NameCom1(), activeFrequencyKHz, standbyFrequencyKHz); + return CAdfSystem::tryGetAdfSystem(o_adfSystem, CModulator::NameCom1(), activeFrequencyKHz, standbyFrequencyKHz); } + /*! * \brief Try to get ADF unit - * \param adfSystem + * \param[out] o_adfSystem * \param activeFrequency * \param standbyFrequency * \return */ - static bool tryGetAdf1Unit(CAdfSystem &adfSystem, PhysicalQuantities::CFrequency activeFrequency, PhysicalQuantities::CFrequency standbyFrequency = CModulator::FrequencyNotSet()) + static bool tryGetAdf1Unit(CAdfSystem &o_adfSystem, PhysicalQuantities::CFrequency activeFrequency, PhysicalQuantities::CFrequency standbyFrequency = CModulator::FrequencyNotSet()) { - return CAdfSystem::tryGetAdfSystem(adfSystem, CModulator::NameCom1(), activeFrequency, standbyFrequency); + return CAdfSystem::tryGetAdfSystem(o_adfSystem, CModulator::NameCom1(), activeFrequency, standbyFrequency); } + /*! * \brief ADF2 unit * \param activeFrequencyKHz @@ -227,6 +241,7 @@ public: { return CAdfSystem(CModulator::NameCom2(), PhysicalQuantities::CFrequency(activeFrequencyKHz, PhysicalQuantities::CFrequencyUnit::MHz()), PhysicalQuantities::CFrequency(standbyFrequencyKHz < 0 ? activeFrequencyKHz : standbyFrequencyKHz, PhysicalQuantities::CFrequencyUnit::MHz())); } + /*! * \brief ADF2 unit * \param activeFrequency @@ -237,32 +252,35 @@ public: { return CAdfSystem(CModulator::NameCom2(), activeFrequency, standbyFrequency == CModulator::FrequencyNotSet() ? activeFrequency : standbyFrequency); } + /*! * \brief Try to get ADF unit - * \param adfSystem + * \param[out] o_adfSystem * \param activeFrequencyKHz * \param standbyFrequencyKHz * \return */ - static bool tryGetAdf2System(CAdfSystem &adfSystem, double activeFrequencyKHz, double standbyFrequencyKHz = -1) + static bool tryGetAdf2System(CAdfSystem &o_adfSystem, double activeFrequencyKHz, double standbyFrequencyKHz = -1) { - return CAdfSystem::tryGetAdfSystem(adfSystem, CModulator::NameCom2(), activeFrequencyKHz, standbyFrequencyKHz); + return CAdfSystem::tryGetAdfSystem(o_adfSystem, CModulator::NameCom2(), activeFrequencyKHz, standbyFrequencyKHz); } + /*! * \brief Try to get ADF unit - * \param adfSystem + * \param[out] o_adfSystem * \param activeFrequency * \param standbyFrequency * \return */ - static bool tryGetAdf2System(CAdfSystem &adfSystem, PhysicalQuantities::CFrequency activeFrequency, PhysicalQuantities::CFrequency standbyFrequency = CModulator::FrequencyNotSet()) + static bool tryGetAdf2System(CAdfSystem &o_adfSystem, PhysicalQuantities::CFrequency activeFrequency, PhysicalQuantities::CFrequency standbyFrequency = CModulator::FrequencyNotSet()) { - return CAdfSystem::tryGetAdfSystem(adfSystem, CModulator::NameCom2(), activeFrequency, standbyFrequency); + return CAdfSystem::tryGetAdfSystem(o_adfSystem, CModulator::NameCom2(), activeFrequency, standbyFrequency); } }; } // namespace } // namespace + Q_DECLARE_METATYPE(BlackMisc::Aviation::CAdfSystem) #endif // BLACKMISC_AVIOADFSYSTEM_H diff --git a/src/blackmisc/aviobase.h b/src/blackmisc/aviobase.h index f99c0b583..36f4d335c 100644 --- a/src/blackmisc/aviobase.h +++ b/src/blackmisc/aviobase.h @@ -21,15 +21,13 @@ namespace Aviation */ class CAvionicsBase : public BlackMisc::CBaseStreamStringifier { - protected: - QString m_name; //!< name of the unit /*! * \brief Constructor */ - CAvionicsBase(const QString &name) : CBaseStreamStringifier(), m_name(name) {} + CAvionicsBase(const QString &name) : m_name(name) {} /*! * \brief Are the set values valid / in range @@ -51,20 +49,21 @@ protected: /*! * \brief operator == - * \param otherSystem + * \param other * \return */ - bool operator ==(const CAvionicsBase &otherSystem) const + bool operator ==(const CAvionicsBase &other) const { - if (this == &otherSystem) return true; - return this->m_name == otherSystem.m_name; + if (this == &other) return true; + return this->m_name == other.m_name; } /*! * \brief Stream to DBus << * \param argument */ - virtual void marshallToDbus(QDBusArgument &argument) const { + virtual void marshallToDbus(QDBusArgument &argument) const + { argument << this->m_name; } @@ -72,7 +71,8 @@ protected: * \brief Stream from DBus >> * \param argument */ - virtual void unmarshallFromDbus(const QDBusArgument &argument) { + virtual void unmarshallFromDbus(const QDBusArgument &argument) + { argument >> this->m_name; } @@ -91,6 +91,7 @@ public: return this->m_name; } }; + } // namespace } // namespace diff --git a/src/blackmisc/aviocomsystem.h b/src/blackmisc/aviocomsystem.h index 9faac94ac..46e4ff6ed 100644 --- a/src/blackmisc/aviocomsystem.h +++ b/src/blackmisc/aviocomsystem.h @@ -24,7 +24,8 @@ private: * \param f * \return */ - bool isValidCivilAviationFrequency(BlackMisc::PhysicalQuantities::CFrequency f) const { + bool isValidCivilAviationFrequency(BlackMisc::PhysicalQuantities::CFrequency f) const + { double fr = f.valueRounded(BlackMisc::PhysicalQuantities::CFrequencyUnit::MHz(), this->m_digits); return fr >= 118.0 && fr <= 136.975; } @@ -34,7 +35,8 @@ private: * \param f * \return */ - bool isValidMilitaryFrequency(BlackMisc::PhysicalQuantities::CFrequency f) const { + bool isValidMilitaryFrequency(BlackMisc::PhysicalQuantities::CFrequency f) const + { double fr = f.valueRounded(BlackMisc::PhysicalQuantities::CFrequencyUnit::MHz(), this->m_digits); return fr >= 220.0 && fr <= 399.95; } @@ -49,7 +51,8 @@ private: * */ CComSystem(bool validate, const QString &name, const BlackMisc::PhysicalQuantities::CFrequency &activeFrequency, const BlackMisc::PhysicalQuantities::CFrequency &standbyFrequency, int digits = 3): - CModulator(name, activeFrequency, standbyFrequency, digits) { + CModulator(name, activeFrequency, standbyFrequency, digits) + { this->validate(validate); } @@ -58,7 +61,8 @@ protected: * \brief Are the set values valid / in range? * \return */ - bool validValues() const { + bool validValues() const + { if (this->isDefaultValue()) return true; // special case return (this->isValidCivilAviationFrequency(this->getFrequencyActive()) || @@ -71,10 +75,11 @@ protected: * \brief Validate values by assert and exception * \param strict * \throws std::range_error - * \remarks Cannot be virtualsince already used in constructor + * \remarks Cannot be virtual because used in constructor * \return */ - bool validate(bool strict = true) const { + bool validate(bool strict = true) const + { if (this->isDefaultValue()) return true; bool valid = this->validValues(); if (!strict) return valid; @@ -91,9 +96,9 @@ public: /*! * \brief Copy constructor - * \param otherSystem + * \param other */ - CComSystem(const CComSystem &otherSystem) : CModulator(otherSystem) {} + CComSystem(const CComSystem &other) : CModulator(other) {} /*! * \brief Constructor @@ -103,7 +108,8 @@ public: * \param digits */ CComSystem(const QString &name, const BlackMisc::PhysicalQuantities::CFrequency &activeFrequency, const BlackMisc::PhysicalQuantities::CFrequency &standbyFrequency = CModulator::FrequencyNotSet(), int digits = 3): - CModulator(name, activeFrequency, standbyFrequency == CModulator::FrequencyNotSet() ? activeFrequency : standbyFrequency, digits) { + CModulator(name, activeFrequency, standbyFrequency == CModulator::FrequencyNotSet() ? activeFrequency : standbyFrequency, digits) + { this->validate(true); } @@ -111,8 +117,9 @@ public: * \brief Set active frequency * \param frequencyMHz */ - void setFrequencyActiveMHz(double frequencyMHz) { - CModulator::setFrequencyActiveMHz(frequencyMHz); + void setFrequencyActiveMHz(double frequencyMHz) + { + this->CModulator::setFrequencyActiveMHz(frequencyMHz); this->validate(true); } @@ -120,15 +127,17 @@ public: * \brief Set standby frequency * \param frequencyMHz */ - void setFrequencyStandbyMHz(double frequencyMHz) { - CModulator::setFrequencyStandbyMHz(frequencyMHz); + void setFrequencyStandbyMHz(double frequencyMHz) + { + this->CModulator::setFrequencyStandbyMHz(frequencyMHz); this->validate(true); } /*! * \brief Set UNICOM frequency as active */ - void setActiveUnicom() { + void setActiveUnicom() + { this->toggleActiveStandby(); this->setFrequencyActive(BlackMisc::PhysicalQuantities::CPhysicalQuantitiesConstants::FrequencyUnicom()); } @@ -136,67 +145,74 @@ public: /*! * \brief Set International Air Distress 121.5MHz */ - void setActiveInternationalAirDistress() { + void setActiveInternationalAirDistress() + { this->toggleActiveStandby(); this->setFrequencyActive(BlackMisc::PhysicalQuantities::CPhysicalQuantitiesConstants::FrequencyInternationalAirDistress()); } /*! * \brief Assigment operator = - * \param otherSystem + * \param other * \return */ - CComSystem& operator =(const CComSystem &otherSystem) { - CModulator::operator =(otherSystem); - return (*this); + CComSystem& operator =(const CComSystem &other) + { + this->CModulator::operator =(other); + return *this; } /*! * \brief operator == - * \param otherSystem + * \param other * \return */ - bool operator ==(const CComSystem &otherSystem) const { - return CModulator::operator ==(otherSystem); + bool operator ==(const CComSystem &other) const + { + return this->CModulator::operator ==(other); } + /*! - * \brief operator == - * \param otherSystem + * \brief operator != + * \param other * \return */ - bool operator !=(const CComSystem &otherSystem) const { - return CModulator::operator !=(otherSystem); + bool operator !=(const CComSystem &other) const + { + return this->CModulator::operator !=(other); } /*! * Try to get a COM unit with given name and frequency. Returns true in case an object * has been sucessfully created, otherwise returns a default object. - * \param comSystem + * \param[out] o_comSystem * \param name * \param activeFrequencyMHz * \param standbyFrequencyMHz * \return */ - static bool tryGetComSystem(CComSystem &comSystem, const QString &name, double activeFrequencyMHz, double standbyFrequencyMHz = -1) { - comSystem = CComSystem(false, name, BlackMisc::PhysicalQuantities::CFrequency(activeFrequencyMHz, BlackMisc::PhysicalQuantities::CFrequencyUnit::MHz()), BlackMisc::PhysicalQuantities::CFrequency(standbyFrequencyMHz < 0 ? activeFrequencyMHz : standbyFrequencyMHz, BlackMisc::PhysicalQuantities::CFrequencyUnit::MHz())); + static bool tryGetComSystem(CComSystem &o_comSystem, const QString &name, double activeFrequencyMHz, double standbyFrequencyMHz = -1) + { + o_comSystem = CComSystem(false, name, BlackMisc::PhysicalQuantities::CFrequency(activeFrequencyMHz, BlackMisc::PhysicalQuantities::CFrequencyUnit::MHz()), BlackMisc::PhysicalQuantities::CFrequency(standbyFrequencyMHz < 0 ? activeFrequencyMHz : standbyFrequencyMHz, BlackMisc::PhysicalQuantities::CFrequencyUnit::MHz())); bool s; - if (!(s = comSystem.validate(false))) comSystem = CComSystem(); // reset to default + if (!(s = o_comSystem.validate(false))) o_comSystem = CComSystem(); // reset to default return s; } /*! * Try to get a COM unit with given name and frequency. Returns true in case an object * has been sucessfully created, otherwise returns a default object. - * \param comSystem + * \param[out] o_comSystem * \param name * \param activeFrequency * \param standbyFrequency * \return */ - static bool tryGetComSystem(CComSystem &comSystem, const QString &name, BlackMisc::PhysicalQuantities::CFrequency activeFrequency, BlackMisc::PhysicalQuantities::CFrequency standbyFrequency = CModulator::FrequencyNotSet()) { - comSystem = CComSystem(false, name, activeFrequency, standbyFrequency); + static bool tryGetComSystem(CComSystem &o_comSystem, const QString &name, BlackMisc::PhysicalQuantities::CFrequency activeFrequency, BlackMisc::PhysicalQuantities::CFrequency standbyFrequency = CModulator::FrequencyNotSet()) + { + o_comSystem = CComSystem(false, name, activeFrequency, standbyFrequency); bool s; - if (!(s = comSystem.validate(false))) comSystem = CComSystem(); // reset to default + if (!(s = o_comSystem.validate(false))) o_comSystem = CComSystem(); // reset to default return s; } @@ -206,7 +222,8 @@ public: * \param standbyFrequencyMHz * \return */ - static CComSystem getCom1System(double activeFrequencyMHz, double standbyFrequencyMHz = -1) { + static CComSystem getCom1System(double activeFrequencyMHz, double standbyFrequencyMHz = -1) + { return CComSystem(CModulator::NameCom1(), BlackMisc::PhysicalQuantities::CFrequency(activeFrequencyMHz, BlackMisc::PhysicalQuantities::CFrequencyUnit::MHz()), BlackMisc::PhysicalQuantities::CFrequency(standbyFrequencyMHz < 0 ? activeFrequencyMHz : standbyFrequencyMHz, BlackMisc::PhysicalQuantities::CFrequencyUnit::MHz())); } @@ -216,28 +233,33 @@ public: * \param standbyFrequency * \return */ - static CComSystem getCom1System(BlackMisc::PhysicalQuantities::CFrequency activeFrequency, BlackMisc::PhysicalQuantities::CFrequency standbyFrequency = CModulator::FrequencyNotSet()) { - return CComSystem(CModulator::NameCom1(), activeFrequency, standbyFrequency == CModulator::FrequencyNotSet() ? activeFrequency : standbyFrequency); + static CComSystem getCom1System(BlackMisc::PhysicalQuantities::CFrequency activeFrequency, BlackMisc::PhysicalQuantities::CFrequency standbyFrequency = CModulator::FrequencyNotSet()) + { + return CComSystem(CModulator::NameCom1(), activeFrequency, standbyFrequency == CModulator::FrequencyNotSet() ? activeFrequency : standbyFrequency); } + /*! * \brief Try to get COM unit - * \param comSystem + * \param[out] o_comSystem * \param activeFrequencyMHz * \param standbyFrequencyMHz * \return */ - static bool tryGetCom1Unit(CComSystem &comSystem, double activeFrequencyMHz, double standbyFrequencyMHz = -1) { - return CComSystem::tryGetComSystem(comSystem, CModulator::NameCom1(), activeFrequencyMHz, standbyFrequencyMHz); + static bool tryGetCom1Unit(CComSystem &o_comSystem, double activeFrequencyMHz, double standbyFrequencyMHz = -1) + { + return CComSystem::tryGetComSystem(o_comSystem, CModulator::NameCom1(), activeFrequencyMHz, standbyFrequencyMHz); } + /*! * \brief Try to get COM unit - * \param comSystem + * \param[out] o_comSystem * \param activeFrequency * \param standbyFrequency * \return */ - static bool tryGetCom1Unit(CComSystem &comSystem, BlackMisc::PhysicalQuantities::CFrequency activeFrequency, BlackMisc::PhysicalQuantities::CFrequency standbyFrequency = CModulator::FrequencyNotSet()) { - return CComSystem::tryGetComSystem(comSystem, CModulator::NameCom1(), activeFrequency, standbyFrequency); + static bool tryGetCom1Unit(CComSystem &o_comSystem, BlackMisc::PhysicalQuantities::CFrequency activeFrequency, BlackMisc::PhysicalQuantities::CFrequency standbyFrequency = CModulator::FrequencyNotSet()) + { + return CComSystem::tryGetComSystem(o_comSystem, CModulator::NameCom1(), activeFrequency, standbyFrequency); } /*! @@ -246,7 +268,8 @@ public: * \param standbyFrequencyMHz * \return */ - static CComSystem getCom2System(double activeFrequencyMHz, double standbyFrequencyMHz = -1) { + static CComSystem getCom2System(double activeFrequencyMHz, double standbyFrequencyMHz = -1) + { return CComSystem(CModulator::NameCom2(), BlackMisc::PhysicalQuantities::CFrequency(activeFrequencyMHz, BlackMisc::PhysicalQuantities::CFrequencyUnit::MHz()), BlackMisc::PhysicalQuantities::CFrequency(standbyFrequencyMHz < 0 ? activeFrequencyMHz : standbyFrequencyMHz, BlackMisc::PhysicalQuantities::CFrequencyUnit::MHz())); } @@ -256,30 +279,33 @@ public: * \param standbyFrequency * \return */ - static CComSystem getCom2System(BlackMisc::PhysicalQuantities::CFrequency activeFrequency, BlackMisc::PhysicalQuantities::CFrequency standbyFrequency = CModulator::FrequencyNotSet()) { + static CComSystem getCom2System(BlackMisc::PhysicalQuantities::CFrequency activeFrequency, BlackMisc::PhysicalQuantities::CFrequency standbyFrequency = CModulator::FrequencyNotSet()) + { return CComSystem(CModulator::NameCom2(), activeFrequency, standbyFrequency == CModulator::FrequencyNotSet() ? activeFrequency : standbyFrequency); } /*! * \brief Try to get COM unit - * \param comSystem + * \param[out] o_comSystem * \param activeFrequencyMHz * \param standbyFrequencyMHz * \return */ - static bool tryGetCom2System(CComSystem &comSystem, double activeFrequencyMHz, double standbyFrequencyMHz = -1) { - return CComSystem::tryGetComSystem(comSystem, CModulator::NameCom2(), activeFrequencyMHz, standbyFrequencyMHz); + static bool tryGetCom2System(CComSystem &o_comSystem, double activeFrequencyMHz, double standbyFrequencyMHz = -1) + { + return CComSystem::tryGetComSystem(o_comSystem, CModulator::NameCom2(), activeFrequencyMHz, standbyFrequencyMHz); } /*! * \brief Try to get COM unit - * \param comSystem + * \param[out] o_comSystem * \param activeFrequency * \param standbyFrequency * \return */ - static bool tryGetCom2System(CComSystem &comSystem, BlackMisc::PhysicalQuantities::CFrequency activeFrequency, BlackMisc::PhysicalQuantities::CFrequency standbyFrequency = CModulator::FrequencyNotSet()) { - return CComSystem::tryGetComSystem(comSystem, CModulator::NameCom2(), activeFrequency, standbyFrequency); + static bool tryGetCom2System(CComSystem &o_comSystem, BlackMisc::PhysicalQuantities::CFrequency activeFrequency, BlackMisc::PhysicalQuantities::CFrequency standbyFrequency = CModulator::FrequencyNotSet()) + { + return CComSystem::tryGetComSystem(o_comSystem, CModulator::NameCom2(), activeFrequency, standbyFrequency); } /*! @@ -288,7 +314,8 @@ public: * \param standbyFrequencyMHz * \return */ - static CComSystem getCom3System(double activeFrequencyMHz, double standbyFrequencyMHz = -1) { + static CComSystem getCom3System(double activeFrequencyMHz, double standbyFrequencyMHz = -1) + { return CComSystem(CModulator::NameCom3(), BlackMisc::PhysicalQuantities::CFrequency(activeFrequencyMHz, BlackMisc::PhysicalQuantities::CFrequencyUnit::MHz()), BlackMisc::PhysicalQuantities::CFrequency(standbyFrequencyMHz < 0 ? activeFrequencyMHz : standbyFrequencyMHz, BlackMisc::PhysicalQuantities::CFrequencyUnit::MHz())); } @@ -298,38 +325,39 @@ public: * \param standbyFrequency * \return */ - static CComSystem getCom3System(BlackMisc::PhysicalQuantities::CFrequency activeFrequency, BlackMisc::PhysicalQuantities::CFrequency standbyFrequency = CModulator::FrequencyNotSet()) { + static CComSystem getCom3System(BlackMisc::PhysicalQuantities::CFrequency activeFrequency, BlackMisc::PhysicalQuantities::CFrequency standbyFrequency = CModulator::FrequencyNotSet()) + { return CComSystem(CModulator::NameCom3(), activeFrequency, standbyFrequency == CModulator::FrequencyNotSet() ? activeFrequency : standbyFrequency); } /*! * \brief Try to get COM unit - * \param comSystem + * \param[out] o_comSystem * \param activeFrequencyMHz * \param standbyFrequencyMHz * \return */ - static bool tryGetCom3System(CComSystem &comSystem, double activeFrequencyMHz, double standbyFrequencyMHz = -1) { - return CComSystem::tryGetComSystem(comSystem, CModulator::NameCom3(), activeFrequencyMHz, standbyFrequencyMHz); + static bool tryGetCom3System(CComSystem &o_comSystem, double activeFrequencyMHz, double standbyFrequencyMHz = -1) + { + return CComSystem::tryGetComSystem(o_comSystem, CModulator::NameCom3(), activeFrequencyMHz, standbyFrequencyMHz); } /*! * \brief Try to get COM unit - * \param comSystem + * \param[out] o_comSystem * \param activeFrequency * \param standbyFrequency * \return */ - static bool tryGetCom3System(CComSystem &comSystem, BlackMisc::PhysicalQuantities::CFrequency activeFrequency, BlackMisc::PhysicalQuantities::CFrequency standbyFrequency = CModulator::FrequencyNotSet()) { - return CComSystem::tryGetComSystem(comSystem, CModulator::NameCom3(), activeFrequency, standbyFrequency); + static bool tryGetCom3System(CComSystem &o_comSystem, BlackMisc::PhysicalQuantities::CFrequency activeFrequency, BlackMisc::PhysicalQuantities::CFrequency standbyFrequency = CModulator::FrequencyNotSet()) + { + return CComSystem::tryGetComSystem(o_comSystem, CModulator::NameCom3(), activeFrequency, standbyFrequency); } - }; - +} // namespace } // namespace -} // namespace Q_DECLARE_METATYPE(BlackMisc::Aviation::CComSystem) #endif // include guard diff --git a/src/blackmisc/aviomodulator.cpp b/src/blackmisc/aviomodulator.cpp index ce309642b..94428b640 100644 --- a/src/blackmisc/aviomodulator.cpp +++ b/src/blackmisc/aviomodulator.cpp @@ -38,33 +38,33 @@ template void CModulator::registerMetadata() /* * Assigment operator = */ -template CModulator& CModulator::operator=(const CModulator &otherModulator) +template CModulator& CModulator::operator=(const CModulator &other) { - if (this == &otherModulator) return *this; // Same object? - this->m_frequencyActive = otherModulator.m_frequencyActive; - this->m_frequencyStandby = otherModulator.m_frequencyStandby; - this->m_digits = otherModulator.m_digits; - this->setName(otherModulator.getName()); + if (this == &other) return *this; + this->m_frequencyActive = other.m_frequencyActive; + this->m_frequencyStandby = other.m_frequencyStandby; + this->m_digits = other.m_digits; + this->setName(other.getName()); return *this; } /* * Equal operator == */ -template bool CModulator::operator ==(const CModulator &otherModulator) const +template bool CModulator::operator ==(const CModulator &other) const { - if (this == &otherModulator) return true; - return (this->getName() == otherModulator.getName() && - this->m_frequencyActive == otherModulator.m_frequencyActive && - this->m_frequencyStandby == otherModulator.m_frequencyStandby); + if (this == &other) return true; + return (this->getName() == other.getName() && + this->m_frequencyActive == other.m_frequencyActive && + this->m_frequencyStandby == other.m_frequencyStandby); } /* * Equal operator != */ -template bool CModulator::operator !=(const CModulator &otherModulator) const +template bool CModulator::operator !=(const CModulator &other) const { - return !(otherModulator == (*this)); + return !(other == (*this)); } // see here for the reason of thess forward instantiations diff --git a/src/blackmisc/aviomodulator.h b/src/blackmisc/aviomodulator.h index 4985a5822..9b6ccf12e 100644 --- a/src/blackmisc/aviomodulator.h +++ b/src/blackmisc/aviomodulator.h @@ -11,7 +11,6 @@ namespace BlackMisc { - namespace Aviation { @@ -26,7 +25,8 @@ template class CModulator : public CAvionicsBase * \param uc * \return */ - friend const QDBusArgument &operator>>(const QDBusArgument &argument, AVIO &uc) { + friend const QDBusArgument &operator>>(const QDBusArgument &argument, AVIO &uc) + { // If I do not have the method here, DBus metasystem tries to stream against // a container: inline const QDBusArgument &operator>>(const QDBusArgument &arg, Container &list) // Once someone solves this, this methods should go and the @@ -55,7 +55,6 @@ protected: int m_digits; //!< digits used protected: - /*! * \brief Default constructor */ @@ -63,10 +62,10 @@ protected: /*! * \brief Copy constructor - * \param otherUnit + * \param other */ - CModulator(const CModulator &otherUnit) : CAvionicsBase(otherUnit.getName()), - m_frequencyActive(otherUnit.m_frequencyActive), m_frequencyStandby(otherUnit.m_frequencyStandby), m_digits(otherUnit.m_digits) {} + CModulator(const CModulator &other) : CAvionicsBase(other.getName()), + m_frequencyActive(other.m_frequencyActive), m_frequencyStandby(other.m_frequencyStandby), m_digits(other.m_digits) {} /*! * \brief Constructor @@ -76,14 +75,15 @@ protected: * \param digits */ CModulator(const QString &name, const BlackMisc::PhysicalQuantities::CFrequency &activeFrequency, const BlackMisc::PhysicalQuantities::CFrequency &standbyFrequency, int digits) : - CAvionicsBase(name), m_frequencyActive(activeFrequency), m_frequencyStandby(standbyFrequency), m_digits(digits) { } + CAvionicsBase(name), m_frequencyActive(activeFrequency), m_frequencyStandby(standbyFrequency), m_digits(digits) {} /*! * \brief String for converter * \param i18n * \return */ - virtual QString convertToQString(bool i18n = false) const { + virtual QString convertToQString(bool i18n = false) const + { QString s(this->getName()); s.append(" Active: ").append(this->m_frequencyActive.unitValueRoundedWithUnit(3, i18n)); s.append(" Standby: ").append(this->m_frequencyStandby.unitValueRoundedWithUnit(3, i18n)); @@ -128,24 +128,25 @@ protected: /*! * \brief Assigment operator = - * \param otherModulator + * \param other * \return */ - CModulator &operator =(const CModulator &otherModulator); + CModulator &operator =(const CModulator &other); /*! * \brief operator == - * \param otherModulator + * \param other * \return */ - bool operator ==(const CModulator &otherModulator) const; + bool operator ==(const CModulator &other) const; /*! * \brief operator != - * \param otherModulator + * \param other * \return */ - bool operator !=(const CModulator &otherModulator) const; + bool operator !=(const CModulator &other) const; + /*! * \brief COM1 * \return @@ -240,8 +241,9 @@ protected: * \brief Stream to DBus << * \param argument */ - virtual void marshallToDbus(QDBusArgument &argument) const { - CAvionicsBase::marshallToDbus(argument); + virtual void marshallToDbus(QDBusArgument &argument) const + { + this->CAvionicsBase::marshallToDbus(argument); argument << this->m_frequencyActive; argument << this->m_frequencyStandby; argument << this->m_digits; @@ -251,8 +253,9 @@ protected: * \brief Stream from DBus >> * \param argument */ - virtual void unmarshallFromDbus(const QDBusArgument &argument) { - CAvionicsBase::unmarshallFromDbus(argument); + virtual void unmarshallFromDbus(const QDBusArgument &argument) + { + this->CAvionicsBase::unmarshallFromDbus(argument); argument >> this->m_frequencyActive; argument >> this->m_frequencyStandby; argument >> this->m_digits; diff --git a/src/blackmisc/avionavsystem.h b/src/blackmisc/avionavsystem.h index b2d448037..f6ec2026b 100644 --- a/src/blackmisc/avionavsystem.h +++ b/src/blackmisc/avionavsystem.h @@ -28,6 +28,7 @@ private: double fr = f.valueRounded(BlackMisc::PhysicalQuantities::CFrequencyUnit::MHz(), this->m_digits); return fr >= 108.0 && fr <= 117.95; } + /*! * \brief Valid military aviation frequency? * \param f @@ -38,6 +39,7 @@ private: double fr = f.valueRounded(BlackMisc::PhysicalQuantities::CFrequencyUnit::MHz(), this->m_digits); return fr >= 960.0 && fr <= 1215.0; // valid TACAN frequency } + /*! * \brief Constructor * \param validate @@ -45,7 +47,6 @@ private: * \param activeFrequency * \param standbyFrequency * \param digits - * */ CNavSystem(bool validate, const QString &name, const BlackMisc::PhysicalQuantities::CFrequency &activeFrequency, const BlackMisc::PhysicalQuantities::CFrequency &standbyFrequency, int digits = 3): CModulator(name, activeFrequency, standbyFrequency, digits) @@ -68,11 +69,12 @@ protected: this->isValidMilitaryNavigationFrequency(this->getFrequencyStandby())); return v; } + /*! * \brief Validate values by assert and exception * \param strict * \throws std::range_error - * \remarks Cannot be virtualsince already used in constructor + * \remarks Cannot be virtual because used in constructor * \return */ bool validate(bool strict = true) const @@ -84,16 +86,19 @@ protected: if (!valid) throw std::range_error("Illegal values in CModulator::validate"); return true; } + public: /*! * Default constructor */ CNavSystem() : CModulator() {} + /*! * \brief Copy constructor - * \param otherSystem + * \param other */ - CNavSystem(const CNavSystem &otherSystem) : CModulator(otherSystem) {} + CNavSystem(const CNavSystem &other) : CModulator(other) {} + /*! * \brief Constructor * \param name @@ -106,85 +111,92 @@ public: { this->validate(true); } + /*! * \brief Set active frequency * \param frequencyMHz */ void setFrequencyActiveMHz(double frequencyMHz) { - CModulator::setFrequencyActiveMHz(frequencyMHz); + this->CModulator::setFrequencyActiveMHz(frequencyMHz); this->validate(true); } + /*! * \brief Set standby frequency * \param frequencyMHz */ void setFrequencyStandbyMHz(double frequencyMHz) { - CModulator::setFrequencyStandbyMHz(frequencyMHz); + this->CModulator::setFrequencyStandbyMHz(frequencyMHz); this->validate(true); } + /*! * \brief Assigment operator = - * \param otherSystem + * \param other * \return */ - CNavSystem &operator =(const CNavSystem &otherSystem) + CNavSystem &operator =(const CNavSystem &other) { - CModulator::operator =(otherSystem); - return (*this); + this->CModulator::operator =(other); + return *this; } + /*! * \brief operator == - * \param otherSystem + * \param other * \return */ - bool operator ==(const CNavSystem &otherSystem) const + bool operator ==(const CNavSystem &other) const { - return CModulator::operator ==(otherSystem); + return this->CModulator::operator ==(other); } + /*! * \brief operator == - * \param otherSystem + * \param other * \return */ - bool operator !=(const CNavSystem &otherSystem) const + bool operator !=(const CNavSystem &other) const { - return CModulator::operator !=(otherSystem); + return this->CModulator::operator !=(other); } /*! * Try to get a NAV unit with given name and frequency. Returns true in case an object * has been sucessfully created,otherwise returns a default object. - * \param navSystem + * \param[out] o_navSystem * \param name * \param activeFrequencyMHz * \param standbyFrequencyMHz * \return */ - static bool tryGetNavSystem(CNavSystem &navSystem, const QString &name, double activeFrequencyMHz, double standbyFrequencyMHz = -1) + static bool tryGetNavSystem(CNavSystem &o_navSystem, const QString &name, double activeFrequencyMHz, double standbyFrequencyMHz = -1) { - navSystem = CNavSystem(false, name, BlackMisc::PhysicalQuantities::CFrequency(activeFrequencyMHz, BlackMisc::PhysicalQuantities::CFrequencyUnit::MHz()), BlackMisc::PhysicalQuantities::CFrequency(standbyFrequencyMHz < 0 ? activeFrequencyMHz : standbyFrequencyMHz, BlackMisc::PhysicalQuantities::CFrequencyUnit::MHz())); + o_navSystem = CNavSystem(false, name, BlackMisc::PhysicalQuantities::CFrequency(activeFrequencyMHz, BlackMisc::PhysicalQuantities::CFrequencyUnit::MHz()), BlackMisc::PhysicalQuantities::CFrequency(standbyFrequencyMHz < 0 ? activeFrequencyMHz : standbyFrequencyMHz, BlackMisc::PhysicalQuantities::CFrequencyUnit::MHz())); bool s; - if (!(s = navSystem.validate(false))) navSystem = CNavSystem(); // reset to default + if (!(s = o_navSystem.validate(false))) o_navSystem = CNavSystem(); // reset to default return s; } + /*! * Try to get a NAV unit with given name and frequency. Returns true in case an object * has been sucessfully created, otherwise returns a default object. - * \param navSystem + * \param[out] o_navSystem * \param name * \param activeFrequency * \param standbyFrequency * \return */ - static bool tryGetNavSystem(CNavSystem &navSystem, const QString &name, BlackMisc::PhysicalQuantities::CFrequency activeFrequency, BlackMisc::PhysicalQuantities::CFrequency standbyFrequency = CModulator::FrequencyNotSet()) + static bool tryGetNavSystem(CNavSystem &o_navSystem, const QString &name, BlackMisc::PhysicalQuantities::CFrequency activeFrequency, BlackMisc::PhysicalQuantities::CFrequency standbyFrequency = CModulator::FrequencyNotSet()) { - navSystem = CNavSystem(false, name, activeFrequency, standbyFrequency); + o_navSystem = CNavSystem(false, name, activeFrequency, standbyFrequency); bool s; - if (!(s = navSystem.validate(false))) navSystem = CNavSystem(); // reset to default + if (!(s = o_navSystem.validate(false))) o_navSystem = CNavSystem(); // reset to default return s; } + /*! * \brief NAV1 unit * \param activeFrequencyMHz @@ -195,6 +207,7 @@ public: { return CNavSystem(CModulator::NameNav1(), BlackMisc::PhysicalQuantities::CFrequency(activeFrequencyMHz, BlackMisc::PhysicalQuantities::CFrequencyUnit::MHz()), BlackMisc::PhysicalQuantities::CFrequency(standbyFrequencyMHz < 0 ? activeFrequencyMHz : standbyFrequencyMHz, BlackMisc::PhysicalQuantities::CFrequencyUnit::MHz())); } + /*! * \brief NAV1 unit * \param activeFrequency @@ -205,28 +218,31 @@ public: { return CNavSystem(CModulator::NameNav1(), activeFrequency, standbyFrequency == CModulator::FrequencyNotSet() ? activeFrequency : standbyFrequency); } + /*! * \brief Try to get NAV unit - * \param navSystem + * \param[out] o_navSystem * \param activeFrequencyMHz * \param standbyFrequencyMHz * \return */ - static bool tryGetNav1System(CNavSystem &navSystem, double activeFrequencyMHz, double standbyFrequencyMHz = -1) + static bool tryGetNav1System(CNavSystem &o_navSystem, double activeFrequencyMHz, double standbyFrequencyMHz = -1) { - return CNavSystem::tryGetNavSystem(navSystem, CModulator::NameNav1(), activeFrequencyMHz, standbyFrequencyMHz); + return CNavSystem::tryGetNavSystem(o_navSystem, CModulator::NameNav1(), activeFrequencyMHz, standbyFrequencyMHz); } + /*! * \brief Try to get NAV unit - * \param navSystem + * \param[out] o_navSystem * \param activeFrequency * \param standbyFrequency * \return */ - static bool tryGetNav1System(CNavSystem &navSystem, BlackMisc::PhysicalQuantities::CFrequency activeFrequency, BlackMisc::PhysicalQuantities::CFrequency standbyFrequency = CModulator::FrequencyNotSet()) + static bool tryGetNav1System(CNavSystem &o_navSystem, BlackMisc::PhysicalQuantities::CFrequency activeFrequency, BlackMisc::PhysicalQuantities::CFrequency standbyFrequency = CModulator::FrequencyNotSet()) { - return CNavSystem::tryGetNavSystem(navSystem, CModulator::NameNav1(), activeFrequency, standbyFrequency); + return CNavSystem::tryGetNavSystem(o_navSystem, CModulator::NameNav1(), activeFrequency, standbyFrequency); } + /*! * \brief NAV2 unit * \param activeFrequencyMHz @@ -237,6 +253,7 @@ public: { return CNavSystem(CModulator::NameNav2(), BlackMisc::PhysicalQuantities::CFrequency(activeFrequencyMHz, BlackMisc::PhysicalQuantities::CFrequencyUnit::MHz()), BlackMisc::PhysicalQuantities::CFrequency(standbyFrequencyMHz < 0 ? activeFrequencyMHz : standbyFrequencyMHz, BlackMisc::PhysicalQuantities::CFrequencyUnit::MHz())); } + /*! * \brief NAV2 unit * \param activeFrequency @@ -247,32 +264,35 @@ public: { return CNavSystem(CModulator::NameNav2(), activeFrequency, standbyFrequency == CModulator::FrequencyNotSet() ? activeFrequency : standbyFrequency); } + /*! * \brief Try to get NAV unit - * \param navSystem + * \param[out] o_navSystem * \param activeFrequencyMHz * \param standbyFrequencyMHz * \return */ - static bool tryGetNav2System(CNavSystem &navSystem, double activeFrequencyMHz, double standbyFrequencyMHz = -1) + static bool tryGetNav2System(CNavSystem &o_navSystem, double activeFrequencyMHz, double standbyFrequencyMHz = -1) { - return CNavSystem::tryGetNavSystem(navSystem, CModulator::NameNav2(), activeFrequencyMHz, standbyFrequencyMHz); + return CNavSystem::tryGetNavSystem(o_navSystem, CModulator::NameNav2(), activeFrequencyMHz, standbyFrequencyMHz); } + /*! * \brief Try to get NAV unit - * \param navSystem + * \param[out] o_navSystem * \param activeFrequency * \param standbyFrequency * \return */ - static bool tryGetNav2System(CNavSystem &navSystem, BlackMisc::PhysicalQuantities::CFrequency activeFrequency, BlackMisc::PhysicalQuantities::CFrequency standbyFrequency = CModulator::FrequencyNotSet()) + static bool tryGetNav2System(CNavSystem &o_navSystem, BlackMisc::PhysicalQuantities::CFrequency activeFrequency, BlackMisc::PhysicalQuantities::CFrequency standbyFrequency = CModulator::FrequencyNotSet()) { - return CNavSystem::tryGetNavSystem(navSystem, CModulator::NameNav2(), activeFrequency, standbyFrequency); + return CNavSystem::tryGetNavSystem(o_navSystem, CModulator::NameNav2(), activeFrequency, standbyFrequency); } }; } // namespace } // namespace + Q_DECLARE_METATYPE(BlackMisc::Aviation::CNavSystem) #endif // BLACKMISC_AVIONAVSYSTEM_H diff --git a/src/blackmisc/aviotransponder.cpp b/src/blackmisc/aviotransponder.cpp index 431c393ff..676508e4a 100644 --- a/src/blackmisc/aviotransponder.cpp +++ b/src/blackmisc/aviotransponder.cpp @@ -45,7 +45,7 @@ bool CTransponder::validate(bool strict) const /** * String representation */ -QString CTransponder::convertToQString(bool /** i18n **/) const +QString CTransponder::convertToQString(bool /* i18n */) const { QString s = this->getName(); s = s.append(" ").append(this->getTransponderCodeFormatted()).append(" ").append(this->getModeAsString()); @@ -103,8 +103,9 @@ QString CTransponder::getTransponderCodeFormatted() const * \brief Stream to DBus << * \param argument */ -void CTransponder::marshallToDbus(QDBusArgument &argument) const { - CAvionicsBase::marshallToDbus(argument); +void CTransponder::marshallToDbus(QDBusArgument &argument) const +{ + this->CAvionicsBase::marshallToDbus(argument); argument << this->m_transponderCode; argument << static_cast(this->m_transponderMode); } @@ -113,8 +114,9 @@ void CTransponder::marshallToDbus(QDBusArgument &argument) const { * \brief Stream from DBus >> * \param argument */ -void CTransponder::unmarshallFromDbus(const QDBusArgument &argument) { - CAvionicsBase::unmarshallFromDbus(argument); +void CTransponder::unmarshallFromDbus(const QDBusArgument &argument) +{ + this->CAvionicsBase::unmarshallFromDbus(argument); qint32 tm; argument >> this->m_transponderCode; argument >> tm; diff --git a/src/blackmisc/aviotransponder.h b/src/blackmisc/aviotransponder.h index 97621277a..e866dfbfc 100644 --- a/src/blackmisc/aviotransponder.h +++ b/src/blackmisc/aviotransponder.h @@ -61,7 +61,7 @@ private: { bool ok = false; this->m_transponderCode = transponderCode.toUInt(&ok); - if (!ok)this->m_transponderCode = -1; // will cause assert / exception + if (!ok) this->m_transponderCode = -1; // will cause assert / exception this->validate(validate); } @@ -117,10 +117,10 @@ public: /*! * \brief Copy constructor - * \param otherTransponder + * \param other */ - CTransponder(const CTransponder &otherTransponder) : CAvionicsBase(otherTransponder.getName()), - m_transponderCode(otherTransponder.m_transponderCode), m_transponderMode(otherTransponder.m_transponderMode) {} + CTransponder(const CTransponder &other) : CAvionicsBase(other.getName()), + m_transponderCode(other.m_transponderCode), m_transponderMode(other.m_transponderMode) {} /*! * \brief Constructor @@ -145,7 +145,7 @@ public: { bool ok = false; this->m_transponderCode = transponderCode.toUInt(&ok); - if (!ok)this->m_transponderCode = -1; // will cause assert / exception + if (!ok) this->m_transponderCode = -1; // will cause assert / exception this->validate(true); } @@ -209,7 +209,7 @@ public: } /*! - * \brief Set emergency + * \brief Set VFR */ void setVFR() { @@ -217,7 +217,7 @@ public: } /*! - * \brief Set emergency + * \brief Set IFR */ void setIFR() { @@ -226,71 +226,71 @@ public: /*! * \brief Assigment operator = - * \param otherTransponder + * \param other * \return */ - CTransponder &operator =(const CTransponder &otherTransponder) + CTransponder &operator =(const CTransponder &other) { - CAvionicsBase::operator =(otherTransponder); - this->m_transponderMode = otherTransponder.m_transponderMode; - this->m_transponderCode = otherTransponder.m_transponderCode; - return (*this); + this->CAvionicsBase::operator =(other); + this->m_transponderMode = other.m_transponderMode; + this->m_transponderCode = other.m_transponderCode; + return *this; } /*! * \brief operator == - * \param otherTransponder + * \param other * \return */ - bool operator ==(const CTransponder &otherTransponder) const + bool operator ==(const CTransponder &other) const { return - this->m_transponderCode == otherTransponder.m_transponderCode && - this->m_transponderMode == otherTransponder.m_transponderMode && - CAvionicsBase::operator ==(otherTransponder); + this->m_transponderCode == other.m_transponderCode && + this->m_transponderMode == other.m_transponderMode && + this->CAvionicsBase::operator ==(other); } /*! * \brief operator =! - * \param otherSystem + * \param other * \return */ - bool operator !=(const CTransponder &otherSystem) const + bool operator !=(const CTransponder &other) const { - return !((*this) == otherSystem); + return !((*this) == other); } /*! * Try to get a Transponder unit with given name and code. Returns true in case an object * has been sucessfully created, otherwise returns a default object. - * \param transponder + * \param[out] o_transponder * \param name * \param transponderCode * \param mode * \return */ - static bool tryGetTransponder(CTransponder &transponder, const QString &name, qint32 transponderCode, TransponderMode mode) + static bool tryGetTransponder(CTransponder &o_transponder, const QString &name, qint32 transponderCode, TransponderMode mode) { - transponder = CTransponder(false, name, transponderCode, mode); + o_transponder = CTransponder(false, name, transponderCode, mode); bool s; - if (!(s = transponder.validate(false))) transponder = CTransponder(); // reset to default + if (!(s = o_transponder.validate(false))) o_transponder = CTransponder(); // reset to default return s; } /*! * Try to get a Transponder unit with given name and code. Returns true in case an object * has been sucessfully created, otherwise returns a default object. - * \param transponder + * \param[out] o_transponder * \param name * \param transponderCode * \param mode * \return */ - static bool tryGetTransponder(CTransponder &transponder, const QString &name, const QString &transponderCode, TransponderMode mode) + static bool tryGetTransponder(CTransponder &o_transponder, const QString &name, const QString &transponderCode, TransponderMode mode) { - transponder = CTransponder(false, name, transponderCode, mode); + o_transponder = CTransponder(false, name, transponderCode, mode); bool s; - if (!(s = transponder.validate(false))) transponder = CTransponder(); // reset to default + if (!(s = o_transponder.validate(false))) o_transponder = CTransponder(); // reset to default return s; } @@ -307,26 +307,26 @@ public: /*! * \brief Try to get Transponder unit - * \param transponder + * \param[out] o_transponder * \param transponderCode * \param mode * \return */ - static bool tryGetStandardTransponder(CTransponder &transponder, qint32 transponderCode, TransponderMode mode) + static bool tryGetStandardTransponder(CTransponder &o_transponder, qint32 transponderCode, TransponderMode mode) { - return CTransponder::tryGetTransponder(transponder, "Transponder", transponderCode, mode); + return CTransponder::tryGetTransponder(o_transponder, "Transponder", transponderCode, mode); } /*! * \brief Try to get Transponder unit - * \param transponder + * \param[out] o_transponder * \param transponderCode * \param mode * \return */ - static bool tryGetStandardTransponder(CTransponder &transponder, const QString &transponderCode, TransponderMode mode) + static bool tryGetStandardTransponder(CTransponder &o_transponder, const QString &transponderCode, TransponderMode mode) { - return CTransponder::tryGetTransponder(transponder, "Transponder", transponderCode, mode); + return CTransponder::tryGetTransponder(o_transponder, "Transponder", transponderCode, mode); } /*! @@ -338,6 +338,7 @@ public: } // namespace } // namespace + Q_DECLARE_METATYPE(BlackMisc::Aviation::CTransponder) #endif // BLACKMISC_AVIOTRANSPONDER_H diff --git a/src/blackmisc/avtrack.cpp b/src/blackmisc/avtrack.cpp index 341d93a32..5fe603fc0 100644 --- a/src/blackmisc/avtrack.cpp +++ b/src/blackmisc/avtrack.cpp @@ -25,29 +25,28 @@ QString CTrack::convertToQString(bool i18n) const /* * Assigment */ -CTrack& CTrack::operator =(const CTrack &otherTrack) +CTrack& CTrack::operator =(const CTrack &other) { - // Check for self-assignment! - if (this == &otherTrack) return *this; - CAngle::operator = (otherTrack); - this->m_magnetic = otherTrack.m_magnetic; - return (*this); + if (this == &other) return *this; + this->CAngle::operator = (other); + this->m_magnetic = other.m_magnetic; + return *this; } /* * Equal? */ -bool CTrack::operator ==(const CTrack &otherTrack) +bool CTrack::operator ==(const CTrack &other) { - return otherTrack.m_magnetic == this->m_magnetic && CAngle::operator ==(otherTrack); + return other.m_magnetic == this->m_magnetic && this->CAngle::operator ==(other); } /* * Unequal? */ -bool CTrack::operator !=(const CTrack &otherTrack) +bool CTrack::operator !=(const CTrack &other) { - return !((*this) == otherTrack); + return !((*this) == other); } /*! diff --git a/src/blackmisc/avtrack.h b/src/blackmisc/avtrack.h index 84c2ecffb..d9e88dd15 100644 --- a/src/blackmisc/avtrack.h +++ b/src/blackmisc/avtrack.h @@ -7,7 +7,6 @@ #define BLACKMISC_AVTRACK_H #include "blackmisc/pqangle.h" - namespace BlackMisc { namespace Aviation @@ -33,8 +32,9 @@ protected: * \brief Stream to DBus << * \param argument */ - virtual void marshallToDbus(QDBusArgument &argument) const { - CAngle::marshallToDbus(argument); + virtual void marshallToDbus(QDBusArgument &argument) const + { + this->CAngle::marshallToDbus(argument); argument << this->m_magnetic; } @@ -42,8 +42,9 @@ protected: * \brief Stream from DBus >> * \param argument */ - virtual void unmarshallFromDbus(const QDBusArgument &argument) { - CAngle::unmarshallFromDbus(argument); + virtual void unmarshallFromDbus(const QDBusArgument &argument) + { + this->CAngle::unmarshallFromDbus(argument); argument >> this->m_magnetic; } @@ -52,6 +53,7 @@ public: * \brief Default constructor: 0 Track magnetic */ CTrack() : BlackMisc::PhysicalQuantities::CAngle(0, BlackMisc::PhysicalQuantities::CAngleUnit::rad()), m_magnetic(true) {} + /*! * \brief Constructor * \param value @@ -59,6 +61,7 @@ public: * \param unit */ CTrack(double value, bool magnetic, const BlackMisc::PhysicalQuantities::CAngleUnit &unit) : BlackMisc::PhysicalQuantities::CAngle(value, unit), m_magnetic(magnetic) {} + /*! * \brief Constructor * \param value @@ -66,42 +69,47 @@ public: * \param unit */ CTrack(int value, bool magnetic, const BlackMisc::PhysicalQuantities::CAngleUnit &unit) : BlackMisc::PhysicalQuantities::CAngle(value, unit), m_magnetic(magnetic) {} + /*! * \brief Constructor by CAngle * \param track * \param magnetic */ - CTrack(BlackMisc::PhysicalQuantities::CAngle track, bool magnetic) : BlackMisc::PhysicalQuantities::CAngle(), m_magnetic(magnetic) { - BlackMisc::PhysicalQuantities::CAngle::operator =(track); - } + CTrack(BlackMisc::PhysicalQuantities::CAngle track, bool magnetic) : BlackMisc::PhysicalQuantities::CAngle(track), m_magnetic(magnetic) {} + /*! * \brief Copy constructor - * \param otherTrack + * \param other */ - CTrack(const CTrack &otherTrack) : BlackMisc::PhysicalQuantities::CAngle(otherTrack), m_magnetic(otherTrack.m_magnetic) {} + CTrack(const CTrack &other) : BlackMisc::PhysicalQuantities::CAngle(other), m_magnetic(other.m_magnetic) {} + /*! * \brief Assignment operator = - * \param otherTrack - * @return + * \param other + * \return */ - CTrack &operator =(const CTrack &otherTrack); + CTrack &operator =(const CTrack &other); + /*! * \brief Equal operator == - * \param otherTrack - * @return + * \param other + * \return */ - bool operator ==(const CTrack &otherTrack); + bool operator ==(const CTrack &other); + /*! * \brief Unequal operator == - * \param otherTrack - * @return + * \param other + * \return */ - bool operator !=(const CTrack &otherTrack); + bool operator !=(const CTrack &other); + /*! * \brief Magnetic Track? * \return */ - bool isMagneticTrack() const { + bool isMagneticTrack() const + { return this->m_magnetic; QT_TRANSLATE_NOOP("Aviation", "magnetic"); QT_TRANSLATE_NOOP("Aviation", "true"); @@ -111,10 +119,22 @@ public: * \brief True Track? * \return */ - bool isTrueTrack() const { + bool isTrueTrack() const + { return !this->m_magnetic; } + /*! + * \brief Switch angle unit + * \param newUnit + * \return + */ + CTrack &switchUnit(const BlackMisc::PhysicalQuantities::CAngleUnit &newUnit) + { + this->CAngle::switchUnit(newUnit); + return *this; + } + /*! * \brief Register metadata */ @@ -122,7 +142,6 @@ public: }; } // namespace - } // namespace Q_DECLARE_METATYPE(BlackMisc::Aviation::CTrack) diff --git a/src/blackmisc/basestreamstringifier.h b/src/blackmisc/basestreamstringifier.h index 1246b2cee..ca216096f 100644 --- a/src/blackmisc/basestreamstringifier.h +++ b/src/blackmisc/basestreamstringifier.h @@ -17,7 +17,6 @@ namespace BlackMisc { // Virtual operators: http://stackoverflow.com/a/4571634/356726 class CBaseStreamStringifier { - /*! * \brief Stream << overload to be used in debugging messages * \param debug @@ -30,9 +29,6 @@ class CBaseStreamStringifier return debug; } - // msvc2010: friend QDebug &operator<<(QDebug &debug, const CBaseStreamStringifier &uc) - // MinGW: No reference - /*! * \brief Operator << based on text stream * \param textStream @@ -98,7 +94,8 @@ class CBaseStreamStringifier * \param uc * \return */ - friend const QDBusArgument &operator>>(const QDBusArgument &argument, CBaseStreamStringifier &uc) { + friend const QDBusArgument &operator>>(const QDBusArgument &argument, CBaseStreamStringifier &uc) + { argument.beginStructure(); uc.unmarshallFromDbus(argument); argument.endStructure(); @@ -120,7 +117,6 @@ class CBaseStreamStringifier } public: - /*! * \brief Virtual destructor */ @@ -129,7 +125,6 @@ public: /*! * \brief Cast as QString * \bool i18n - * \remarks operator cast caused too many ambiguity trouble */ QString toQString(bool i18n = false) const { @@ -173,12 +168,11 @@ protected: /*! * \brief Copy assignment operator. - * This is protected in order to forbid slicing an instance of one derived - * class into an instance of a completely unrelated derived class. + * \remark This is protected in order to forbid slicing an instance of one derived + * class into an instance of a completely unrelated derived class. * \return */ CBaseStreamStringifier& operator=(const CBaseStreamStringifier&) { return *this; } - }; } // namespace diff --git a/src/blackmisc/blackmiscfreefunctions.cpp b/src/blackmisc/blackmiscfreefunctions.cpp index 9d21ea7a4..70020caa3 100644 --- a/src/blackmisc/blackmiscfreefunctions.cpp +++ b/src/blackmisc/blackmiscfreefunctions.cpp @@ -10,17 +10,15 @@ */ void BlackMisc::PhysicalQuantities::registerMetadata() { - { - CAcceleration::registerMetadata(); - CAngle::registerMetadata(); - CFrequency::registerMetadata(); - CLength::registerMetadata(); - CMass::registerMetadata(); - CPressure::registerMetadata(); - CSpeed::registerMetadata(); - CTemperature::registerMetadata(); - CTime::registerMetadata(); - } + CAcceleration::registerMetadata(); + CAngle::registerMetadata(); + CFrequency::registerMetadata(); + CLength::registerMetadata(); + CMass::registerMetadata(); + CPressure::registerMetadata(); + CSpeed::registerMetadata(); + CTemperature::registerMetadata(); + CTime::registerMetadata(); } /* @@ -32,7 +30,6 @@ void BlackMisc::Aviation::registerMetadata() CNavSystem::registerMetadata(); CAdfSystem::registerMetadata(); CAltitude::registerMetadata(); - CAviationVerticalPositions::registerMetadata(); CTransponder::registerMetadata(); CHeading::registerMetadata(); CTrack::registerMetadata(); diff --git a/src/blackmisc/coordinateecef.h b/src/blackmisc/coordinateecef.h index 42695a483..e660b72ef 100644 --- a/src/blackmisc/coordinateecef.h +++ b/src/blackmisc/coordinateecef.h @@ -11,6 +11,7 @@ namespace BlackMisc { namespace Geo { + /*! * \brief Earth centered, earth fixed position */ @@ -112,11 +113,11 @@ protected: arg(QString::number(this->z(), 'f', 6)); return s; } - }; } // namespace } // namespace + Q_DECLARE_METATYPE(BlackMisc::Geo::CCoordinateEcef) #endif // guard diff --git a/src/blackmisc/coordinategeodetic.cpp b/src/blackmisc/coordinategeodetic.cpp index 363dd370d..10f64507c 100644 --- a/src/blackmisc/coordinategeodetic.cpp +++ b/src/blackmisc/coordinategeodetic.cpp @@ -22,7 +22,8 @@ QString CCoordinateGeodetic::convertToQString(bool i18n) const /* * Marshall to Dbus */ -void CCoordinateGeodetic::marshallToDbus(QDBusArgument &argument) const { +void CCoordinateGeodetic::marshallToDbus(QDBusArgument &argument) const +{ argument << this->m_latitude; argument << this->m_longitude; argument << this->m_height; @@ -31,7 +32,8 @@ void CCoordinateGeodetic::marshallToDbus(QDBusArgument &argument) const { /* * Unmarshall from Dbus */ -void CCoordinateGeodetic::unmarshallFromDbus(const QDBusArgument &argument) { +void CCoordinateGeodetic::unmarshallFromDbus(const QDBusArgument &argument) +{ argument >> this->m_latitude; argument >> this->m_longitude; argument >> this->m_height; diff --git a/src/blackmisc/coordinategeodetic.h b/src/blackmisc/coordinategeodetic.h index 7af0596c1..7f7ef9681 100644 --- a/src/blackmisc/coordinategeodetic.h +++ b/src/blackmisc/coordinategeodetic.h @@ -39,14 +39,12 @@ class ICoordinateGeodetic */ class CCoordinateGeodetic : public CBaseStreamStringifier, public ICoordinateGeodetic { - private: BlackMisc::Geo::CLatitude m_latitude; //!< Latitude BlackMisc::Geo::CLongitude m_longitude; //!< Longitude BlackMisc::PhysicalQuantities::CLength m_height; //!< height protected: - /*! * \brief String for converter * \param i18n @@ -132,7 +130,7 @@ public: { this->m_latitude.switchUnit(unit); this->m_longitude.switchUnit(unit); - return (*this); + return *this; } /*! @@ -143,14 +141,14 @@ public: CCoordinateGeodetic &switchUnit(const BlackMisc::PhysicalQuantities::CLengthUnit &unit) { this->m_height.switchUnit(unit); - return (*this); + return *this; } /*! * \brief Set latitude * \param latitude */ - void setLatitude(CLatitude latitude) + void setLatitude(const CLatitude &latitude) { this->m_latitude = latitude; } @@ -159,7 +157,7 @@ public: * \brief Set longitude * \param longitude */ - void setLongitude(CLongitude longitude) + void setLongitude(const CLongitude &longitude) { this->m_longitude = longitude; } @@ -168,58 +166,57 @@ public: * \brief Set height * \param height */ - void setHeight(BlackMisc::PhysicalQuantities::CLength height) + void setHeight(const BlackMisc::PhysicalQuantities::CLength &height) { this->m_height = height; } /*! * \brief Equal operator == - * \param otherGeodetic + * \param other * \return */ - bool operator ==(const CCoordinateGeodetic &otherGeodetic) const + bool operator ==(const CCoordinateGeodetic &other) const { - if (this == &otherGeodetic) return true; - return this->m_height == otherGeodetic.m_height && - this->m_latitude == otherGeodetic.m_latitude && - this->m_longitude == otherGeodetic.m_longitude; + if (this == &other) return true; + return this->m_height == other.m_height && + this->m_latitude == other.m_latitude && + this->m_longitude == other.m_longitude; } /*! * \brief Unequal operator != - * \param otherGeodetic + * \param other * \return */ - bool operator !=(const CCoordinateGeodetic &otherGeodetic) const + bool operator !=(const CCoordinateGeodetic &other) const { - if (this == &otherGeodetic) return false; - return !((*this) == otherGeodetic); + return !((*this) == other); } /*! * \brief Assigment operator = - * \param otherGeodetic + * \param other * \return */ - CCoordinateGeodetic &operator =(const CCoordinateGeodetic &otherGeodetic) + CCoordinateGeodetic &operator =(const CCoordinateGeodetic &other) { - if (this == &otherGeodetic) return *this; // Same object? - this->m_height = otherGeodetic.m_height; - this->m_latitude = otherGeodetic.m_latitude; - this->m_longitude = otherGeodetic.m_longitude; - return (*this); + if (this == &other) return *this; + this->m_height = other.m_height; + this->m_latitude = other.m_latitude; + this->m_longitude = other.m_longitude; + return *this; } /* * Register metadata */ static void registerMetadata(); - }; } // namespace } // namespace + Q_DECLARE_METATYPE(BlackMisc::Geo::CCoordinateGeodetic) #endif // guard diff --git a/src/blackmisc/coordinatened.h b/src/blackmisc/coordinatened.h index 00972ec7c..57fdd9f85 100644 --- a/src/blackmisc/coordinatened.h +++ b/src/blackmisc/coordinatened.h @@ -18,7 +18,6 @@ namespace Geo */ class CCoordinateNed : public BlackMisc::Math::CVector3DBase { - private: CCoordinateGeodetic m_referencePosition; //!< geodetic reference position bool m_hasReferencePosition; //!< valid reference position? @@ -70,58 +69,57 @@ public: * \brief Copy constructor * \param otherNed */ - CCoordinateNed(const CCoordinateNed &otherNed) : - CVector3DBase(otherNed), m_referencePosition(otherNed.m_referencePosition), m_hasReferencePosition(otherNed.m_hasReferencePosition) {} + CCoordinateNed(const CCoordinateNed &other) : + CVector3DBase(other), m_referencePosition(other.m_referencePosition), m_hasReferencePosition(other.m_hasReferencePosition) {} /*! * \brief Constructor by math vector * \param vector */ - explicit CCoordinateNed(const BlackMisc::Math::CVector3D vector) : CVector3DBase(vector.i(), vector.j(), vector.k()), m_referencePosition(), m_hasReferencePosition(false) {} + explicit CCoordinateNed(const BlackMisc::Math::CVector3D &vector) : CVector3DBase(vector.i(), vector.j(), vector.k()), m_referencePosition(), m_hasReferencePosition(false) {} /*! * \brief Constructor by math vector and reference position * \param referencePosition * \param vector */ - CCoordinateNed(const CCoordinateGeodetic &referencePosition, const BlackMisc::Math::CVector3D vector) : CVector3DBase(vector.i(), vector.j(), vector.k()), m_referencePosition(referencePosition), m_hasReferencePosition(true) {} + CCoordinateNed(const CCoordinateGeodetic &referencePosition, const BlackMisc::Math::CVector3D &vector) : CVector3DBase(vector.i(), vector.j(), vector.k()), m_referencePosition(referencePosition), m_hasReferencePosition(true) {} /*! * \brief Equal operator == - * \param otherNed + * \param other * \return */ - bool operator ==(const CCoordinateNed &otherNed) const + bool operator ==(const CCoordinateNed &other) const { - if (this == &otherNed) return true; - return this->m_hasReferencePosition == otherNed.m_hasReferencePosition && - this->m_referencePosition == otherNed.m_referencePosition && - CVector3DBase::operator== (otherNed); + if (this == &other) return true; + return this->m_hasReferencePosition == other.m_hasReferencePosition && + this->m_referencePosition == other.m_referencePosition && + this->CVector3DBase::operator== (other); } /*! * \brief Unequal operator != - * \param otherNed + * \param other * \return */ - bool operator !=(const CCoordinateNed &otherNed) const + bool operator !=(const CCoordinateNed &other) const { - if (this == &otherNed) return false; - return !((*this) == otherNed); + return !((*this) == other); } /*! * \brief Assigment operator = - * \param otherNed + * \param other * \return */ - CCoordinateNed &operator =(const CCoordinateNed &otherNed) + CCoordinateNed &operator =(const CCoordinateNed &other) { - if (this == &otherNed) return *this; // Same object? - CVector3DBase::operator = (otherNed); - this->m_hasReferencePosition = otherNed.m_hasReferencePosition; - this->m_referencePosition = otherNed.m_referencePosition; - return (*this); + if (this == &other) return *this; + this->CVector3DBase::operator = (other); + this->m_hasReferencePosition = other.m_hasReferencePosition; + this->m_referencePosition = other.m_referencePosition; + return *this; } /*! @@ -218,6 +216,7 @@ public: } // namespace } // namespace + Q_DECLARE_METATYPE(BlackMisc::Geo::CCoordinateNed) #endif // guard diff --git a/src/blackmisc/coordinatetransformation.h b/src/blackmisc/coordinatetransformation.h index b4e9a62e3..519eb586b 100644 --- a/src/blackmisc/coordinatetransformation.h +++ b/src/blackmisc/coordinatetransformation.h @@ -91,9 +91,9 @@ private: } /*! - * \brief Default constructor, avoid object instantiation + * \brief Default constructor, deleted */ - CCoordinateTransformation() {} + CCoordinateTransformation(); public: /*! @@ -124,7 +124,6 @@ public: * \return */ static CCoordinateGeodetic toGeodetic(const CCoordinateEcef &ecef); - }; } // namespace diff --git a/src/blackmisc/geoearthangle.h b/src/blackmisc/geoearthangle.h index 29e93cd1e..54c74a021 100644 --- a/src/blackmisc/geoearthangle.h +++ b/src/blackmisc/geoearthangle.h @@ -22,7 +22,8 @@ template class CEarthAngle : public BlackMisc::PhysicalQuantiti * \param uc * \return */ - friend const QDBusArgument &operator>>(const QDBusArgument &argument, LATorLON &uc) { + friend const QDBusArgument &operator>>(const QDBusArgument &argument, LATorLON &uc) + { // If I do not have the method here, DBus metasystem tries to stream against // a container: inline const QDBusArgument &operator>>(const QDBusArgument &arg, Container &list) // Once someone solves this, this methods should go and the @@ -53,20 +54,20 @@ protected: * \brief Copy constructor * \param latOrLon */ - CEarthAngle(const LATorLON &latOrLon) : CAngle(latOrLon) { } + CEarthAngle(const LATorLON &latOrLon) : CAngle(latOrLon) {} /*! * \brief Init by double value * \param value * \param unit */ - CEarthAngle(double value, const BlackMisc::PhysicalQuantities::CAngleUnit &unit): CAngle(value, unit) {} + CEarthAngle(double value, const BlackMisc::PhysicalQuantities::CAngleUnit &unit) : CAngle(value, unit) {} /*! * \brief Init by double value * \param angle */ - CEarthAngle(const BlackMisc::PhysicalQuantities::CAngle &angle): CAngle(angle) {} + CEarthAngle(const BlackMisc::PhysicalQuantities::CAngle &angle) : CAngle(angle) {} /*! * \brief String for converter and streaming @@ -81,16 +82,18 @@ protected: * \brief Stream to DBus << * \param argument */ - virtual void marshallToDbus(QDBusArgument &argument) const { - CAngle::marshallToDbus(argument); + virtual void marshallToDbus(QDBusArgument &argument) const + { + this->CAngle::marshallToDbus(argument); } /*! * \brief Stream from DBus >> * \param argument */ - virtual void unmarshallFromDbus(const QDBusArgument &argument) { - CAngle::unmarshallFromDbus(argument); + virtual void unmarshallFromDbus(const QDBusArgument &argument) + { + this->CAngle::unmarshallFromDbus(argument); } public: @@ -106,7 +109,7 @@ public: */ bool operator==(const LATorLON &latOrLon) const { - return CAngle::operator ==(latOrLon); + return this->CAngle::operator ==(latOrLon); } /*! @@ -116,7 +119,7 @@ public: */ bool operator!=(const LATorLON &latOrLon) const { - return CAngle::operator !=(latOrLon); + return this->CAngle::operator !=(latOrLon); } /*! @@ -126,8 +129,8 @@ public: */ CEarthAngle &operator +=(const CEarthAngle &latOrLon) { - CAngle::operator +=(latOrLon); - return (*this); + this->CAngle::operator +=(latOrLon); + return *this; } /*! @@ -137,8 +140,8 @@ public: */ CEarthAngle &operator -=(const CEarthAngle &latOrLon) { - CAngle::operator -=(latOrLon); - return (*this); + this->CAngle::operator -=(latOrLon); + return *this; } /*! @@ -148,7 +151,7 @@ public: */ bool operator >(const LATorLON &latOrLon) const { - return CAngle::operator >(latOrLon); + return this->CAngle::operator >(latOrLon); } /*! @@ -158,7 +161,7 @@ public: */ bool operator <(const LATorLON &latOrLon) const { - return CAngle::operator >(latOrLon); + return this->CAngle::operator >(latOrLon); } /*! @@ -168,7 +171,7 @@ public: */ bool operator <=(const LATorLON &latOrLon) const { - return CAngle::operator <=(latOrLon); + return this->CAngle::operator <=(latOrLon); } /*! @@ -178,7 +181,7 @@ public: */ bool operator >=(const LATorLON &latOrLon) const { - return CAngle::operator >=(latOrLon); + return this->CAngle::operator >=(latOrLon); } /*! @@ -188,8 +191,8 @@ public: */ CEarthAngle &operator =(const LATorLON &latOrLon) { - CAngle::operator =(latOrLon); - return (*this); + this->CAngle::operator =(latOrLon); + return *this; } /*! @@ -199,8 +202,7 @@ public: */ LATorLON operator +(const LATorLON &latOrLon) const { - LATorLON l(0.0, this->getUnit()); - l += (*this); + LATorLON l(*this); l += latOrLon; return l; } @@ -212,8 +214,7 @@ public: */ LATorLON operator -(const LATorLON &latOrLon) const { - LATorLON l(0.0, this->getUnit()); - l += (*this); + LATorLON l(*this); l -= latOrLon; return l; } @@ -229,7 +230,6 @@ public: * \return */ static LATorLON fromWgs84(const QString &wgsCoordinate); - }; } // namespace diff --git a/src/blackmisc/geolatitude.h b/src/blackmisc/geolatitude.h index d4f7ac644..781a8b599 100644 --- a/src/blackmisc/geolatitude.h +++ b/src/blackmisc/geolatitude.h @@ -33,9 +33,9 @@ public: /*! * \brief Copy constructor - * \param latitude + * \param other */ - CLatitude(const CLatitude &latitude) : CEarthAngle(latitude) {} + CLatitude(const CLatitude &other) : CEarthAngle(other) {} /*! * \brief Constructor @@ -48,13 +48,12 @@ public: * \param value * \param unit */ - CLatitude(double value, const BlackMisc::PhysicalQuantities::CAngleUnit &unit): CEarthAngle(value, unit) {} + CLatitude(double value, const BlackMisc::PhysicalQuantities::CAngleUnit &unit) : CEarthAngle(value, unit) {} /*! * \brief Virtual destructor */ virtual ~CLatitude() {} - }; } // namespace diff --git a/src/blackmisc/geolongitude.h b/src/blackmisc/geolongitude.h index 884e3913c..a851be10c 100644 --- a/src/blackmisc/geolongitude.h +++ b/src/blackmisc/geolongitude.h @@ -30,9 +30,9 @@ public: /*! * \brief Copy constructor - * \param Longitude + * \param other */ - CLongitude(const CLongitude &Longitude) : CEarthAngle(Longitude) {} + CLongitude(const CLongitude &other) : CEarthAngle(other) {} /*! * \brief Constructor @@ -45,7 +45,7 @@ public: * \param value * \param unit */ - CLongitude(double value, const BlackMisc::PhysicalQuantities::CAngleUnit &unit): CEarthAngle(value, unit) {} + CLongitude(double value, const BlackMisc::PhysicalQuantities::CAngleUnit &unit) : CEarthAngle(value, unit) {} /*! * \brief Virtual destructor diff --git a/src/blackmisc/mathematics.h b/src/blackmisc/mathematics.h index e97a72382..f49241513 100644 --- a/src/blackmisc/mathematics.h +++ b/src/blackmisc/mathematics.h @@ -102,9 +102,9 @@ public: private: /*! - * \brief Avoid object init + * \brief Deleted */ - CMath() {} + CMath(); }; } // namespace diff --git a/src/blackmisc/mathmatrix1x3.h b/src/blackmisc/mathmatrix1x3.h index 0daeea83b..430307397 100644 --- a/src/blackmisc/mathmatrix1x3.h +++ b/src/blackmisc/mathmatrix1x3.h @@ -21,15 +21,15 @@ class CMatrix1x3 : public CMatrixBase { public: /*! - * \brief Matrix 1x3 + * \brief Constructor */ CMatrix1x3() : CMatrixBase() {} /*! * \brief Copy constructor - * \param otherMatrix + * \param other */ - CMatrix1x3(const CMatrix1x3 &otherMatrix) : CMatrixBase(otherMatrix) {} + CMatrix1x3(const CMatrix1x3 &other) : CMatrixBase(other) {} /*! * \brief Init by fill value @@ -38,7 +38,7 @@ public: explicit CMatrix1x3(double fillValue) : CMatrixBase(fillValue) {} /*! - * \brief CMatrix 3x1 + * \brief Constructor * \param c1 * \param c2 * \param c3 @@ -52,8 +52,8 @@ public: }; } // namespace - } // namespace + Q_DECLARE_METATYPE(BlackMisc::Math::CMatrix1x3) #endif // guard diff --git a/src/blackmisc/mathmatrix3x1.h b/src/blackmisc/mathmatrix3x1.h index e26b82810..81078618a 100644 --- a/src/blackmisc/mathmatrix3x1.h +++ b/src/blackmisc/mathmatrix3x1.h @@ -23,17 +23,17 @@ class CMatrix3x1 : public CMatrixBase public: /*! - * \brief CMatrix 3x1 + * \brief Constructor */ CMatrix3x1() : CMatrixBase() {} /*! - * \brief CMatrix 3x1 + * \brief Constructor * \param r1 * \param r2 * \param r3 */ - CMatrix3x1(qreal r1, qreal r2, qreal r3) : CMatrixBase() + CMatrix3x1(double r1, double r2, double r3) : CMatrixBase() { this->m_matrix(0, 0) = r1; this->m_matrix(1, 0) = r2; @@ -44,7 +44,7 @@ public: * \brief Copy constructor * \param otherMatrix */ - CMatrix3x1(const CMatrix3x1 &otherMatrix) : CMatrixBase(otherMatrix) {} + CMatrix3x1(const CMatrix3x1 &other) : CMatrixBase(other) {} /*! * \brief Init by fill value @@ -74,8 +74,8 @@ public: }; } // namespace - } // namespace + Q_DECLARE_METATYPE(BlackMisc::Math::CMatrix3x1) #endif // guard diff --git a/src/blackmisc/mathmatrix3x3.cpp b/src/blackmisc/mathmatrix3x3.cpp index 7ef0e6905..21185d857 100644 --- a/src/blackmisc/mathmatrix3x3.cpp +++ b/src/blackmisc/mathmatrix3x3.cpp @@ -15,27 +15,25 @@ namespace Math */ double CMatrix3x3::determinant() const { - double determinant = + return this->m_matrix(0, 0) * this->m_matrix(1, 1) * this->m_matrix(2, 2) + this->m_matrix(0, 1) * this->m_matrix(1, 2) * this->m_matrix(2, 0) + this->m_matrix(0, 2) * this->m_matrix(1, 0) * this->m_matrix(2, 1) - this->m_matrix(0, 1) * this->m_matrix(1, 0) * this->m_matrix(2, 2) - this->m_matrix(0, 2) * this->m_matrix(1, 1) * this->m_matrix(2, 0) - this->m_matrix(0, 0) * this->m_matrix(1, 2) * this->m_matrix(2, 1); - - return determinant; } /* * Inverse */ -CMatrix3x3 CMatrix3x3::inverse(bool &invertible) const +CMatrix3x3 CMatrix3x3::inverse(bool &o_invertible) const { CMatrix3x3 inverse; double det; - if (this->allValuesEqual() || (det = determinant()) == 0) + if (this->allValuesEqual() || (det = this->determinant()) == 0) { - invertible = false; + o_invertible = false; inverse.setZero(); return inverse; } @@ -51,7 +49,7 @@ CMatrix3x3 CMatrix3x3::inverse(bool &invertible) const inverse.m_matrix(2, 1) = (- this->m_matrix(0, 0) * this->m_matrix(2, 1) + this->m_matrix(0, 1) * this->m_matrix(2, 0)) * invdet; inverse.m_matrix(2, 2) = (this->m_matrix(0, 0) * this->m_matrix(1, 1) - this->m_matrix(0, 1) * this->m_matrix(1, 0)) * invdet; - invertible = true; + o_invertible = true; return inverse; } @@ -78,5 +76,4 @@ CMatrix3x1 CMatrix3x3::getColumn(int column) const } } // namespace - } // namespace diff --git a/src/blackmisc/mathmatrix3x3.h b/src/blackmisc/mathmatrix3x3.h index b4da2c090..44e9c5b31 100644 --- a/src/blackmisc/mathmatrix3x3.h +++ b/src/blackmisc/mathmatrix3x3.h @@ -27,9 +27,9 @@ public: /*! * \brief Copy constructor - * \param otherMatrix + * \param other */ - CMatrix3x3(const CMatrix3x3 &otherMatrix) : CMatrixBase(otherMatrix) {} + CMatrix3x3(const CMatrix3x3 &other) : CMatrixBase(other) {} /*! * \brief Init by fill value @@ -72,43 +72,43 @@ public: /*! * \brief Calculate the inverse - * \param invertible + * \param[out] o_isInvertible * \return */ - CMatrix3x3 inverse(bool &invertible) const; + CMatrix3x3 inverse(bool &o_isInvertible) const; /*! * \brief Operator *= - * \param otherMatrix + * \param other * \return */ - CMatrix3x3 &operator *=(const CMatrix3x3 &otherMatrix) + CMatrix3x3 &operator *=(const CMatrix3x3 &other) { - this->m_matrix = this->m_matrix * otherMatrix.m_matrix; - return (*this); + this->m_matrix = this->m_matrix * other.m_matrix; + return *this; } /*! * \brief Operator * - * \param otherMatrix + * \param other * \return */ - CMatrix3x1 operator *(const CMatrix3x1 &otherMatrix) const + CMatrix3x1 operator *(const CMatrix3x1 &other) const { CMatrix3x1 m; - m.m_matrix = this->m_matrix * otherMatrix.m_matrix; + m.m_matrix = this->m_matrix * other.m_matrix; return m; } /*! * \brief Operator * - * \param otherMatrix + * \param other * \return */ - CMatrix3x3 operator *(const CMatrix3x3 &otherMatrix) const + CMatrix3x3 operator *(const CMatrix3x3 &other) const { CMatrix3x3 m(*this); - m *= otherMatrix; + m *= other; return m; } @@ -144,7 +144,7 @@ public: CMatrix3x3 &operator *=(double factor) { CMatrixBase::operator *=(factor); - return (*this); + return *this; } /*! @@ -175,8 +175,8 @@ public: }; } // namespace - } // namespace + Q_DECLARE_METATYPE(BlackMisc::Math::CMatrix3x3) #endif // guard diff --git a/src/blackmisc/mathmatrixbase.cpp b/src/blackmisc/mathmatrixbase.cpp index b00c1f9de..e2113a91b 100644 --- a/src/blackmisc/mathmatrixbase.cpp +++ b/src/blackmisc/mathmatrixbase.cpp @@ -34,7 +34,6 @@ template void CMatrixBase void CMatrixBase::checkRange(size_t row, size_t column) const { - // no >=0 comparison since unsinged comparison always >=0 bool valid = (row < Rows && column < Columns); Q_ASSERT_X(valid, "getElement()", "Row or column invalid"); if (!valid) throw std::range_error("Row or column invalid"); @@ -149,7 +148,7 @@ template void CMatrixBase QString CMatrixBase::convertToQString(bool /** i18n **/) const +template QString CMatrixBase::convertToQString(bool /* i18n */) const { QString s = "{"; for (int r = 0; r < Rows; r++) @@ -176,7 +175,6 @@ template void CMatrixBase(); } - // see here for the reason of thess forward instantiations // http://www.parashift.com/c++-faq/separate-template-class-defn-from-decl.html template class CMatrixBase; @@ -184,8 +182,4 @@ template class CMatrixBase; template class CMatrixBase; } // namespace - } // namespace - -#include "mathmatrixbase.h" - diff --git a/src/blackmisc/mathmatrixbase.h b/src/blackmisc/mathmatrixbase.h index a2090e5c0..7b6897f69 100644 --- a/src/blackmisc/mathmatrixbase.h +++ b/src/blackmisc/mathmatrixbase.h @@ -55,7 +55,8 @@ protected: * \brief Stream to DBus * \param argument */ - virtual void marshallToDbus(QDBusArgument &argument) const { + virtual void marshallToDbus(QDBusArgument &argument) const + { const QList l = this->toList(); // there is an issue with the signature of QList, so I use @@ -69,7 +70,8 @@ protected: * \brief Stream from DBus * \param argument */ - virtual void unmarshallFromDbus(const QDBusArgument &argument) { + virtual void unmarshallFromDbus(const QDBusArgument &argument) + { QList list; double v; while(!argument.atEnd()) { @@ -87,9 +89,9 @@ public: /*! * \brief Copy constructor - * \param otherMatrix + * \param other */ - CMatrixBase(const CMatrixBase &otherMatrix) : m_matrix(otherMatrix.m_matrix) {} + CMatrixBase(const CMatrixBase &other) : m_matrix(other.m_matrix) {} /*! * \brief Fill with value @@ -119,36 +121,35 @@ public: /*! * \brief Equal operator == - * \param otherMatrix + * \param other * \return */ - bool operator ==(const ImplMatrix &otherMatrix) const + bool operator ==(const ImplMatrix &other) const { - if (this == &otherMatrix) return true; - return this->m_matrix == otherMatrix.m_matrix; + if (this == &other) return true; + return this->m_matrix == other.m_matrix; } /*! * \brief Unequal operator != - * \param otherMatrix + * \param other * \return */ - bool operator !=(const ImplMatrix &otherMatrix) const + bool operator !=(const ImplMatrix &other) const { - if (this == &otherMatrix) return false; - return !((*this) == otherMatrix); + return !((*this) == other); } /*! * \brief Assigment operator = - * \param otherMatrix + * \param other * \return */ - CMatrixBase &operator =(const CMatrixBase &otherMatrix) + CMatrixBase &operator =(const CMatrixBase &other) { - if (this == &otherMatrix) return *this; // Same object? - this->m_matrix = otherMatrix.m_matrix; - return (*this); + if (this == &other) return *this; + this->m_matrix = other.m_matrix; + return *this; } /*! @@ -159,7 +160,7 @@ public: CMatrixBase &operator *=(double factor) { this->m_matrix *= factor; - return (*this); + return *this; } /*! @@ -177,12 +178,12 @@ public: /*! * \brief Operator to support commutative multiplication * \param factor - * \param otherMatrix + * \param other * \return */ - friend ImplMatrix operator *(double factor, const ImplMatrix &otherMatrix) + friend ImplMatrix operator *(double factor, const ImplMatrix &other) { - return otherMatrix * factor; + return other * factor; } /*! @@ -200,7 +201,7 @@ public: CMatrixBase &operator /=(double factor) { this->m_matrix /= factor; - return (*this); + return *this; } /*! @@ -217,47 +218,47 @@ public: /*! * \brief Operator += - * \param otherMatrix + * \param other * \return */ - CMatrixBase &operator +=(const CMatrixBase &otherMatrix) + CMatrixBase &operator +=(const CMatrixBase &other) { - this->m_matrix += otherMatrix.m_matrix; - return (*this); + this->m_matrix += other.m_matrix; + return *this; } /*! * \brief Operator + - * \param otherMatrix + * \param other * \return */ - ImplMatrix operator +(const ImplMatrix &otherMatrix) const + ImplMatrix operator +(const ImplMatrix &other) const { ImplMatrix m = *derived(); - m += otherMatrix; + m += other; return m; } /*! * \brief Operator -= - * \param otherMatrix + * \param other * \return */ - CMatrixBase &operator -=(const CMatrixBase &otherMatrix) + CMatrixBase &operator -=(const CMatrixBase &other) { - this->m_matrix -= otherMatrix.m_matrix; - return (*this); + this->m_matrix -= other.m_matrix; + return *this; } /*! * \brief Operator - - * \param otherMatrix + * \param other * \return */ - ImplMatrix operator -(const ImplMatrix &otherMatrix) const + ImplMatrix operator -(const ImplMatrix &other) const { ImplMatrix m = *derived(); - m -= otherMatrix; + m -= other; return m; } @@ -402,11 +403,9 @@ private: * \throws std::range_error if index out of bounds */ void checkRange(size_t row, size_t column) const; - }; } // namespace - } // namespace #endif // guard diff --git a/src/blackmisc/mathvector3d.h b/src/blackmisc/mathvector3d.h index 26a03cd37..dd8520bd0 100644 --- a/src/blackmisc/mathvector3d.h +++ b/src/blackmisc/mathvector3d.h @@ -35,9 +35,9 @@ public: /*! * \brief Copy constructor - * \param otherVector + * \param other */ - CVector3D(const CVector3D &otherVector) : CVector3DBase(otherVector) {} + CVector3D(const CVector3D &other) : CVector3DBase(other) {} /*! * \brief i @@ -97,6 +97,7 @@ public: } // namespace } // namespace + Q_DECLARE_METATYPE(BlackMisc::Math::CVector3D) #endif // guard diff --git a/src/blackmisc/mathvector3dbase.cpp b/src/blackmisc/mathvector3dbase.cpp index 8c07decb3..0e3df39f3 100644 --- a/src/blackmisc/mathvector3dbase.cpp +++ b/src/blackmisc/mathvector3dbase.cpp @@ -16,7 +16,7 @@ namespace Math /* * Convert to string */ -template QString CVector3DBase::convertToQString(bool /** i18n **/) const +template QString CVector3DBase::convertToQString(bool /* i18n */) const { QString s = ("{%1, %2, %3}"); s = s.arg(QString::number(this->m_i, 'f')). @@ -94,21 +94,21 @@ template void CVector3DBase::setElement(size_t ro /* * Cross product */ -template ImplVector CVector3DBase::crossProduct(const ImplVector &otherVector) const +template ImplVector CVector3DBase::crossProduct(const ImplVector &other) const { - ImplVector v(otherVector); - v.m_i = this->m_j * otherVector.m_k - this->m_k * otherVector.m_j; - v.m_j = this->m_k * otherVector.m_i - this->m_i * otherVector.m_k; - v.m_k = this->m_i * otherVector.m_j - this->m_j * otherVector.m_i; + ImplVector v(other); + v.m_i = this->m_j * other.m_k - this->m_k * other.m_j; + v.m_j = this->m_k * other.m_i - this->m_i * other.m_k; + v.m_k = this->m_i * other.m_j - this->m_j * other.m_i; return v; } /* * Cross product */ -template double CVector3DBase::dotProduct(const ImplVector &otherVector) const +template double CVector3DBase::dotProduct(const ImplVector &other) const { - return this->m_i * otherVector.m_i + this->m_j * otherVector.m_j + this->m_k * otherVector.m_k; + return this->m_i * other.m_i + this->m_j * other.m_j + this->m_k * other.m_k; } @@ -117,7 +117,7 @@ template double CVector3DBase::dotProduct(const I */ template void CVector3DBase::matrixMultiplication(const CMatrix3x3 &matrix) { - CMatrix3x1 m = matrix * (this->toMatrix3x1()); + CMatrix3x1 m = matrix * this->toMatrix3x1(); this->m_i = m(0, 0); this->m_j = m(1, 0); this->m_k = m(2, 0); @@ -136,7 +136,8 @@ template CMatrix3x1 CVector3DBase::toMatrix3x1() * \brief Stream to DBus * \param argument */ -template void CVector3DBase::marshallToDbus(QDBusArgument &argument) const { +template void CVector3DBase::marshallToDbus(QDBusArgument &argument) const +{ argument << this->m_i; argument << this->m_j; argument << this->m_k; @@ -146,7 +147,8 @@ template void CVector3DBase::marshallToDbus(QDBus * \brief Stream from DBus * \param argument */ -template void CVector3DBase::unmarshallFromDbus(const QDBusArgument &argument) { +template void CVector3DBase::unmarshallFromDbus(const QDBusArgument &argument) +{ argument >> this->m_i; argument >> this->m_j; argument >> this->m_k; @@ -168,5 +170,4 @@ template class CVector3DBase; template class CVector3DBase; } // namespace - } // namespace diff --git a/src/blackmisc/mathvector3dbase.h b/src/blackmisc/mathvector3dbase.h index aae74f5f4..7bd0fdc0e 100644 --- a/src/blackmisc/mathvector3dbase.h +++ b/src/blackmisc/mathvector3dbase.h @@ -23,14 +23,14 @@ class CMatrix3x1; // forward declaration */ template class CVector3DBase : public CBaseStreamStringifier { - /*! * \brief Unmarshalling operator >>, DBus to object * \param argument * \param uc * \return */ - friend const QDBusArgument &operator>>(const QDBusArgument &argument, ImplVector &uc) { + friend const QDBusArgument &operator>>(const QDBusArgument &argument, ImplVector &uc) + { // If I do not have the method here, DBus metasystem tries to stream against // a container: inline const QDBusArgument &operator>>(const QDBusArgument &arg, Container &list) // Once someone solves this, this methods should go and the @@ -71,7 +71,6 @@ private: } protected: - // using own value since Qt QVector3D stores internally as float double m_i; //!< Vector data i double m_j; //!< Vector data j @@ -98,9 +97,9 @@ protected: /*! * \brief Copy constructor - * \param otherVector + * \param other */ - CVector3DBase(const CVector3DBase &otherVector) : m_i(otherVector.m_i), m_j(otherVector.m_j), m_k(otherVector.m_k) {} + CVector3DBase(const CVector3DBase &other) : m_i(other.m_i), m_j(other.m_j), m_k(other.m_k) {} /*! * \brief String for converter @@ -122,7 +121,6 @@ protected: virtual void marshallToDbus(QDBusArgument &argument) const; public: - // getter and setters are implemented in the derived classes // as they have different names (x, i, north) @@ -137,7 +135,7 @@ public: void setZero(); /*! - * \brief Set zeros + * \brief Is zero */ bool isZero() const { @@ -151,7 +149,7 @@ public: bool isZeroEpsilon() const { ImplVector v; - v += (*this); + v += *this; v.round(); return v.isZero(); } @@ -182,124 +180,115 @@ public: */ double operator[](size_t row) const { return this->getElement(row); } - - /*! - * \brief Get row element by () - * \param row - * \return - */ - double operator()(size_t row) const { return this->getElement(row); } - /*! * \brief Equal operator == - * \param otherVector + * \param other * \return */ - bool operator ==(const CVector3DBase &otherVector) const + bool operator ==(const CVector3DBase &other) const { - if (this == &otherVector) return true; - return this->m_i == otherVector.m_i && - this->m_j == otherVector.m_j && - this->m_k == otherVector.m_k; + if (this == &other) return true; + return this->m_i == other.m_i && + this->m_j == other.m_j && + this->m_k == other.m_k; } /*! * \brief Unequal operator != - * \param otherVector + * \param other * \return */ - bool operator !=(const CVector3DBase &otherVector) const + bool operator !=(const CVector3DBase &other) const { - if (this == &otherVector) return false; - return !((*this) == otherVector); + return !((*this) == other); } /*! * \brief Assigment operator = - * \param otherVector + * \param other * \return */ - CVector3DBase &operator =(const CVector3DBase &otherVector) + CVector3DBase &operator =(const CVector3DBase &other) { - if (this == &otherVector) return *this; // Same object? - this->m_i = otherVector.m_i; - this->m_j = otherVector.m_j; - this->m_k = otherVector.m_k; - return (*this); + if (this == &other) return *this; + this->m_i = other.m_i; + this->m_j = other.m_j; + this->m_k = other.m_k; + return *this; } /*! * \brief Operator += - * \param otherVector + * \param other * \return */ - CVector3DBase &operator +=(const CVector3DBase &otherVector) + CVector3DBase &operator +=(const CVector3DBase &other) { - this->m_i += otherVector.m_i; - this->m_j += otherVector.m_j; - this->m_k += otherVector.m_k; - return (*this); + this->m_i += other.m_i; + this->m_j += other.m_j; + this->m_k += other.m_k; + return *this; } /*! * \brief Operator + - * \param otherVector + * \param other * \return */ - ImplVector operator +(const ImplVector &otherVector) const + ImplVector operator +(const ImplVector &other) const { ImplVector v = *derived(); - v += otherVector; + v += other; return v; } /*! * \brief Operator -= - * \param otherVector + * \param other * \return */ - CVector3DBase &operator -=(const CVector3DBase &otherVector) + CVector3DBase &operator -=(const CVector3DBase &other) { - this->m_i -= otherVector.m_i; - this->m_j -= otherVector.m_j; - this->m_k -= otherVector.m_k; - return (*this); + this->m_i -= other.m_i; + this->m_j -= other.m_j; + this->m_k -= other.m_k; + return *this; } /*! * \brief Operator - - * \param otherVector + * \param other * \return */ - ImplVector operator -(const ImplVector &otherVector) const + ImplVector operator -(const ImplVector &other) const { ImplVector v = *derived(); - v -= otherVector; + v -= other; return v; } /*! * \brief Operator *=, just x*x, y*y, z*z neither vector nor dot product (like a matrix produc) - * \param otherVector + * \param other * \return */ - CVector3DBase &operator *=(const CVector3DBase &otherVector) + CVector3DBase &operator *=(const CVector3DBase &other) { - this->m_i *= otherVector.m_i; - this->m_j *= otherVector.m_j; - this->m_k *= otherVector.m_k; - return (*this); + this->m_i *= other.m_i; + this->m_j *= other.m_j; + this->m_k *= other.m_k; + return *this; } /*! * \brief Operator, just x*x, y*y, z*z neither vector nor dot product, (like a matrix produc) - * \param otherVector + * \param other * \return */ - ImplVector operator *(const ImplVector &otherVector) const + ImplVector operator *(const ImplVector &other) const { ImplVector v = *derived(); - v *= otherVector; + v *= other; return v; } @@ -313,7 +302,7 @@ public: this->m_i *= factor; this->m_j *= factor; this->m_k *= factor; - return (*this); + return *this; } /*! @@ -334,9 +323,9 @@ public: * \param otherVector * \return */ - friend ImplVector operator *(double factor, const ImplVector &otherVector) + friend ImplVector operator *(double factor, const ImplVector &other) { - return otherVector * factor; + return other * factor; } /*! @@ -349,7 +338,7 @@ public: this->m_i /= divisor; this->m_j /= divisor; this->m_k /= divisor; - return (*this); + return *this; } /*! @@ -366,42 +355,42 @@ public: /*! * \brief Operator /=, just x/x, y/y, z/z - * \param otherVector + * \param other * \return */ - CVector3DBase &operator /=(const CVector3DBase &otherVector) + CVector3DBase &operator /=(const CVector3DBase &other) { - this->m_i /= otherVector.m_i; - this->m_j /= otherVector.m_j; - this->m_k /= otherVector.m_k; - return (*this); + this->m_i /= other.m_i; + this->m_j /= other.m_j; + this->m_k /= other.m_k; + return *this; } /*! * \brief Operator, just x/x, y/y, z/z - * \param otherVector + * \param other * \return */ - ImplVector operator /(const ImplVector &otherVector) const + ImplVector operator /(const ImplVector &other) const { ImplVector v = *derived(); - v /= otherVector; + v /= other; return v; } /*! * \brief Dot product - * \param otherVector + * \param other * \return */ - double dotProduct(const ImplVector &otherVector) const; + double dotProduct(const ImplVector &other) const; /*! * \brief Cross product - * \param otherVector + * \param other * \return */ - ImplVector crossProduct(const ImplVector &otherVector) const; + ImplVector crossProduct(const ImplVector &other) const; /*! * \brief Matrix * this vector @@ -450,7 +439,7 @@ public: * \brief Rounded vector * \return */ - ImplVector roundedVector() const + ImplVector rounded() const { ImplVector v = *derived(); v.round(); @@ -464,7 +453,6 @@ public: }; } // namespace - } // namespace #endif // guard diff --git a/src/blackmisc/pqacceleration.h b/src/blackmisc/pqacceleration.h index 1a8c4bba4..449c2aec9 100644 --- a/src/blackmisc/pqacceleration.h +++ b/src/blackmisc/pqacceleration.h @@ -38,16 +38,17 @@ public: CAcceleration(double value, const CAccelerationUnit &unit) : CPhysicalQuantity(value, unit, CAccelerationUnit::m_s2()) {} /*! - * \brief Copy constructor - * \param acceleration + * \brief Copy constructor by base type + * \param base */ - CAcceleration(const CPhysicalQuantity &acceleration) : CPhysicalQuantity(acceleration) {} + CAcceleration(const CPhysicalQuantity &base) : CPhysicalQuantity(base) {} /*! * \brief Virtual destructor */ virtual ~CAcceleration() {} }; + } // namespace } // namespace diff --git a/src/blackmisc/pqangle.h b/src/blackmisc/pqangle.h index 4cd63098a..de0bd6517 100644 --- a/src/blackmisc/pqangle.h +++ b/src/blackmisc/pqangle.h @@ -12,6 +12,7 @@ namespace BlackMisc { namespace PhysicalQuantities { + /*! * \brief Physical unit angle (radians, degrees) */ @@ -24,9 +25,9 @@ public: CAngle() : CPhysicalQuantity(0, CAngleUnit::rad(), CAngleUnit::rad()) {} /*! - * \brief Copy constructor + * \brief Copy constructor from base type */ - CAngle(const CAngle &angle) : CPhysicalQuantity(angle) {} + CAngle(const CPhysicalQuantity &base) : CPhysicalQuantity(base) {} /*! * \brief Init by int value @@ -51,9 +52,7 @@ public: CAngle(qint32 degrees, qint32 minutes, double seconds) : CPhysicalQuantity( degrees + minutes / 100.0 + seconds / 10000.0, - CAngleUnit::sexagesimalDeg(), CAngleUnit::rad()) { - // void - } + CAngleUnit::sexagesimalDeg(), CAngleUnit::rad()) {} /*! * \brief Virtual destructor diff --git a/src/blackmisc/pqbase.cpp b/src/blackmisc/pqbase.cpp index 774e268df..47a916f98 100644 --- a/src/blackmisc/pqbase.cpp +++ b/src/blackmisc/pqbase.cpp @@ -20,65 +20,62 @@ namespace PhysicalQuantities /* * Constructor */ -CMeasurementPrefix::CMeasurementPrefix(const QString &name, const QString &unitName, double factor): +CMeasurementPrefix::CMeasurementPrefix(const QString &name, const QString &unitName, double factor) : m_name(name), m_prefix(unitName), m_factor(factor) { - // void } /* * Constructor */ -CMeasurementPrefix::CMeasurementPrefix(const CMeasurementPrefix &otherMultiplier) : - m_name(otherMultiplier.m_name), m_prefix(otherMultiplier.m_prefix), m_factor(otherMultiplier.m_factor) +CMeasurementPrefix::CMeasurementPrefix(const CMeasurementPrefix &other) : + m_name(other.m_name), m_prefix(other.m_prefix), m_factor(other.m_factor) { - // void } /* * Assignment operator */ -CMeasurementPrefix &CMeasurementPrefix::operator=(const CMeasurementPrefix &otherMultiplier) +CMeasurementPrefix &CMeasurementPrefix::operator=(const CMeasurementPrefix &other) { - - if (this == &otherMultiplier) return *this; // Same object? Yes, so skip assignment, and just return *this - this->m_name = otherMultiplier.m_name; - this->m_prefix = otherMultiplier.m_prefix; - this->m_factor = otherMultiplier.m_factor; + if (this == &other) return *this; + this->m_name = other.m_name; + this->m_prefix = other.m_prefix; + this->m_factor = other.m_factor; return *this; } /* * Equal? */ -bool CMeasurementPrefix::operator ==(const CMeasurementPrefix &otherMultiplier) const +bool CMeasurementPrefix::operator ==(const CMeasurementPrefix &other) const { - if (this == &otherMultiplier) return true; - return this->m_factor == otherMultiplier.m_factor && this->m_name == otherMultiplier.m_name; + if (this == &other) return true; + return this->m_factor == other.m_factor && this->m_name == other.m_name; } /* * Not equal */ -bool CMeasurementPrefix::operator !=(const CMeasurementPrefix &otherMultiplier) const +bool CMeasurementPrefix::operator !=(const CMeasurementPrefix &other) const { - return !(*this == otherMultiplier); + return !(*this == other); } /* * Greater? */ -bool CMeasurementPrefix::operator >(const CMeasurementPrefix &otherMultiplier) const +bool CMeasurementPrefix::operator >(const CMeasurementPrefix &other) const { - return this->m_factor > otherMultiplier.m_factor; + return this->m_factor > other.m_factor; } /* * Less? */ -bool CMeasurementPrefix::operator <(const CMeasurementPrefix &otherMultiplier) const +bool CMeasurementPrefix::operator <(const CMeasurementPrefix &other) const { - return this->m_factor < otherMultiplier.m_factor; + return this->m_factor < other.m_factor; } // ----------------------------------------------------------------------- @@ -95,57 +92,55 @@ CMeasurementUnit::CMeasurementUnit(const QString &name, const QString &unitName, m_conversionFactorToSIConversionUnit(conversionFactorToSI), m_epsilon(epsilon), m_displayDigits(displayDigits), m_multiplier(multiplier), m_fromSiConverter(fromSiConverter), m_toSiConverter(toSiConverter) { - // void } /* * Copy constructor */ -CMeasurementUnit::CMeasurementUnit(const CMeasurementUnit &otherUnit): - m_name(otherUnit.m_name), m_unitName(otherUnit.m_unitName), m_type(otherUnit.m_type), m_isSiUnit(otherUnit.m_isSiUnit), - m_isSiBaseUnit(otherUnit.m_isSiBaseUnit), m_conversionFactorToSIConversionUnit(otherUnit.m_conversionFactorToSIConversionUnit), - m_epsilon(otherUnit.m_epsilon), m_displayDigits(otherUnit.m_displayDigits), m_multiplier(otherUnit.m_multiplier), m_fromSiConverter(otherUnit.m_fromSiConverter), m_toSiConverter(otherUnit.m_toSiConverter) +CMeasurementUnit::CMeasurementUnit(const CMeasurementUnit &other): + m_name(other.m_name), m_unitName(other.m_unitName), m_type(other.m_type), m_isSiUnit(other.m_isSiUnit), + m_isSiBaseUnit(other.m_isSiBaseUnit), m_conversionFactorToSIConversionUnit(other.m_conversionFactorToSIConversionUnit), + m_epsilon(other.m_epsilon), m_displayDigits(other.m_displayDigits), m_multiplier(other.m_multiplier), m_fromSiConverter(other.m_fromSiConverter), m_toSiConverter(other.m_toSiConverter) { - // void } /* * Assigment operator */ -CMeasurementUnit &CMeasurementUnit::operator =(const CMeasurementUnit &otherUnit) +CMeasurementUnit &CMeasurementUnit::operator =(const CMeasurementUnit &other) { - if (this == &otherUnit) return *this; // Same object? Yes, so skip assignment, and just return *this - this->m_name = otherUnit.m_name; - this->m_unitName = otherUnit.m_unitName; - this->m_type = otherUnit.m_type; - this->m_isSiUnit = otherUnit.m_isSiUnit; - this->m_isSiBaseUnit = otherUnit.m_isSiBaseUnit; - this->m_conversionFactorToSIConversionUnit = otherUnit.m_conversionFactorToSIConversionUnit; - this->m_multiplier = otherUnit.m_multiplier; - this->m_displayDigits = otherUnit.m_displayDigits; - this->m_epsilon = otherUnit.m_epsilon; - this->m_fromSiConverter = otherUnit.m_fromSiConverter; - this->m_toSiConverter = otherUnit.m_toSiConverter; + if (this == &other) return *this; // Same object? Yes, so skip assignment, and just return *this + this->m_name = other.m_name; + this->m_unitName = other.m_unitName; + this->m_type = other.m_type; + this->m_isSiUnit = other.m_isSiUnit; + this->m_isSiBaseUnit = other.m_isSiBaseUnit; + this->m_conversionFactorToSIConversionUnit = other.m_conversionFactorToSIConversionUnit; + this->m_multiplier = other.m_multiplier; + this->m_displayDigits = other.m_displayDigits; + this->m_epsilon = other.m_epsilon; + this->m_fromSiConverter = other.m_fromSiConverter; + this->m_toSiConverter = other.m_toSiConverter; return *this; } /* * Equal operator */ -bool CMeasurementUnit::operator ==(const CMeasurementUnit &otherUnit) const +bool CMeasurementUnit::operator ==(const CMeasurementUnit &other) const { - if (this == &otherUnit) return true; - if (this->m_type != otherUnit.m_type) return false; - return this->m_multiplier == otherUnit.m_multiplier && this->m_name == otherUnit.m_name - && this->m_isSiUnit == otherUnit.m_isSiUnit; + if (this == &other) return true; + if (this->m_type != other.m_type) return false; + return this->m_multiplier == other.m_multiplier && this->m_name == other.m_name + && this->m_isSiUnit == other.m_isSiUnit; } /* * Unequal operator */ -bool CMeasurementUnit::operator !=(const CMeasurementUnit &otherUnit) const +bool CMeasurementUnit::operator !=(const CMeasurementUnit &other) const { - return !(otherUnit == *this); + return !(other == *this); } /* @@ -153,7 +148,7 @@ bool CMeasurementUnit::operator !=(const CMeasurementUnit &otherUnit) const */ double CMeasurementUnit::conversionToUnit(double value, const CMeasurementUnit &to) const { - if (to == (*this)) return value; + if (to == *this) return value; double siValue = this->convertToSiConversionUnit(value); return to.convertFromSiConversionUnit(siValue); } @@ -179,7 +174,7 @@ double CMeasurementUnit::valueRounded(double value, int digits) const /* * Rounded to QString */ -QString CMeasurementUnit::toQStringRounded(double value, int digits, bool /** i18n **/) const +QString CMeasurementUnit::toQStringRounded(double value, int digits, bool /* i18n */) const { if (digits < 0) digits = this->m_displayDigits; double v = CMath::round(value, digits); diff --git a/src/blackmisc/pqbase.h b/src/blackmisc/pqbase.h index cd3ffa643..462fd527c 100644 --- a/src/blackmisc/pqbase.h +++ b/src/blackmisc/pqbase.h @@ -31,6 +31,7 @@ private: QString m_name; //!< name, e.g. "kilo" QString m_prefix; //!< prefix, e.g. "k" for kilo double m_factor; //!< factor, e.g. 1000 for kilo 1/100 for centi + /*! * Constructor by parameters * \brief CMeasurementMultiplier @@ -46,7 +47,7 @@ protected: * \param i18n * \return */ - virtual QString convertToQString(bool /* i18n */ = false) const + virtual QString convertToQString(bool /* i18n */ = false) const { return this->m_name; } @@ -55,7 +56,8 @@ protected: * \brief Stream to DBus * \param argument */ - virtual void marshallToDbus(QDBusArgument &argument) const { + virtual void marshallToDbus(QDBusArgument &argument) const + { argument << this->m_name; } @@ -63,7 +65,8 @@ protected: * \brief Stream from DBus * \param argument */ - virtual void unmarshallFromDbus(const QDBusArgument &argument) { + virtual void unmarshallFromDbus(const QDBusArgument &argument) + { QString name; argument >> name; (*this) = CMeasurementPrefix::fromPrefixName(name); @@ -72,48 +75,44 @@ protected: public: /*! * \brief Copy constructor - * \param otherMultiplier + * \param other */ - CMeasurementPrefix(const CMeasurementPrefix &otherMultiplier); + CMeasurementPrefix(const CMeasurementPrefix &other); /*! * \brief Assigmnet operator = - * \param otherMultiplier + * \param other * \return */ - CMeasurementPrefix &operator =(const CMeasurementPrefix &otherMultiplier); + CMeasurementPrefix &operator =(const CMeasurementPrefix &other); /*! * \brief Equal operator == - * \param otherMultiplier + * \param other * \return */ - bool operator == (const CMeasurementPrefix &otherMultiplier) const; + bool operator == (const CMeasurementPrefix &other) const; /*! * \brief Unequal operator != - * \param otherMultiplier + * \param other * \return */ - bool operator != (const CMeasurementPrefix &otherMultiplier) const; + bool operator != (const CMeasurementPrefix &other) const; /*! * \brief Greater operator > - * \param otherMultiplier + * \param other * \return */ - bool operator > (const CMeasurementPrefix &otherMultiplier) const; + bool operator > (const CMeasurementPrefix &other) const; /*! * \brief Less operator < - * \param otherMultiplier + * \param other * \return */ - bool operator < (const CMeasurementPrefix &otherMultiplier) const; - - /*! - * \brief Cast as double - */ + bool operator < (const CMeasurementPrefix &other) const; /*! * \brief Factor, e.g.1000 for "kilo" @@ -243,7 +242,6 @@ public: return milli; } - /*! * \brief All prefixes * \return @@ -267,9 +265,9 @@ public: * \param prefixName must be valid! * \return */ - static const CMeasurementPrefix &fromPrefixName(const QString &prefixName) { - QList prefixes = CMeasurementPrefix::prefixes(); - // read only, avoid deep copy + static const CMeasurementPrefix &fromPrefixName(const QString &prefixName) + { + const QList &prefixes = CMeasurementPrefix::prefixes(); for (int i = 0; i < prefixes.size(); ++i) { if (prefixes.at(i).getName() == prefixName) return (prefixes.at(i)); } @@ -329,16 +327,16 @@ protected: /*! * \brief Copy constructor - * \param otherUnit + * \param other */ - CMeasurementUnit(const CMeasurementUnit &otherUnit); + CMeasurementUnit(const CMeasurementUnit &other); /*! * \brief Assignment operator = - * \param otherUnit + * \param other * \return */ - CMeasurementUnit &operator =(const CMeasurementUnit &otherUnit); + CMeasurementUnit &operator =(const CMeasurementUnit &other); /*! * \brief String for streaming operators is full name @@ -394,7 +392,8 @@ protected: * \brief Stream to DBus * \param argument */ - virtual void marshallToDbus(QDBusArgument &argument) const { + virtual void marshallToDbus(QDBusArgument &argument) const + { argument << this->m_unitName; } @@ -402,7 +401,8 @@ protected: * \brief Stream from DBus * \param argument */ - virtual void unmarshallFromDbus(const QDBusArgument &) { + virtual void unmarshallFromDbus(const QDBusArgument &) + { // the concrete implementations will override this default // this is required so I can also stream None (*this) = CMeasurementUnit::None(); @@ -411,17 +411,17 @@ protected: public: /*! * \brief Equal operator == - * \param otherUnit + * \param other * \return */ - bool operator == (const CMeasurementUnit &otherUnit) const; + bool operator == (const CMeasurementUnit &other) const; /*! * \brief Unequal operator != - * \param otherUnit + * \param other * \return */ - bool operator != (const CMeasurementUnit &otherUnit) const; + bool operator != (const CMeasurementUnit &other) const; /*! * \brief Representing an SI unit? Examples: kilometer, meter, hertz @@ -455,7 +455,7 @@ public: * \param i18n * \return */ - QString getName(bool i18n=false) const + QString getName(bool i18n = false) const { return i18n ? QCoreApplication::translate("CMeasurementUnit", this->m_name.toStdString().c_str()) : this->m_name; } @@ -573,13 +573,13 @@ public: /*! * \brief Is given value <= epsilon? - * \param checkValue + * \param value * \return */ - bool isEpsilon(double checkValue) const + bool isEpsilon(double value) const { - if (checkValue == 0) return true; - return abs(checkValue) <= this->m_epsilon; + if (value == 0) return true; + return abs(value) <= this->m_epsilon; } // -------------------------------------------------------------------- @@ -587,7 +587,7 @@ public: // -------------------------------------------------------------------- /*! - * \brief Unit is not specified + * \brief Dimensionless unit * \return */ static CMeasurementUnit &None() @@ -595,7 +595,6 @@ public: static CMeasurementUnit none("none", "", "", false, false, 0.0, CMeasurementPrefix::None(), 0, 0); return none; } - }; } // namespace diff --git a/src/blackmisc/pqconstants.h b/src/blackmisc/pqconstants.h index 959ea75e8..173a605ae 100644 --- a/src/blackmisc/pqconstants.h +++ b/src/blackmisc/pqconstants.h @@ -12,86 +12,76 @@ namespace BlackMisc { namespace PhysicalQuantities { + /*! * \brief Physical quantities constants */ class CPhysicalQuantitiesConstants { - public: - /*! - * \brief Temperature absolute Zero in °C - * \return - */ - static const CTemperature& TemperatureAbsoluteZero() { - static CTemperature t(-273.15, CTemperatureUnit::C()); - return t; - } /*! * \brief Tripe point of purified water, 0.01°C * \return */ - static const CTemperature& TemperatureTriplePointOfVSMOW() { + static const CTemperature& TemperatureTriplePointOfVSMOW() + { static CTemperature t(-273.16, CTemperatureUnit::K()); return t; } + /*! * \brief Temperature absolute Zero in °C * \return */ - static const CTemperature& TemperatureAbsoluteZeroC() { + static const CTemperature& TemperatureAbsoluteZeroC() + { static CTemperature t(-273.15, CTemperatureUnit::C()); return t; } + /*! * \brief Standard pressure 1013,25mbar / 29.92inHg * \return */ - static const CPressure& InternationalStandardSeaLevelPressure() { + static const CPressure& InternationalStandardSeaLevelPressure() + { static CPressure p(1013.25, CPressureUnit::hPa()); return p; } - /*! - * \brief 0m - * \return - */ - static const CLength& Length0m() { - static CLength l(0, CLengthUnit::m()); - return l; - } - /*! - * \brief 0ft - * \return - */ - static const CLength& Length0ft() { - static CLength l(0, CLengthUnit::ft()); - return l; - } + /*! * \brief Unicom frequency * \return */ - static const CFrequency& FrequencyUnicom() { + static const CFrequency& FrequencyUnicom() + { static CFrequency f(122.8, CFrequencyUnit::MHz()); return f; } + /*! * \brief Civil aircraft emergency frequency * \return */ - static const CFrequency& FrequencyInternationalAirDistress() { + static const CFrequency& FrequencyInternationalAirDistress() + { static CFrequency f(121.5, CFrequencyUnit::MHz()); return f; } + /*! * \brief Military aircraft emergency frequency * \return */ - static const CFrequency& FrequencyMilitaryAirDistress() { + + static const CFrequency& FrequencyMilitaryAirDistress() + { static CFrequency f(243.0, CFrequencyUnit::MHz()); return f; } }; + } // namespace } // namespace + #endif // guard diff --git a/src/blackmisc/pqfrequency.h b/src/blackmisc/pqfrequency.h index def61d65d..4501a7461 100644 --- a/src/blackmisc/pqfrequency.h +++ b/src/blackmisc/pqfrequency.h @@ -23,27 +23,32 @@ public: * \brief Default constructor */ CFrequency() : CPhysicalQuantity(0, CFrequencyUnit::Hz(), CFrequencyUnit::Hz()) {} + /** - *\brief Copy constructor + *\brief Copy constructor from base type */ - CFrequency(const CFrequency &frequency) : CPhysicalQuantity(frequency) {} + CFrequency(const CPhysicalQuantity &base) : CPhysicalQuantity(base) {} + /*! * \brief Init by int value * \param value * \param unit */ CFrequency(qint32 value, const CFrequencyUnit &unit) : CPhysicalQuantity(value, unit, CFrequencyUnit::Hz()) {} + /*! * \brief Init by double value * \param value * \param unit */ CFrequency(double value, const CFrequencyUnit &unit) : CPhysicalQuantity(value, unit, CFrequencyUnit::Hz()) {} + /*! * \brief Virtual destructor */ virtual ~CFrequency() {} }; + } // namespace } // namespace diff --git a/src/blackmisc/pqlength.h b/src/blackmisc/pqlength.h index a5b914174..6cc339203 100644 --- a/src/blackmisc/pqlength.h +++ b/src/blackmisc/pqlength.h @@ -23,27 +23,32 @@ public: * \brief Default constructor */ CLength() : CPhysicalQuantity(0, CLengthUnit::m(), CLengthUnit::m()) {} + /** - *\brief Copy constructor + *\brief Copy constructor from base type */ - CLength(const CLength &length) : CPhysicalQuantity(length) {} + CLength(const CPhysicalQuantity &base) : CPhysicalQuantity(base) {} + /*! * \brief Init by int value * \param value * \param unit */ CLength(qint32 value, const CLengthUnit &unit) : CPhysicalQuantity(value, unit, CLengthUnit::m()) {} + /*! *\brief Init by double value * \param value * \param unit */ CLength(double value, const CLengthUnit &unit) : CPhysicalQuantity(value, unit, CLengthUnit::m()) {} + /*! * \brief Virtual destructor */ virtual ~CLength() {} }; + } // namespace } // namespace diff --git a/src/blackmisc/pqmass.h b/src/blackmisc/pqmass.h index 414a2c9a7..76cc070a0 100644 --- a/src/blackmisc/pqmass.h +++ b/src/blackmisc/pqmass.h @@ -38,16 +38,17 @@ public: CMass(double value, const CMassUnit &unit) : CPhysicalQuantity(value, unit, CMassUnit::kg()) {} /*! - * \brief Copy constructor - * \param mass + * \brief Copy constructor from base type + * \param base */ - CMass(const CPhysicalQuantity &mass) : CPhysicalQuantity(mass) {} + CMass(const CPhysicalQuantity &base) : CPhysicalQuantity(base) {} /*! * \brief Virtual destructor */ virtual ~CMass() {} }; + } // namespace } // namespace diff --git a/src/blackmisc/pqphysicalquantity.cpp b/src/blackmisc/pqphysicalquantity.cpp index 72eb72eeb..581cc9025 100644 --- a/src/blackmisc/pqphysicalquantity.cpp +++ b/src/blackmisc/pqphysicalquantity.cpp @@ -31,11 +31,10 @@ template CPhysicalQuantity::CPhysicalQuantity(doubl /* * Copy constructor */ -template CPhysicalQuantity::CPhysicalQuantity(const CPhysicalQuantity &otherQuantity) : - m_unitValueD(otherQuantity.m_unitValueD), m_unitValueI(otherQuantity.m_unitValueI), m_convertedSiUnitValueD(otherQuantity.m_convertedSiUnitValueD), - m_isIntegerBaseValue(otherQuantity.m_isIntegerBaseValue), m_unit(otherQuantity.m_unit), m_conversionSiUnit(otherQuantity.m_conversionSiUnit) +template CPhysicalQuantity::CPhysicalQuantity(const CPhysicalQuantity &other) : + m_unitValueD(other.m_unitValueD), m_unitValueI(other.m_unitValueI), m_convertedSiUnitValueD(other.m_convertedSiUnitValueD), + m_isIntegerBaseValue(other.m_isIntegerBaseValue), m_unit(other.m_unit), m_conversionSiUnit(other.m_conversionSiUnit) { - // void } /* @@ -43,40 +42,39 @@ template CPhysicalQuantity::CPhysicalQuantity(const */ template CPhysicalQuantity::~CPhysicalQuantity() { - // void } /* * Equal operator == */ -template bool CPhysicalQuantity::operator ==(const CPhysicalQuantity &otherQuantity) const +template bool CPhysicalQuantity::operator ==(const CPhysicalQuantity &other) const { - if (this == &otherQuantity) return true; - if (this->m_unit.getType() != otherQuantity.m_unit.getType()) return false; + if (this == &other) return true; + if (this->m_unit.getType() != other.m_unit.getType()) return false; // some special cases for best quality double diff; const double lenient = 1.001; // even diff already has a rounding issue to be avoided bool eq = false; - if (this->m_unit == otherQuantity.m_unit) + if (this->m_unit == other.m_unit) { // same unit - if (this->m_isIntegerBaseValue && otherQuantity.m_isIntegerBaseValue) + if (this->m_isIntegerBaseValue && other.m_isIntegerBaseValue) { // pure integer comparison, no rounding issues - eq = this->m_unitValueI == otherQuantity.m_unitValueI; + eq = this->m_unitValueI == other.m_unitValueI; } else { // same unit, comparison based on double - diff = qAbs(this->m_unitValueD - otherQuantity.m_unitValueD); + diff = qAbs(this->m_unitValueD - other.m_unitValueD); eq = diff <= (lenient * this->m_unit.getEpsilon()); } } else { // based on SI value - diff = qAbs(this->m_convertedSiUnitValueD - otherQuantity.m_convertedSiUnitValueD); + diff = qAbs(this->m_convertedSiUnitValueD - other.m_convertedSiUnitValueD); eq = diff <= (lenient * this->m_conversionSiUnit.getEpsilon()); } return eq; @@ -85,51 +83,48 @@ template bool CPhysicalQuantity::operator ==(const /* * Not equal */ -template bool CPhysicalQuantity::operator !=(const CPhysicalQuantity &otherQuantity) const +template bool CPhysicalQuantity::operator !=(const CPhysicalQuantity &other) const { - if (this == &otherQuantity) return false; - return !((*this) == otherQuantity); + return !((*this) == other); } /* * Assignment operator = */ -template CPhysicalQuantity& CPhysicalQuantity::operator=(const CPhysicalQuantity &otherQuantity) +template CPhysicalQuantity& CPhysicalQuantity::operator=(const CPhysicalQuantity &other) { + if (this == &other) return *this; - // Check for self-assignment! - if (this == &otherQuantity) return *this; // Same object? - - this->m_unitValueI = otherQuantity.m_unitValueI; - this->m_unitValueD = otherQuantity.m_unitValueD; - this->m_convertedSiUnitValueD = otherQuantity.m_convertedSiUnitValueD; - this->m_isIntegerBaseValue = otherQuantity.m_isIntegerBaseValue; - this->m_unit = otherQuantity.m_unit; - this->m_conversionSiUnit = otherQuantity.m_conversionSiUnit; + this->m_unitValueI = other.m_unitValueI; + this->m_unitValueD = other.m_unitValueD; + this->m_convertedSiUnitValueD = other.m_convertedSiUnitValueD; + this->m_isIntegerBaseValue = other.m_isIntegerBaseValue; + this->m_unit = other.m_unit; + this->m_conversionSiUnit = other.m_conversionSiUnit; return *this; } /* * Plus operator */ -template CPhysicalQuantity &CPhysicalQuantity::operator +=(const CPhysicalQuantity &otherQuantity) +template CPhysicalQuantity &CPhysicalQuantity::operator +=(const CPhysicalQuantity &other) { - if (this->m_unit == otherQuantity.m_unit) + if (this->m_unit == other.m_unit) { // same unit - if (this->m_isIntegerBaseValue && otherQuantity.m_isIntegerBaseValue) + if (this->m_isIntegerBaseValue && other.m_isIntegerBaseValue) { // pure integer, no rounding issues - this->setUnitValue(otherQuantity.m_unitValueI + this->m_unitValueI); + this->setUnitValue(other.m_unitValueI + this->m_unitValueI); } else { - this->setUnitValue(otherQuantity.m_unitValueD + this->m_unitValueD); + this->setUnitValue(other.m_unitValueD + this->m_unitValueD); } } else { - double v = otherQuantity.value(this->m_unit); + double v = other.value(this->m_unit); this->setUnitValue(v + this->m_unitValueD); } return *this; @@ -138,14 +133,13 @@ template CPhysicalQuantity &CPhysicalQuantity PQ CPhysicalQuantity::operator +(const PQ &otherQuantity) const +template PQ CPhysicalQuantity::operator +(const PQ &other) const { - PQ plus(otherQuantity); - plus += (*this); - return plus; + PQ copy(other); + copy += *this; + return copy; } - /* * Explicit plus */ @@ -165,24 +159,24 @@ template void CPhysicalQuantity::substractUnitValue /* * Minus operator */ -template CPhysicalQuantity &CPhysicalQuantity::operator -=(const CPhysicalQuantity &otherQuantity) +template CPhysicalQuantity &CPhysicalQuantity::operator -=(const CPhysicalQuantity &other) { - if (this->m_unit == otherQuantity.m_unit) + if (this->m_unit == other.m_unit) { // same unit - if (this->m_isIntegerBaseValue && otherQuantity.m_isIntegerBaseValue) + if (this->m_isIntegerBaseValue && other.m_isIntegerBaseValue) { // pure integer, no rounding issues - this->setUnitValue(otherQuantity.m_unitValueI - this->m_unitValueI); + this->setUnitValue(other.m_unitValueI - this->m_unitValueI); } else { - this->setUnitValue(otherQuantity.m_unitValueD - this->m_unitValueD); + this->setUnitValue(other.m_unitValueD - this->m_unitValueD); } } else { - double v = otherQuantity.value(this->m_unit); + double v = other.value(this->m_unit); this->setUnitValue(v - this->m_unitValueD); } return *this; @@ -191,11 +185,11 @@ template CPhysicalQuantity &CPhysicalQuantity PQ CPhysicalQuantity::operator -(const PQ &otherQuantity) const +template PQ CPhysicalQuantity::operator -(const PQ &other) const { - PQ minus = *derived(); - minus -= otherQuantity; - return minus; + PQ copy = *derived(); + copy -= other; + return copy; } /* @@ -212,9 +206,9 @@ template CPhysicalQuantity &CPhysicalQuantity PQ CPhysicalQuantity::operator *(double multiply) const { - PQ times = *derived(); - times *= multiply; - return times; + PQ copy = *derived(); + copy *= multiply; + return copy; } /* @@ -231,48 +225,48 @@ template CPhysicalQuantity &CPhysicalQuantity PQ CPhysicalQuantity::operator /(double divide) const { - PQ div = *derived(); - div /= divide; - return div; + PQ copy = *derived(); + copy /= divide; + return copy; } /* * Less operator < */ -template bool CPhysicalQuantity::operator <(const CPhysicalQuantity &otherQuantity) const +template bool CPhysicalQuantity::operator <(const CPhysicalQuantity &other) const { - if ((*this) == otherQuantity) return false; + if ((*this) == other) return false; // == considers epsilon, so we now have a diff > epsilon here - double diff = this->m_convertedSiUnitValueD - otherQuantity.m_convertedSiUnitValueD; + double diff = this->m_convertedSiUnitValueD - other.m_convertedSiUnitValueD; return (diff < 0); } /* * Greater than */ -template bool CPhysicalQuantity::operator >(const CPhysicalQuantity &otherQuantity) const +template bool CPhysicalQuantity::operator >(const CPhysicalQuantity &other) const { - if (this == &otherQuantity) return false; - return otherQuantity < (*this); + if (this == &other) return false; + return other < *this; } /* * Greater / Equal */ -template bool CPhysicalQuantity::operator >=(const CPhysicalQuantity &otherQuantity) const +template bool CPhysicalQuantity::operator >=(const CPhysicalQuantity &other) const { - if (this == &otherQuantity) return true; - return !(*this < otherQuantity); + if (this == &other) return true; + return !(*this < other); } /* * Less equal */ -template bool CPhysicalQuantity::operator <=(const CPhysicalQuantity &otherQuantity) const +template bool CPhysicalQuantity::operator <=(const CPhysicalQuantity &other) const { - if (this == &otherQuantity) return true; - return !(*this > otherQuantity); + if (this == &other) return true; + return !(*this > other); } /* @@ -399,7 +393,6 @@ template double CPhysicalQuantity::convertedSiValue return this->m_conversionSiUnit.valueRounded(this->m_convertedSiUnitValueD, digits); } - // see here for the reason of thess forward instantiations // http://www.parashift.com/c++-faq/separate-template-class-defn-from-decl.html template class CPhysicalQuantity; diff --git a/src/blackmisc/pqphysicalquantity.h b/src/blackmisc/pqphysicalquantity.h index fb832e952..18aefe77e 100644 --- a/src/blackmisc/pqphysicalquantity.h +++ b/src/blackmisc/pqphysicalquantity.h @@ -19,13 +19,12 @@ namespace BlackMisc { namespace PhysicalQuantities { + /*! * \brief A physical quantity such as "5m", "20s", "1500ft/s" */ - template class CPhysicalQuantity : public BlackMisc::CBaseStreamStringifier { - private: double m_unitValueD; //!< value backed by double qint32 m_unitValueI; //!< value backed by integer, allows sole integer arithmetic @@ -71,7 +70,7 @@ protected: CPhysicalQuantity(double baseValue, const MU &unit, const MU &siConversionUnit); /*! - * \brief Name as stringification + * \brief Name as string * \param i18n * \return */ @@ -101,9 +100,9 @@ protected: public: /*! * \brief Copy constructor - * \param otherQuantity + * \param other */ - CPhysicalQuantity(const CPhysicalQuantity &otherQuantity); + CPhysicalQuantity(const CPhysicalQuantity &other); /*! * \brief Virtual destructor @@ -305,12 +304,12 @@ public: /*! * \brief Operator to support commutative multiplication * \param factor - * \param otherQuantity + * \param other * \return */ - friend PQ operator *(double factor, const PQ &otherQuantity) + friend PQ operator *(double factor, const PQ &other) { - return otherQuantity * factor; + return other * factor; } /*! @@ -322,80 +321,80 @@ public: /*! * \brief Equal operator == - * \param otherQuantity + * \param other * \return */ - bool operator==(const CPhysicalQuantity &otherQuantity) const; + bool operator==(const CPhysicalQuantity &other) const; /*! * \brief Not equal operator != - * \param otherQuantity + * \param other * \return */ - bool operator!=(const CPhysicalQuantity &otherQuantity) const; + bool operator!=(const CPhysicalQuantity &other) const; /*! * \brief Plus operator += - * \param otherQuantity + * \param other * \return */ - CPhysicalQuantity &operator +=(const CPhysicalQuantity &otherQuantity); + CPhysicalQuantity &operator +=(const CPhysicalQuantity &other); /*! * \brief Minus operator-= - * \param otherQuantity + * \param other * \return */ - CPhysicalQuantity &operator -=(const CPhysicalQuantity &otherQuantity); + CPhysicalQuantity &operator -=(const CPhysicalQuantity &other); /*! * \brief Greater operator > - * \param otherQuantity + * \param other * \return */ - bool operator >(const CPhysicalQuantity &otherQuantity) const; + bool operator >(const CPhysicalQuantity &other) const; /*! * \brief Less operator < - * \param otherQuantity + * \param other * \return */ - bool operator <(const CPhysicalQuantity &otherQuantity) const; + bool operator <(const CPhysicalQuantity &other) const; /*! * \brief Less equal operator <= - * \param otherQuantity + * \param other * \return */ - bool operator <=(const CPhysicalQuantity &otherQuantity) const; + bool operator <=(const CPhysicalQuantity &other) const; /*! * \brief Greater equal operator >= - * \param otherQuantity + * \param other * \return */ - bool operator >=(const CPhysicalQuantity &otherQuantity) const; + bool operator >=(const CPhysicalQuantity &other) const; /*! * \brief Assignment operator = - * \param otherQuantity + * \param other * \return */ - CPhysicalQuantity &operator =(const CPhysicalQuantity &otherQuantity); + CPhysicalQuantity &operator =(const CPhysicalQuantity &other); /*! * \brief Plus operator + - * \param otherQuantity + * \param other * \return */ - PQ operator +(const PQ &otherQuantity) const; + PQ operator +(const PQ &other) const; /*! * \brief Minus operator - - * \param otherQuantity + * \param other * \return */ - PQ operator -(const PQ &otherQuantity) const; + PQ operator -(const PQ &other) const; /*! * \brief Quantity value <= epsilon @@ -429,7 +428,8 @@ public: * \brief Stream to DBus << * \param argument */ - virtual void marshallToDbus(QDBusArgument &argument) const { + virtual void marshallToDbus(QDBusArgument &argument) const + { argument << this->m_unitValueD; argument << this->m_unitValueI; argument << this->m_convertedSiUnitValueD; @@ -442,7 +442,8 @@ public: * \brief Stream from DBus >> * \param argument */ - virtual void unmarshallFromDbus(const QDBusArgument &argument) { + virtual void unmarshallFromDbus(const QDBusArgument &argument) + { argument >> this->m_unitValueD; argument >> this->m_unitValueI; argument >> this->m_convertedSiUnitValueD; @@ -463,7 +464,6 @@ public: qDBusRegisterMetaType(); qDBusRegisterMetaType>(); } - }; } // namespace diff --git a/src/blackmisc/pqpressure.h b/src/blackmisc/pqpressure.h index 3cfd5fbdb..660f1451a 100644 --- a/src/blackmisc/pqpressure.h +++ b/src/blackmisc/pqpressure.h @@ -24,27 +24,32 @@ public: * \brief Default constructor */ CPressure() : CPhysicalQuantity(0, CPressureUnit::Pa(), CPressureUnit::Pa()) {} + /** - *\brief Copy constructor + *\brief Copy constructor from base type */ - CPressure(const CPressure &pressure) : CPhysicalQuantity(pressure) {} + CPressure(const CPhysicalQuantity &base) : CPhysicalQuantity(base) {} + /*! * \brief Init by int value * \param value * \param unit */ CPressure(qint32 value, const CPressureUnit &unit) : CPhysicalQuantity(value, unit, CPressureUnit::Pa()) {} + /*! *\brief Init by double value * \param value * \param unit */ CPressure(double value, const CPressureUnit &unit) : CPhysicalQuantity(value, unit, CPressureUnit::Pa()) {} + /*! * \brief Virtual destructor */ virtual ~CPressure() {} }; + } // namespace } // namespace diff --git a/src/blackmisc/pqspeed.h b/src/blackmisc/pqspeed.h index e49dd3f2f..737b2f0d4 100644 --- a/src/blackmisc/pqspeed.h +++ b/src/blackmisc/pqspeed.h @@ -24,22 +24,26 @@ public: * \brief Default constructor */ CSpeed() : CPhysicalQuantity(0, CSpeedUnit::m_s(), CSpeedUnit::m_s()) {} + /*! - *\brief Copy constructor + *\brief Copy constructor from base type */ - CSpeed(const CSpeed &speed): CPhysicalQuantity(speed) {} + CSpeed(const CPhysicalQuantity &base): CPhysicalQuantity(base) {} + /*! * \brief Init by int value * \param value * \param unit */ CSpeed(qint32 value, const CSpeedUnit &unit) : CPhysicalQuantity(value, unit, CSpeedUnit::m_s()) {} + /*! *\brief Init by double value * \param value * \param unit */ CSpeed(double value, const CSpeedUnit &unit) : CPhysicalQuantity(value, unit, CSpeedUnit::m_s()) {} + /*! * \brief Destructor */ diff --git a/src/blackmisc/pqtemperature.h b/src/blackmisc/pqtemperature.h index bec623817..896b313d4 100644 --- a/src/blackmisc/pqtemperature.h +++ b/src/blackmisc/pqtemperature.h @@ -23,27 +23,32 @@ public: * \brief Default constructor */ CTemperature() : CPhysicalQuantity(0, CTemperatureUnit::K(), CTemperatureUnit::K()) {} + /** - *\brief Copy constructor + * \brief Copy constructor from base type */ - CTemperature(const CTemperature &temperature) : CPhysicalQuantity(temperature) {} + CTemperature(const CPhysicalQuantity &base) : CPhysicalQuantity(base) {} + /*! * \brief Init by int value * \param value * \param unit */ CTemperature(qint32 value, const CTemperatureUnit &unit): CPhysicalQuantity(value, unit, CTemperatureUnit::K()) {} + /*! - *\brief Init by double value + * \brief Init by double value * \param value * \param unit */ CTemperature(double value, const CTemperatureUnit &unit): CPhysicalQuantity(value, unit, CTemperatureUnit::K()) {} + /*! * \brief Destructor */ virtual ~CTemperature() {} }; + } // namespace } // namespace diff --git a/src/blackmisc/pqtime.h b/src/blackmisc/pqtime.h index 9641e8d45..62e78f115 100644 --- a/src/blackmisc/pqtime.h +++ b/src/blackmisc/pqtime.h @@ -24,27 +24,32 @@ public: * \brief Default constructor */ CTime() : CPhysicalQuantity(0, CTimeUnit::s(), CTimeUnit::s()) {} + /** - *\brief Copy constructor + *\brief Copy constructor from base type */ - CTime(const CPhysicalQuantity &time): CPhysicalQuantity(time) {} + CTime(const CPhysicalQuantity &base): CPhysicalQuantity(base) {} + /*! * \brief Init by int value * \param value * \param unit */ CTime(qint32 value, const CTimeUnit &unit) : CPhysicalQuantity(value, unit, CTimeUnit::s()) {} + /*! *\brief Init by double value * \param value * \param unit */ CTime(double value, const CTimeUnit &unit) : CPhysicalQuantity(value, unit, CTimeUnit::s()) {} + /*! * \brief Destructor */ virtual ~CTime() {} }; + } // namespace } // namespace diff --git a/src/blackmisc/pqunits.cpp b/src/blackmisc/pqunits.cpp index 90962792e..5973a3c10 100644 --- a/src/blackmisc/pqunits.cpp +++ b/src/blackmisc/pqunits.cpp @@ -82,7 +82,7 @@ QString CAngleUnit::toQStringRounded(double value, int digits, bool i18n) const } else { - s = CMeasurementUnit::toQStringRounded(value, digits); + s = this->CMeasurementUnit::toQStringRounded(value, digits); } return s; } diff --git a/src/blackmisc/pqunits.h b/src/blackmisc/pqunits.h index e70564413..c11350d76 100644 --- a/src/blackmisc/pqunits.h +++ b/src/blackmisc/pqunits.h @@ -29,7 +29,6 @@ namespace PhysicalQuantities */ class CLengthUnit : public CMeasurementUnit { - private: /*! * \brief Constructor length unit @@ -43,10 +42,7 @@ private: * \param epsilon */ CLengthUnit(const QString &name, const QString &unitName, bool isSiUnit, bool isSIBaseUnit, double conversionFactorToSI = 1.0, const CMeasurementPrefix &mulitplier = CMeasurementPrefix::One(), qint32 displayDigits = 2, double epsilon = 1E-9) : - CMeasurementUnit(name, unitName, "distance", isSiUnit, isSIBaseUnit, conversionFactorToSI, mulitplier, displayDigits, epsilon) - { - // void - } + CMeasurementUnit(name, unitName, "distance", isSiUnit, isSIBaseUnit, conversionFactorToSI, mulitplier, displayDigits, epsilon) {} public: /*! @@ -56,12 +52,9 @@ public: /*! * \brief Copy constructor - * \param otherUnit + * \param other */ - CLengthUnit(const CLengthUnit &otherUnit) : CMeasurementUnit(otherUnit) - { - // void - } + CLengthUnit(const CLengthUnit &other) : CMeasurementUnit(other) {} /*! * \brief Meter m @@ -74,7 +67,6 @@ public: QT_TRANSLATE_NOOP("CMeasurementUnit", "meter"); } - /*! * \brief Nautical miles NM * \return @@ -97,7 +89,6 @@ public: QT_TRANSLATE_NOOP("CMeasurementUnit", "foot"); } - /*! * \brief Kilometer km * \return @@ -164,9 +155,9 @@ public: * \param unitName must be valid! * \return */ - static const CLengthUnit &fromUnitName(const QString &unitName) { - QList units = CLengthUnit::units(); - // read only, avoid deep copy + static const CLengthUnit &fromUnitName(const QString &unitName) + { + const QList &units = CLengthUnit::units(); for (int i = 0; i < units.size(); ++i) { if (units.at(i).getUnitName() == unitName) return (units.at(i)); } @@ -179,7 +170,8 @@ protected: * \brief Stream from DBus * \param argument */ - virtual void unmarshallFromDbus(const QDBusArgument &argument) { + virtual void unmarshallFromDbus(const QDBusArgument &argument) + { QString unitName; argument >> unitName; (*this) = CLengthUnit::fromUnitName(unitName); @@ -207,16 +199,15 @@ private: const CMeasurementPrefix &multiplier = CMeasurementPrefix::One(), qint32 displayDigits = 2, double epsilon = 1E-9, UnitConverter converterToSi = 0, UnitConverter converterFromSi = 0) : CMeasurementUnit(name, unitName, "angle", isSiUnit, false, conversionFactorToSI, - multiplier, displayDigits, epsilon, converterToSi, converterFromSi) - { - // void - } + multiplier, displayDigits, epsilon, converterToSi, converterFromSi) {} + /*! * \brief Special conversion for sexagesimal degrees * \param value * \return */ static double conversionSexagesimalToSi(const CMeasurementUnit &angleUnit, double value); + /*! * \brief Special conversion for sexagesimal degrees * \param value @@ -226,15 +217,15 @@ private: public: /*! - * Default constructor, we do not want this, but required for Qt Metasystem + * Default constructor, required for Qt Metasystem */ CAngleUnit() : CMeasurementUnit("radian", "rad", "angle", true, false) {} /*! * \brief Copy constructor - * \param otherUnit + * \param other */ - CAngleUnit(const CAngleUnit &otherUnit) : CMeasurementUnit(otherUnit) { } + CAngleUnit(const CAngleUnit &other) : CMeasurementUnit(other) {} /*! * \brief Special conversion to QString for sexagesimal degrees. @@ -297,9 +288,9 @@ public: * \param unitName must be valid! * \return */ - static const CAngleUnit &fromUnitName(const QString &unitName) { - QList units = CAngleUnit::units(); - // read only, avoid deep copy + static const CAngleUnit &fromUnitName(const QString &unitName) + { + const QList &units = CAngleUnit::units(); for (int i = 0; i < units.size(); ++i) { if (units.at(i).getUnitName() == unitName) return (units.at(i)); } @@ -312,7 +303,8 @@ protected: * \brief Stream from DBus * \param argument */ - virtual void unmarshallFromDbus(const QDBusArgument &argument) { + virtual void unmarshallFromDbus(const QDBusArgument &argument) + { QString unitName; argument >> unitName; (*this) = CAngleUnit::fromUnitName(unitName); @@ -339,20 +331,18 @@ private: */ CFrequencyUnit(const QString &name, const QString &unitName, bool isSiUnit, double conversionFactorToSI = 1.0, const CMeasurementPrefix &mulitplier = CMeasurementPrefix::One(), qint32 displayDigits = 2, double epsilon = 1E-9) : CMeasurementUnit(name, unitName, "frequency", isSiUnit, false, conversionFactorToSI, mulitplier, displayDigits, epsilon) {} + public: /*! - * Default constructor, we do not want this, but required for Qt Metasystem + * Default constructor, required for Qt Metasystem */ CFrequencyUnit() : CMeasurementUnit("hertz", "Hz", "frequency", true, false) {} /*! * \brief Copy constructor - * \param otherUnit + * \param other */ - CFrequencyUnit(const CFrequencyUnit &otherUnit) : CMeasurementUnit(otherUnit) - { - // void - } + CFrequencyUnit(const CFrequencyUnit &other) : CMeasurementUnit(other) {} /*! * \brief Hertz @@ -413,9 +403,9 @@ public: * \param unitName must be valid! * \return */ - static const CFrequencyUnit &fromUnitName(const QString &unitName) { - QList units = CFrequencyUnit::units(); - // read only, avoid deep copy + static const CFrequencyUnit &fromUnitName(const QString &unitName) + { + const QList &units = CFrequencyUnit::units(); for (int i = 0; i < units.size(); ++i) { if (units.at(i).getUnitName() == unitName) return (units.at(i)); } @@ -428,7 +418,8 @@ protected: * \brief Stream from DBus * \param argument */ - virtual void unmarshallFromDbus(const QDBusArgument &argument) { + virtual void unmarshallFromDbus(const QDBusArgument &argument) + { QString unitName; argument >> unitName; (*this) = CFrequencyUnit::fromUnitName(unitName); @@ -455,20 +446,18 @@ private: */ CMassUnit(const QString &name, const QString &unitName, bool isSiUnit, bool isSIBaseUnit, double conversionFactorToSI = 1.0, const CMeasurementPrefix &mulitplier = CMeasurementPrefix::One(), qint32 displayDigits = 2, double epsilon = 1E-9) : CMeasurementUnit(name, unitName, "mass", isSiUnit, isSIBaseUnit, conversionFactorToSI, mulitplier, displayDigits, epsilon) {} + public: /*! - * Default constructor, we do not want this, but required for Qt Metasystem + * Default constructor, required for Qt Metasystem */ CMassUnit() : CMeasurementUnit("kilogram", "kg", "mass", true, true, 1.0, CMeasurementPrefix::k(), 1) {} /*! * \brief Copy constructor - * \param otherUnit + * \param other */ - CMassUnit(const CMassUnit &otherUnit) : CMeasurementUnit(otherUnit) - { - // void - } + CMassUnit(const CMassUnit &other) : CMeasurementUnit(other) {} /*! * \brief Kilogram, SI base unit @@ -533,9 +522,9 @@ public: * \param unitName must be valid! * \return */ - static const CMassUnit &fromUnitName(const QString &unitName) { - QList units = CMassUnit::units(); - // read only, avoid deep copy + static const CMassUnit &fromUnitName(const QString &unitName) + { + const QList &units = CMassUnit::units(); for (int i = 0; i < units.size(); ++i) { if (units.at(i).getUnitName() == unitName) return (units.at(i)); } @@ -548,12 +537,12 @@ protected: * \brief Stream from DBus * \param argument */ - virtual void unmarshallFromDbus(const QDBusArgument &argument) { + virtual void unmarshallFromDbus(const QDBusArgument &argument) + { QString unitName; argument >> unitName; (*this) = CMassUnit::fromUnitName(unitName); } - }; Q_DECLARE_METATYPE(BlackMisc::PhysicalQuantities::CMassUnit) @@ -576,20 +565,18 @@ private: */ CPressureUnit(const QString &name, const QString &unitName, bool isSiUnit, double conversionFactorToSI = 1.0, const CMeasurementPrefix &mulitplier = CMeasurementPrefix::One(), qint32 displayDigits = 2, double epsilon = 1E-9) : CMeasurementUnit(name, unitName, "pressure", isSiUnit, false, conversionFactorToSI, mulitplier, displayDigits, epsilon) {} + public: /*! - * Default constructor, we do not want this, but required for Qt Metasystem + * Default constructor, required for Qt Metasystem */ CPressureUnit() : CMeasurementUnit("pascal", "Pa", "pressure", true, false) {} /*! * \brief Copy constructor - * \param otherUnit + * \param other */ - CPressureUnit(const CPressureUnit &otherUnit) : CMeasurementUnit(otherUnit) - { - // void - } + CPressureUnit(const CPressureUnit &other) : CMeasurementUnit(other) {} /*! * \brief Pascal @@ -689,9 +676,9 @@ public: * \param unitName must be valid! * \return */ - static const CPressureUnit &fromUnitName(const QString &unitName) { - QList units = CPressureUnit::units(); - // read only, avoid deep copy + static const CPressureUnit &fromUnitName(const QString &unitName) + { + const QList &units = CPressureUnit::units(); for (int i = 0; i < units.size(); ++i) { if (units.at(i).getUnitName() == unitName) return (units.at(i)); } @@ -704,7 +691,8 @@ protected: * \brief Stream from DBus * \param argument */ - virtual void unmarshallFromDbus(const QDBusArgument &argument) { + virtual void unmarshallFromDbus(const QDBusArgument &argument) + { QString unitName; argument >> unitName; (*this) = CPressureUnit::fromUnitName(unitName); @@ -719,6 +707,7 @@ class CTemperatureUnit : public CMeasurementUnit { private: double m_conversionOffsetToSi; + private: /*! * Constructor temperature unit @@ -734,6 +723,7 @@ private: */ CTemperatureUnit(const QString &name, const QString &unitName, bool isSiUnit, bool isSIBaseUnit, double conversionFactorToSI = 1.0, double temperatureOffsetToSI = 0, const CMeasurementPrefix &mulitplier = CMeasurementPrefix::One(), qint32 displayDigits = 2, double epsilon = 1E-9) : CMeasurementUnit(name, unitName, "temperature", isSiUnit, isSIBaseUnit, conversionFactorToSI, mulitplier, displayDigits, epsilon), m_conversionOffsetToSi(temperatureOffsetToSI) {} + protected: /*! * \brief Convert to SI conversion unit, specific for temperature @@ -751,25 +741,25 @@ protected: public: /*! - * Default constructor, we do not want this, but required for Qt Metasystem + * Default constructor, required for Qt Metasystem */ CTemperatureUnit() : CMeasurementUnit("Kelvin", "K", "temperature", true, true) {} /*! * \brief Copy constructor - * \param otherUnit + * \param other */ - CTemperatureUnit(const CTemperatureUnit &otherUnit) : CMeasurementUnit(otherUnit), m_conversionOffsetToSi(otherUnit.m_conversionOffsetToSi) {} + CTemperatureUnit(const CTemperatureUnit &other) : CMeasurementUnit(other), m_conversionOffsetToSi(other.m_conversionOffsetToSi) {} /*! * Assigment operator */ - CTemperatureUnit &operator =(const CTemperatureUnit &otherUnit) + CTemperatureUnit &operator =(const CTemperatureUnit &other) { - if (this == &otherUnit) return *this; // Same object? Yes, so skip assignment, and just return *this - CMeasurementUnit::operator = (otherUnit); - this->m_conversionOffsetToSi = otherUnit.m_conversionOffsetToSi; - return (*this); + if (this == &other) return *this; + CMeasurementUnit::operator = (other); + this->m_conversionOffsetToSi = other.m_conversionOffsetToSi; + return *this; } /*! @@ -825,9 +815,9 @@ public: * \param unitName must be valid! * \return */ - static const CTemperatureUnit &fromUnitName(const QString &unitName) { - QList units = CTemperatureUnit::units(); - // read only, avoid deep copy + static const CTemperatureUnit &fromUnitName(const QString &unitName) + { + const QList &units = CTemperatureUnit::units(); for (int i = 0; i < units.size(); ++i) { if (units.at(i).getUnitName() == unitName) return (units.at(i)); } @@ -840,7 +830,8 @@ protected: * \brief Stream from DBus * \param argument */ - virtual void unmarshallFromDbus(const QDBusArgument &argument) { + virtual void unmarshallFromDbus(const QDBusArgument &argument) + { QString unitName; argument >> unitName; (*this) = CTemperatureUnit::fromUnitName(unitName); @@ -868,17 +859,18 @@ private: */ CSpeedUnit(const QString &name, const QString &unitName, bool isSiUnit, bool isSIBaseUnit, double conversionFactorToSI = 1.0, const CMeasurementPrefix &mulitplier = CMeasurementPrefix::One(), qint32 displayDigits = 2, double epsilon = 1E-9) : CMeasurementUnit(name, unitName, "speed", isSiUnit, isSIBaseUnit, conversionFactorToSI, mulitplier, displayDigits, epsilon) {} + public: /*! - * Default constructor, we do not want this, but required for Qt Metasystem + * Default constructor, required for Qt Metasystem */ CSpeedUnit() : CMeasurementUnit("meters/second", "m/s", "speed", true, false) {} /*! * Constructor, allows to implement methods in base class - * \param otherUnit + * \param other */ - CSpeedUnit(const CSpeedUnit &otherUnit) : CMeasurementUnit(otherUnit) {} + CSpeedUnit(const CSpeedUnit &other) : CMeasurementUnit(other) {} /*! * \brief Meter/second m/s @@ -967,9 +959,9 @@ public: * \param unitName must be valid! * \return */ - static const CSpeedUnit &fromUnitName(const QString &unitName) { - QList units = CSpeedUnit::units(); - // read only, avoid deep copy + static const CSpeedUnit &fromUnitName(const QString &unitName) + { + const QList &units = CSpeedUnit::units(); for (int i = 0; i < units.size(); ++i) { if (units.at(i).getUnitName() == unitName) return (units.at(i)); } @@ -982,7 +974,8 @@ protected: * \brief Stream from DBus * \param argument */ - virtual void unmarshallFromDbus(const QDBusArgument &argument) { + virtual void unmarshallFromDbus(const QDBusArgument &argument) + { QString unitName; argument >> unitName; (*this) = CSpeedUnit::fromUnitName(unitName); @@ -1010,17 +1003,18 @@ private: */ CTimeUnit(const QString &name, const QString &unitName, bool isSiUnit, bool isSIBaseUnit, double conversionFactorToSI = 1.0, const CMeasurementPrefix &mulitplier = CMeasurementPrefix::One(), qint32 displayDigits = 2, double epsilon = 1E-9) : CMeasurementUnit(name, unitName, "time", isSiUnit, isSIBaseUnit, conversionFactorToSI, mulitplier, displayDigits, epsilon) {} + public: /*! - * Default constructor, we do not want this, but required for Qt Metasystem + * Default constructor, required for Qt Metasystem */ CTimeUnit() : CMeasurementUnit("second", "s", "time", true, true, 1, CMeasurementPrefix::None()) {} /*! * Constructor, allows to implement methods in base class - * \param otherUnit + * \param other */ - CTimeUnit(const CTimeUnit &otherUnit) : CMeasurementUnit(otherUnit) {} + CTimeUnit(const CTimeUnit &other) : CMeasurementUnit(other) {} /*! * \brief Second s @@ -1097,9 +1091,9 @@ public: * \param unitName must be valid! * \return */ - static const CTimeUnit &fromUnitName(const QString &unitName) { - QList units = CTimeUnit::units(); - // read only, avoid deep copy + static const CTimeUnit &fromUnitName(const QString &unitName) + { + const QList &units = CTimeUnit::units(); for (int i = 0; i < units.size(); ++i) { if (units.at(i).getUnitName() == unitName) return (units.at(i)); } @@ -1112,7 +1106,8 @@ protected: * \brief Stream from DBus * \param argument */ - virtual void unmarshallFromDbus(const QDBusArgument &argument) { + virtual void unmarshallFromDbus(const QDBusArgument &argument) + { QString unitName; argument >> unitName; (*this) = CTimeUnit::fromUnitName(unitName); @@ -1140,17 +1135,18 @@ private: */ CAccelerationUnit(const QString &name, const QString &unitName, bool isSiUnit, bool isSIBaseUnit, double conversionFactorToSI = 1.0, const CMeasurementPrefix &mulitplier = CMeasurementPrefix::One(), qint32 displayDigits = 2, double epsilon = 1E-9) : CMeasurementUnit(name, unitName, "acceleration", isSiUnit, isSIBaseUnit, conversionFactorToSI, mulitplier, displayDigits, epsilon) {} + public: /*! - * Default constructor, we do not want this, but required for Qt Metasystem + * Default constructor, required for Qt Metasystem */ - CAccelerationUnit() : CMeasurementUnit("meter/second²", "m/s^2", "acceleration", true, false, 1, CMeasurementPrefix::None(), 1) {} + CAccelerationUnit() : CMeasurementUnit("meter/second^2", "m/s^2", "acceleration", true, false, 1, CMeasurementPrefix::None(), 1) {} /*! * Constructor, allows to implement methods in base class - * \param otherUnit + * \param other */ - CAccelerationUnit(const CAccelerationUnit &otherUnit) : CMeasurementUnit(otherUnit) {} + CAccelerationUnit(const CAccelerationUnit &other) : CMeasurementUnit(other) {} /*! * \brief Meter/second^2 (m/s^2) @@ -1193,9 +1189,9 @@ public: * \param unitName must be valid! * \return */ - static const CAccelerationUnit &fromUnitName(const QString &unitName) { - QList units = CAccelerationUnit::units(); - // read only, avoid deep copy + static const CAccelerationUnit &fromUnitName(const QString &unitName) + { + const QList &units = CAccelerationUnit::units(); for (int i = 0; i < units.size(); ++i) { if (units.at(i).getUnitName() == unitName) return (units.at(i)); } @@ -1208,7 +1204,8 @@ protected: * \brief Stream from DBus * \param argument */ - virtual void unmarshallFromDbus(const QDBusArgument &argument) { + virtual void unmarshallFromDbus(const QDBusArgument &argument) + { QString unitName; argument >> unitName; (*this) = CAccelerationUnit::fromUnitName(unitName); @@ -1216,7 +1213,6 @@ protected: }; Q_DECLARE_METATYPE(BlackMisc::PhysicalQuantities::CAccelerationUnit) - } // namespace } // namespace #endif // guard