mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-21 04:45:31 +08:00
Changed PQ to template, removed unit default values, checked unit tests
This commit is contained in:
@@ -5,111 +5,37 @@
|
||||
|
||||
namespace BlackMisc {
|
||||
|
||||
/*!
|
||||
* Specialized class for pressure (psi, hPa, bar).
|
||||
* \author KWB
|
||||
*/
|
||||
class CPressureUnit : public CMeasurementUnit {
|
||||
friend class CPressure;
|
||||
private:
|
||||
/*!
|
||||
* Downcast copy constructor, allows to implement methods in base class
|
||||
* and cast unit
|
||||
* \param otherUnit
|
||||
*/
|
||||
CPressureUnit(const CMeasurementUnit &otherUnit) : CMeasurementUnit(otherUnit) {}
|
||||
public:
|
||||
/*!
|
||||
* Constructor
|
||||
* \brief Pressure unit
|
||||
* \param name
|
||||
* \param unitName
|
||||
* \param isSIUnit
|
||||
* \param conversionFactorToSI
|
||||
* \param mulitplier
|
||||
* \param displayDigits
|
||||
* \param epsilon
|
||||
*/
|
||||
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, "frequency", isSIUnit, false, conversionFactorToSI, mulitplier, displayDigits, epsilon) {}
|
||||
/*!
|
||||
* \brief Pascal
|
||||
* \return
|
||||
*/
|
||||
static const CPressureUnit& Pa() { static CPressureUnit Pa("pascal", "Pa", true); return Pa;}
|
||||
/*!
|
||||
* \brief Hectopascal
|
||||
* \return
|
||||
*/
|
||||
static const CPressureUnit& hPa() { static CPressureUnit hPa("hectopascal", "hPa", true, CMeasurementPrefix::h().getFactor(), CMeasurementPrefix::h()); return hPa;}
|
||||
/*!
|
||||
* \brief Pounds per square inch
|
||||
* \return
|
||||
*/
|
||||
static const CPressureUnit& psi() { static CPressureUnit psi("pounds per square inch", "psi", false, 6894.8, CMeasurementPrefix::One(), 2); return psi;}
|
||||
/*!
|
||||
* \brief Bar
|
||||
* \return
|
||||
*/
|
||||
static const CPressureUnit& bar() { static CPressureUnit bar("bar", "bar", false, 1E5);return bar;}
|
||||
/*!
|
||||
* \brief Millibar, actually the same as hPa
|
||||
* \return
|
||||
*/
|
||||
static const CPressureUnit& mbar() { static CPressureUnit bar("bar", "bar", false, 1E2);return bar;}
|
||||
/*!
|
||||
* \brief Inch of mercury at 0°C
|
||||
* \return
|
||||
*/
|
||||
static const CPressureUnit& inHg() { static CPressureUnit inhg("Inch of mercury 0°C", "inHg", false, 3386.389);return inhg;}
|
||||
/*!
|
||||
* \brief Inch of mercury for flight level 29,92inHg = 1013,25mbar = 1013,25hPa
|
||||
* \return
|
||||
*/
|
||||
static const CPressureUnit& inHgFL() { static CPressureUnit inhg("Inch of mercury ", "inHg", false, 3386.5307486631);return inhg;}
|
||||
};
|
||||
|
||||
/*!
|
||||
* \brief Physical unit distance
|
||||
* \author KWB
|
||||
*/
|
||||
class CPressure : public CPhysicalQuantity
|
||||
class CPressure : public CPhysicalQuantity<CPressureUnit,CPressure>
|
||||
{
|
||||
public:
|
||||
/*!
|
||||
* \brief Default constructor
|
||||
*/
|
||||
CPressure();
|
||||
CPressure() : CPhysicalQuantity(0, CPressureUnit::Pa(), CPressureUnit::Pa()){}
|
||||
/**
|
||||
*\brief downcast copy constructor
|
||||
*\brief Copy constructor
|
||||
*/
|
||||
CPressure(const CPhysicalQuantity &frequency);
|
||||
CPressure(const CPressure &pressure) : CPhysicalQuantity(pressure) {}
|
||||
/*!
|
||||
* \brief Init by int value
|
||||
* \param value
|
||||
* \param unit
|
||||
*/
|
||||
CPressure(qint32 value, const CPressureUnit &unit = CPressureUnit::Pa());
|
||||
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 = CPressureUnit::Pa());
|
||||
CPressure(double value, const CPressureUnit &unit) : CPhysicalQuantity(value, unit, CPressureUnit::Pa()){}
|
||||
/*!
|
||||
* \brief Virtual destructor
|
||||
*/
|
||||
virtual ~CPressure();
|
||||
/*!
|
||||
* \brief Unit of the distance
|
||||
* \return
|
||||
*/
|
||||
CPressureUnit getUnit() const { return this->_pUnit; }
|
||||
/*!
|
||||
* \brief Conversion SI unit
|
||||
* \return
|
||||
*/
|
||||
CPressureUnit getConversionSiUnit() const { return this->_pConversionSiUnit; }
|
||||
virtual ~CPressure() {}
|
||||
};
|
||||
} // namespace blackCore
|
||||
} // namespace
|
||||
#endif // PQPRESSURE_H
|
||||
|
||||
Reference in New Issue
Block a user