LCOV - code coverage report
Current view: top level - atmosphere/ATM - ATMInverseLength.h (source / functions) Hit Total Coverage
Test: casacpp_coverage.info Lines: 1 1 100.0 %
Date: 2024-10-29 13:38:20 Functions: 1 1 100.0 %

          Line data    Source code
       1             : #ifndef _ATM_INVERSELENGTH_H
       2             : #define _ATM_INVERSELENGTH_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: ATMInverseLength.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             : 
      36             : 
      37             : ATM_NAMESPACE_BEGIN
      38             : /*! \brief Class for those physical parameters having dimensions of Inverse Length [L^-1]
      39             :  *
      40             :  *   This class is defined for those physical parameters that have units of Inverse Length, for example
      41             :  *   the absorption coefficients. Desfault units are m^-1 (International System).
      42             :  */
      43             : class InverseLength
      44             : {
      45             : public:
      46             :   enum Units {
      47             :     UnitInverseMeter,
      48             :     UnitInverseKiloMeter,
      49             :     UnitInverseMilliMeter,
      50             :     UnitInverseMicron,
      51             :     UnitInverseNanoMeter,
      52             :     NumInverseLengthUnits
      53             :   };
      54             : 
      55             :   /** Default constructor: Length value set to 0 m^-1 */
      56             :   InverseLength();
      57             :   /** A full constructor: value in default units (m^-1) */
      58             :   InverseLength(double inverseLength);
      59             :   /** A full constructor: value + units. Valid units are:  km-1 [KM-1], m-1 [M-1], mm-1 [MM-1], micron-1 [MICRON-1], nm-1 [NM-1]. */
      60             :   InverseLength(double inverseLength, const std::string &units);
      61             :   InverseLength(double inverseLength, Units units);
      62             :   /** Copy constructor */
      63             :   InverseLength (const InverseLength &inverseLength);
      64             : 
      65             :   /** Destructor */
      66             :   virtual ~InverseLength();
      67             : 
      68             :   /** Accessor to get the numerical value of inverse length (in International System units: m^-1) */
      69         840 :   inline double get() const { return valueIS_; }
      70             :   /** Accessor to the inverse length value in specified units. Implemented units are km-1 [KM-1], m-1 [M-1], mm-1 [MM-1], micron-1 [MICRON-1], nm-1 [NM-1].
      71             :    *  If none of these implemented units is given, the SI value will be returned. */
      72             :   inline double get(const std::string &units) const { return sget(valueIS_, units); }
      73             :   inline double get(Units units) const { return sget(valueIS_, units); }
      74             : 
      75             :   /** Operator "equal to a InverseLength" */
      76             :   inline InverseLength& operator=(const InverseLength &rhs) { if(&rhs != this) valueIS_ = rhs.valueIS_; return *this; }
      77             :   /** Operator "equal to a double converted to InverseLength in m-1" */
      78             :   inline InverseLength& operator=(double rhs) { valueIS_ = rhs; return *this; }
      79             :   /** Operator "addition of inverse lengths" */
      80             :   inline InverseLength operator+(const InverseLength &rhs) { return InverseLength(valueIS_ + rhs.get()); }
      81             :   /** Operator "substraction of inverse lengths" */
      82             :   inline InverseLength operator-(const InverseLength &rhs) { return InverseLength(valueIS_ - rhs.get()); }
      83             :   /** Operator "multiplication of a inverse length by a double" */
      84             :   inline InverseLength operator*(double scf) { return InverseLength(valueIS_ * scf); }
      85             :   /** Operator "multiplication of a inverse length by a float" */
      86             :   inline InverseLength operator*(float scf) { return InverseLength(valueIS_ * (double) scf); }
      87             :   /** Operator "multiplication of a inverse length by an int" */
      88             :   inline InverseLength operator*(int scf) { return InverseLength(valueIS_ * (double) scf); }
      89             :   /** Operator "multiplication of a inverse length by an unsigned int" */
      90             :   inline InverseLength operator*(unsigned int scf) { return InverseLength(valueIS_ * (double) scf); }
      91             :   /** Operator "division of a inverse length by a double" */
      92             :   inline InverseLength operator/(double scf) { return InverseLength(valueIS_ / scf); }
      93             :   /** Operator "division of a inverse length by a float" */
      94             :   inline InverseLength operator/(float scf) { return InverseLength(valueIS_ / (double) scf); }
      95             :   /** Operator "division of a inverse length by an int" */
      96             :   inline InverseLength operator/(int scf) { return InverseLength(valueIS_ / (double) scf); }
      97             :   /** Operator "division of a inverse length by an unsigned int" */
      98             :   inline InverseLength operator/(unsigned int scf) { return InverseLength(valueIS_ / (double) scf); }
      99             :   /** Operator "comparator < for two inverse lengths" */
     100             :   inline bool operator<(const InverseLength & rhs) const { return (valueIS_ < rhs.get()); }
     101             :   /** Operator "comparator > for two inverse lengths" */
     102             :   inline bool operator>(const InverseLength & rhs) const { return (valueIS_ > rhs.get()); }
     103             :   /** Operator "comparator <= for two inverse lengths" */
     104             :   inline bool operator<=(const InverseLength & rhs) const { return (valueIS_ <= rhs.get()); }
     105             :   /** Operator "comparator >= for two inverse lengths" */
     106             :   inline bool operator>=(const InverseLength & rhs) const { return (valueIS_ >= rhs.get()); }
     107             :   /** Operator "comparator == for two inverse lengths" */
     108             :   inline bool operator==(const InverseLength & rhs) const { return (valueIS_ == rhs.get()); }
     109             :   /** Operator "comparator != for two inverse lengths" */
     110             :   inline bool operator!=(const InverseLength & rhs) const { return (valueIS_ != rhs.get()); }
     111             : 
     112             : private:
     113             :   static double sget(double value, const std::string &units);
     114             :   static double sput(double value, const std::string &units);
     115             :   static double sget(double value, Units units);
     116             :   static double sput(double value, Units units);
     117             : 
     118             : private:
     119             :   double valueIS_;
     120             : }; // class InverseLength
     121             : 
     122             : ATM_NAMESPACE_END
     123             : 
     124             : #endif /*!_ATM_INVERSELENGTH_H*/

Generated by: LCOV version 1.16