LCOV - code coverage report
Current view: top level - atmosphere/ATM - ATMNumberDensity.h (source / functions) Hit Total Coverage
Test: casacpp_coverage.info Lines: 2 2 100.0 %
Date: 2024-10-10 15:00:01 Functions: 2 2 100.0 %

          Line data    Source code
       1             : #ifndef _ATM_NUMBERDENSITY_H
       2             : #define _ATM_NUMBERDENSITY_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: ATMNumberDensity.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             : 
      39             : /*! \brief Number Density value with units
      40             :  *
      41             :  *   This class defines physical parameters having units of Number Density.
      42             :  *   For example, the profiles of minor gases, such as O3, are in number density.
      43             :  *   Default is m**-3 (International System).
      44             :  */
      45             : class NumberDensity
      46             : {
      47             :  public:
      48             :   enum Units {
      49             :     UnitInverseCubicCentiMeter,
      50             :     UnitInverseCubicMeter,
      51             :     NumNumberDensityUnits
      52             :   };
      53             : 
      54             :   /** Default constructor */
      55             :   NumberDensity();
      56             :   /** A full constructor: Number Density value assumed by default to be in m**-3 (International System) */
      57             :   NumberDensity(double numberdensity);
      58             :   /** A full constructor: Number Density value + unit. Valid units are m**-3 [M**-3], cm**-3 [CM**-3].
      59             :    *  If none of these implented units is given, the SI value will be returned. */
      60             :   NumberDensity(double numberdensity, const string &units);
      61             :   NumberDensity(double numberdensity, Units units);
      62             : 
      63             :   /** Destructor */
      64             :   virtual ~NumberDensity();
      65             : 
      66             :   /** Accessor to the numberdensity value in International System units (K) */
      67             :   double get() const { return valueIS_; }
      68             :   /** Accessor to the numberdensity value in specified units. Valid units are K [k], mK [mk], and C [c] */
      69             :   double get(const string &units) const;
      70             :   double get(const Units units) const;
      71             : 
      72       15180 :   NumberDensity& operator=(const NumberDensity &rhs) { if(&rhs != this) valueIS_ = rhs.valueIS_; return *this; }
      73             :   NumberDensity& operator=(const double &rhs) { valueIS_ = rhs; return *this; }
      74             :   NumberDensity operator+(const NumberDensity &rhs) { return NumberDensity(valueIS_ + rhs.get()); }
      75             :   NumberDensity operator-(const NumberDensity &rhs) { return NumberDensity(valueIS_ - rhs.get()); }
      76        2530 :   NumberDensity operator*(double scf) { return NumberDensity(valueIS_ * scf); }
      77             :   NumberDensity operator*(float scf) { return NumberDensity(valueIS_ * (double) scf); }
      78             :   NumberDensity operator*(int scf) { return NumberDensity(valueIS_ * (double) scf); }
      79             :   NumberDensity operator*(unsigned int scf) { return NumberDensity(valueIS_ * (double) scf); }
      80             :   NumberDensity operator/(double scf) { return NumberDensity(valueIS_ / scf); }
      81             :   NumberDensity operator/(float scf) { return NumberDensity(valueIS_ / (double) scf); }
      82             :   NumberDensity operator/(int scf) { return NumberDensity(valueIS_ / (double) scf); }
      83             :   NumberDensity operator/(unsigned int scf) { return NumberDensity(valueIS_ / (double) scf); }
      84             :   bool operator<(const NumberDensity &rhs) const { return (valueIS_ < rhs.get()); }
      85             :   bool operator>(const NumberDensity &rhs) const { return (valueIS_ > rhs.get()); }
      86             :   bool operator<=(const NumberDensity &rhs) const { return (valueIS_ <= rhs.get()); }
      87             :   bool operator>=(const NumberDensity &rhs) const { return (valueIS_ >= rhs.get()); }
      88             :   bool operator==(const NumberDensity &rhs) const { return (valueIS_ == rhs.get()); }
      89             :   bool operator!=(const NumberDensity &rhs) const { return (valueIS_ != rhs.get()); }
      90             : 
      91             :  private:
      92             :   double valueIS_;
      93             : }; // class NumberDensity
      94             : 
      95             : ATM_NAMESPACE_END
      96             : 
      97             : #endif /*!_ATM_NUMBERDENSITY_H*/
      98             : 
      99             : 

Generated by: LCOV version 1.16