casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ATMOpacity.h
Go to the documentation of this file.
1 #ifndef _ATM_OPACITY_H
2 #define _ATM_OPACITY_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: ATMOpacity.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 
38 
44 class Opacity
45 {
46 public:
48  Opacity();
50  Opacity(double opacity);
52  Opacity(double opacity, const std::string &units);
54  Opacity (const Opacity &opacity);
55 
57  virtual ~Opacity();
58 
60  double get() const { return valueIS_; }
63  inline double get(const std::string &units) const { return sget(valueIS_, units); }
64 
66  inline Opacity& operator=(const Opacity &rhs) { if(&rhs != this) valueIS_ = rhs.valueIS_; return *this; }
68  inline Opacity& operator=(const double &rhs) { valueIS_ = rhs; return *this; }
70  inline Opacity operator+(const Opacity &rhs) { return Opacity(valueIS_ + rhs.get()); }
72  inline Opacity operator-(const Opacity &rhs) { return Opacity(valueIS_ - rhs.get()); }
74  inline Opacity operator*(double scf) { return Opacity(valueIS_ * scf); }
76  inline Opacity operator*(float scf) { return Opacity(valueIS_ * (double) scf); }
78  inline Opacity operator*(int scf) { return Opacity(valueIS_ * (double) scf); }
80  inline Opacity operator*(unsigned int scf) { return Opacity(valueIS_ * (double) scf); }
82  inline Opacity operator/(double scf) { return Opacity(valueIS_ / scf); }
84  inline Opacity operator/(float scf) { return Opacity(valueIS_ / (double) scf); }
86  inline Opacity operator/(int scf) { return Opacity(valueIS_ / (double) scf); }
88  inline Opacity operator/(unsigned int scf) { return Opacity(valueIS_ / (double) scf); }
90  inline bool operator<(const Opacity &rhs) const { return (valueIS_ < rhs.get()); }
92  inline bool operator>(const Opacity &rhs) const { return (valueIS_ > rhs.get()); }
94  inline bool operator<=(const Opacity &rhs) const { return (valueIS_ <= rhs.get()); }
96  inline bool operator>=(const Opacity &rhs) const { return (valueIS_ >= rhs.get()); }
98  inline bool operator==(const Opacity &rhs) const { return (valueIS_ == rhs.get()); }
100  inline bool operator!=(const Opacity &rhs) const { return (valueIS_ != rhs.get()); }
101 
102 private:
103  static double sget(double value, const std::string &units);
104  static double sput(double value, const std::string &units);
105 
106 private:
107  double valueIS_;
108 }; // class Opacity
109 
111 
112 #endif
#define ATM_NAMESPACE_END
Definition: ATMCommon.h:38
bool operator!=(const Opacity &rhs) const
Operator &quot;comparator != for two opacities&quot;.
Definition: ATMOpacity.h:100
Opacity operator+(const Opacity &rhs)
Operator &quot;addition of opacities&quot;.
Definition: ATMOpacity.h:70
bool operator==(const Opacity &rhs) const
Operator &quot;comparator == for two opacities&quot;.
Definition: ATMOpacity.h:98
Opacity & operator=(const Opacity &rhs)
Operator &quot;equal to a Opacity&quot;.
Definition: ATMOpacity.h:66
Opacity & operator=(const double &rhs)
Operator &quot;equal to a double converted to Opacity in m&quot;.
Definition: ATMOpacity.h:68
Opacity operator*(double scf)
Operator &quot;multiplication of an opacity by a double&quot;.
Definition: ATMOpacity.h:74
virtual ~Opacity()
Destructor.
bool operator>(const Opacity &rhs) const
Operator &quot;comparator &gt; for two opacities&quot;.
Definition: ATMOpacity.h:92
static double sput(double value, const std::string &units)
Opacity operator/(float scf)
Operator &quot;division of a opacity by a float&quot;.
Definition: ATMOpacity.h:84
Opacity operator*(int scf)
Operator &quot;multiplication of an opacity by an int&quot;.
Definition: ATMOpacity.h:78
bool operator<=(const Opacity &rhs) const
Operator &quot;comparator &lt;= for two opacities&quot;.
Definition: ATMOpacity.h:94
Opacity operator*(unsigned int scf)
Operator &quot;multiplication of an opacity by an unsigned int&quot;.
Definition: ATMOpacity.h:80
#define ATM_NAMESPACE_BEGIN
Definition: ATMCommon.h:37
Opacity()
Default constructor: Opacity value set to 0 np.
bool operator>=(const Opacity &rhs) const
Operator &quot;comparator &gt;= for two opacities&quot;.
Definition: ATMOpacity.h:96
Opacity operator/(int scf)
Operator &quot;division of a opacity by an int&quot;.
Definition: ATMOpacity.h:86
static double sget(double value, const std::string &units)
bool operator<(const Opacity &rhs) const
Operator &quot;comparator &lt; for two opacities&quot;.
Definition: ATMOpacity.h:90
Class for opacities [no dimensions].
Definition: ATMOpacity.h:44
Opacity operator-(const Opacity &rhs)
Operator &quot;substraction of opacities&quot;.
Definition: ATMOpacity.h:72
double get() const
Accessor to get the numerical value of opacity (in np)
Definition: ATMOpacity.h:60
Opacity operator/(double scf)
Operator &quot;division of a opacity by an int&quot;.
Definition: ATMOpacity.h:82
Opacity operator/(unsigned int scf)
Operator &quot;division of a opacity by an unsigned int&quot;.
Definition: ATMOpacity.h:88
double valueIS_
Definition: ATMOpacity.h:107
Opacity operator*(float scf)
Operator &quot;multiplication of an opacity by a float&quot;.
Definition: ATMOpacity.h:76
LatticeExprNode value(const LatticeExprNode &expr)
This function returns the value of the expression without a mask.