casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ATMFrequency.h
Go to the documentation of this file.
1 #ifndef _ATM_FREQUENCY_H
2 #define _ATM_FREQUENCY_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: ATMFrequency.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 
48 class Frequency
49 {
50 public:
52  Frequency();
54  Frequency(double frequency, const std::string &units);
56  Frequency(double frequency);
58  Frequency (const Frequency &frequency);
59 
61  virtual ~Frequency();
62 
64  inline double get() const { return valueIS_; }
67  inline double get(const std::string &units) const { return sget( valueIS_, units); }
68 
70  inline Frequency& operator=(const Frequency &rhs) { if(&rhs != this) valueIS_ = rhs.valueIS_; return *this; }
72  inline Frequency& operator=(double rhs) { valueIS_ = rhs; return *this; }
74  inline Frequency operator+(const Frequency &rhs) { return Frequency(valueIS_ + rhs.get()); }
76  inline Frequency operator-(const Frequency &rhs) { return Frequency(valueIS_ - rhs.get()); }
77  /* operator+= operator-= */
79  inline Frequency operator*(double scf) { return Frequency(valueIS_ * scf); }
81  inline Frequency operator*(float scf) { return Frequency(valueIS_ * (double) scf); }
83  inline Frequency operator*(int scf) { return Frequency(valueIS_ * (double) scf); }
85  inline Frequency operator*(unsigned int scf) { return Frequency(valueIS_ * (double) scf); }
87  inline Frequency operator/(double scf) { return Frequency(valueIS_ / scf); }
89  inline Frequency operator/(float scf) { return Frequency(valueIS_ / (double) scf); }
91  inline Frequency operator/(int scf) { return Frequency(valueIS_ / (double) scf); }
93  inline Frequency operator/(unsigned int scf) { return Frequency(valueIS_ / (double) scf); }
95  inline bool operator<(const Frequency &rhs) const {return (valueIS_ < rhs.get()); }
97  inline bool operator> (const Frequency &rhs) const {return (valueIS_ > rhs.get()); }
99  inline bool operator<=(const Frequency &rhs) const {return (valueIS_ <= rhs.get()); }
101  inline bool operator>=(const Frequency &rhs) const {return (valueIS_ >= rhs.get()); }
103  inline bool operator==(const Frequency &rhs) const {return (valueIS_ == rhs.get()); }
105  inline bool operator!=(const Frequency &rhs) const {return (valueIS_ != rhs.get()); }
106 
107 private:
108  static double sget(double value, const std::string &units);
109  static double sput(double value, const std::string &units);
110 
111 private:
112  double valueIS_;
113 }; // class Frequency
114 
116 
117 #endif
Frequency operator*(float scf)
Operator &quot;multiplication of a frequency by a float&quot;.
Definition: ATMFrequency.h:81
#define ATM_NAMESPACE_END
Definition: ATMCommon.h:38
Frequency()
Default constructor: Frequency value set to 0 Hz.
bool operator==(const Frequency &rhs) const
Operator &quot;comparator == for two frequencies&quot;.
Definition: ATMFrequency.h:103
Frequency & operator=(double rhs)
Operator &quot;equal to a double converted to Frequency in Hz&quot;.
Definition: ATMFrequency.h:72
Frequency operator/(unsigned int scf)
Operator &quot;division of a frequency by an unsigned int&quot;.
Definition: ATMFrequency.h:93
bool operator<(const Frequency &rhs) const
Operator &quot;comparator &lt; for two frequencies&quot;.
Definition: ATMFrequency.h:95
bool operator!=(const Frequency &rhs) const
Operator &quot;comparator != for two frequencies&quot;.
Definition: ATMFrequency.h:105
Frequency operator-(const Frequency &rhs)
Operator &quot;subtraction of frequencies&quot;.
Definition: ATMFrequency.h:76
Frequency operator*(unsigned int scf)
Operator &quot;multiplication of a frequency by an unsigned int&quot;.
Definition: ATMFrequency.h:85
Frequency operator/(double scf)
Operator &quot;division of a frequency by a double&quot;.
Definition: ATMFrequency.h:87
Frequency & operator=(const Frequency &rhs)
Operator &quot;equal to a Frequency&quot;.
Definition: ATMFrequency.h:70
Frequency operator*(double scf)
Operator &quot;multiplication of a frequency by a double&quot;.
Definition: ATMFrequency.h:79
Frequency operator/(float scf)
Operator &quot;division of a frequency by a float&quot;.
Definition: ATMFrequency.h:89
bool operator>=(const Frequency &rhs) const
Operator &quot;comparator &gt;= for two frequencies&quot;.
Definition: ATMFrequency.h:101
Frequency operator*(int scf)
Operator &quot;multiplication of a frequency by an int&quot;.
Definition: ATMFrequency.h:83
double valueIS_
Definition: ATMFrequency.h:112
#define ATM_NAMESPACE_BEGIN
Definition: ATMCommon.h:37
bool operator<=(const Frequency &rhs) const
Operator &quot;comparator &lt;= for two frequencies&quot;.
Definition: ATMFrequency.h:99
Frequency operator+(const Frequency &rhs)
Operator &quot;addition of frequencies&quot;.
Definition: ATMFrequency.h:74
static double sput(double value, const std::string &units)
static double sget(double value, const std::string &units)
double get() const
Accessor to get the numerical value of frequency (in International System units: Hz) ...
Definition: ATMFrequency.h:64
bool operator>(const Frequency &rhs) const
Operator &quot;comparator &gt; for two frequencies&quot;.
Definition: ATMFrequency.h:97
Frequency operator/(int scf)
Operator &quot;division of a frequency by an int&quot;.
Definition: ATMFrequency.h:91
virtual ~Frequency()
Destructor.
Defines a frequency value with units.
Definition: ATMFrequency.h:48
LatticeExprNode value(const LatticeExprNode &expr)
This function returns the value of the expression without a mask.