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