LCOV - code coverage report
Current view: top level - atmosphere/ATM - ATMPressure.h (source / functions) Hit Total Coverage
Test: ctest_coverage.info Lines: 2 4 50.0 %
Date: 2023-11-02 14:27:30 Functions: 2 4 50.0 %

          Line data    Source code
       1             : #ifndef _ATM_PRESSURE_H
       2             : #define _ATM_PRESSURE_H
       3             : /*******************************************************************************
       4             :  * ALMA - Atacama Large Millimiter Array
       5             :  * (c) Instituto de Estructura de la Materia, 2009
       6             :  *
       7             :  * This library is free software; you can redistribute it and/or
       8             :  * modify it under the terms of the GNU Lesser General Public
       9             :  * License as published by the Free Software Foundation; either
      10             :  * version 2.1 of the License, or (at your option) any later version.
      11             :  *
      12             :  * This library is distributed in the hope that it will be useful,
      13             :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      14             :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
      15             :  * Lesser General Public License for more details.
      16             :  *
      17             :  * You should have received a copy of the GNU Lesser General Public
      18             :  * License along with this library; if not, write to the Free Software
      19             :  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
      20             :  *
      21             :  * "@(#) $Id: ATMPressure.h Exp $"
      22             :  *
      23             :  * who       when      what
      24             :  * --------  --------  ----------------------------------------------
      25             :  * pardo     24/03/09  created
      26             :  */
      27             : 
      28             : #ifndef __cplusplus
      29             : #error "This is a C++ include file and cannot be used from plain C"
      30             : #endif
      31             : 
      32             : #include "ATMCommon.h"
      33             : #include <string>
      34             : 
      35             : using std::string;
      36             : 
      37             : ATM_NAMESPACE_BEGIN
      38             : /*! \brief Defines pressure with units
      39             :  *
      40             :  *   This class defines physical parameters having units of Pressure.
      41             :  *   Default is Pa (International System) but the ATM library uses mb (hPa).
      42             :  */
      43             : class Pressure
      44             : {
      45             : public:
      46             :   enum Units {
      47             :     UnitPascal,
      48             :     UnitHectoPascal,
      49             :     UnitBar,
      50             :     UnitMilliBar,
      51             :     UnitAtmosphere,
      52             :     NumPressureUnits
      53             :   };
      54             : 
      55             :   /** Default constructor */
      56             :   Pressure();
      57             :   /** A full constructor: Pressure value in default SI units (Pa) */
      58             :   Pressure(double pressure);
      59             :   /** A full constructor: Pressure value + units. Valid units are hPa [HPA] [hpa], bar [BAR], mb [MB], mbar [MBAR], atm [ATM]. */
      60             :   Pressure(double pressure, const string &units);
      61             :   Pressure(double pressure, Units units);
      62             : 
      63             :   /** Destructor */
      64             :   virtual ~Pressure();
      65             : 
      66             :   /** Accessor to get the value in SI units (Pa) */
      67         360 :   double get() const { return valueIS_; }
      68             :   /** Accessor to get the value in the following (implemented) units: hPa [HPA] [hpa], bar [BAR], mb [MB], mbar [MBAR], atm [ATM].
      69             :    * If none of these implemented units is given, the SI value will be returned. */
      70             :   double get(const string &units) const;
      71             :   double get(Units units) const;
      72             : 
      73         158 :    Pressure& operator=(const Pressure &rhs) { if(&rhs != this) valueIS_ = rhs.valueIS_; return *this; }
      74           0 :    Pressure& operator=(double rhs) { valueIS_ = rhs; return *this; }
      75           0 :    Pressure operator+(const Pressure &rhs) { return Pressure(valueIS_ + rhs.get()); }
      76             :    Pressure operator-(const Pressure &rhs) { return Pressure(valueIS_ - rhs.get()); }
      77             :    Pressure operator*(double scf) { return Pressure(valueIS_ * scf); }
      78             :    Pressure operator*(float scf) { return Pressure(valueIS_ * (double) scf); }
      79             :    Pressure operator*(int scf) { return Pressure(valueIS_ * (double) scf); }
      80             :    Pressure operator*(unsigned int scf) { return Pressure(valueIS_ * (double) scf); }
      81             :    Pressure operator/(double scf) { return Pressure(valueIS_ / scf); }
      82             :    Pressure operator/(float scf) { return Pressure(valueIS_ / (double) scf); }
      83             :    Pressure operator/(int scf) { return Pressure(valueIS_ / (double) scf); }
      84             :    Pressure operator/(unsigned int scf) { return Pressure(valueIS_ / (double) scf); }
      85             :    bool operator<(const Pressure &rhs) const { return (valueIS_ < rhs.get()); }
      86             :    bool operator>(const Pressure &rhs) const { return (valueIS_ > rhs.get()); }
      87             :    bool operator<=(const Pressure &rhs) const { return (valueIS_ <= rhs.get()); }
      88             :    bool operator>=(const Pressure &rhs) const { return (valueIS_ >= rhs.get()); }
      89             :    bool operator==(const Pressure &rhs) const { return (valueIS_ == rhs.get()); }
      90             :    bool operator!=(const Pressure &rhs) const { return (valueIS_ != rhs.get()); }
      91             : 
      92             : private:
      93             :   double valueIS_;
      94             : }; // class Pressure
      95             : 
      96             : ATM_NAMESPACE_END
      97             : 
      98             : #endif /*!_ATM_PRESSURE_H*/
      99             : 

Generated by: LCOV version 1.16