casacore
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
MVDouble.h
Go to the documentation of this file.
1 //# MVDouble.h: class to distinguish between internal and external Double
2 //# Copyright (C) 1996,1997,1998,1999,2000,2001
3 //# Associated Universities, Inc. Washington DC, USA.
4 //#
5 //# This library is free software; you can redistribute it and/or modify it
6 //# under the terms of the GNU Library General Public License as published by
7 //# the Free Software Foundation; either version 2 of the License, or (at your
8 //# option) any later version.
9 //#
10 //# This library is distributed in the hope that it will be useful, but WITHOUT
11 //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 //# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
13 //# License for more details.
14 //#
15 //# You should have received a copy of the GNU Library General Public License
16 //# along with this library; if not, write to the Free Software Foundation,
17 //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
18 //#
19 //# Correspondence concerning AIPS++ should be addressed as follows:
20 //# Internet email: aips2-request@nrao.edu.
21 //# Postal address: AIPS++ Project Office
22 //# National Radio Astronomy Observatory
23 //# 520 Edgemont Road
24 //# Charlottesville, VA 22903-2475 USA
25 //#
26 //# $Id$
27 
28 #ifndef CASA_MVDOUBLE_H
29 #define CASA_MVDOUBLE_H
30 
31 
32 //# Includes
33 #include <casacore/casa/aips.h>
37 #include <casacore/casa/iosfwd.h>
38 
39 namespace casacore { //# NAMESPACE CASACORE - BEGIN
40 
41 //# Forward Declarations
42 
43 //# Constants (SUN compiler does not accept non-simple default arguments)
44 
45 // <summary> Class to distinguish external and Measure internal Double </summary>
46 
47 // <use visibility=export>
48 
49 // <reviewed reviewer="tcornwel" date="1996/02/23" tests="tMeasMath" demos="">
50 // </reviewed>
51 
52 // <prerequisite>
53 // <li> <linkto class=MeasValue>MeasValue</linkto>
54 // </prerequisite>
55 //
56 // <etymology>
57 // From Measure, Value and Double
58 // </etymology>
59 //
60 // <synopsis>
61 // An MVDouble is a simple Double, to be used in simple, single value
62 // Measures. Requirements can be found in the
63 // <linkto class=MeasValue>MeasValue</linkto> base class.<br>
64 // The only reasonable constructor is (but all MeasValue constructors are present)
65 // <src>MVDouble(Double)</src>; and an <src>operator Double</src> takes
66 // care of all other possibilities. Its external use is for
67 // <linkto class=MeasConvert>MeasConvert</linkto>, to distinguish between
68 // input in internal Measure units, and values which have to have
69 // units applied.
70 // </synopsis>
71 //
72 // <example>
73 // See e.g. <linkto class=MFrequency>MFrequency</linkto>
74 // </example>
75 //
76 // <motivation>
77 // To aid coordinate transformations possibilities
78 // </motivation>
79 //
80 // <todo asof="1995/09/04">
81 // </todo>
82 
83 class MVDouble : public MeasValue {
84 
85 public:
86 
87  //# Constructors
88  // Default constructor: generate a zero value
89  MVDouble();
90  // Copy constructor
91  MVDouble(const MVDouble &other);
92  // Copy assignment
93  MVDouble &operator=(const MVDouble &other);
94  // Constructor from Double
95  MVDouble(Double d);
96  // Constructor from Quantum : value taken will be the canonical value
97  // <group>
98  MVDouble(const Quantity &other);
99  MVDouble(const Quantum<Vector<Double> > &other);
100  // </group>
101  // Constructor from Vector. A zero value will be taken for an empty vector,
102  // the canonical value for a quantum vector.
103  // <thrown>
104  // <li> AipsError if vector length > 1
105  // </thrown>
106  // <group>
107  MVDouble(const Vector<Double> &other);
108  MVDouble(const Vector<Quantity> &other);
109  // </group>
110 
111  // Destructor
112  ~MVDouble();
113 
114  //# Operators
115  // Conversion operator
116  operator Double() const;
117 
118  // Addition
119  // <group>
120  MVDouble &operator+=(const MVDouble &other);
121  MVDouble &operator-=(const MVDouble &other);
122  // </group>
123  // Comparisons
124  // <group>
125  Bool operator==(const MVDouble &other) const;
126  Bool operator!=(const MVDouble &other) const;
127  Bool near(const MVDouble &other, Double tol = 1e-13) const;
128  Bool nearAbs(const MVDouble &other, Double tol = 1e-13) const;
129  // </group>
130 
131  //# General member functions
132  // Tell me your type
133  // <group>
134  static void assure(const MeasValue &in);
135  // </group>
136  // Print data
137  virtual void print(ostream &os) const;
138  // Clone
139  virtual MeasValue *clone() const;
140  // Adjust value: taken from base class, a NOP.
141  // Get the value in internal units
142  virtual Vector<Double> getVector() const;
143  // Set the value from internal units (set 0 for empty vector)
144  virtual void putVector(const Vector<Double> &in);
145  // Get the internal value as a <src>Vector<Quantity></src>. Usable in
146  // records. The getXRecordValue() gets additional information for records.
147  // Note that the Vectors could be empty.
148  // <group>
149  virtual Vector<Quantum<Double> > getRecordValue() const;
150  // </group>
151  // Set the internal value if correct values and dimensions
152  virtual Bool putValue(const Vector<Quantum<Double> > &in);
153 
154 private:
155  //# Data
156  // Value
158 };
159 
160 
161 } //# NAMESPACE CASACORE - END
162 
163 #endif
virtual void putVector(const Vector< Double > &in)
Set the value from internal units (set 0 for empty vector)
Bool operator==(const MVDouble &other) const
Comparisons.
MVDouble & operator+=(const MVDouble &other)
Addition.
virtual Vector< Double > getVector() const
Adjust value: taken from base class, a NOP.
Double val
Value.
Definition: MVDouble.h:157
virtual MeasValue * clone() const
Clone.
~MVDouble()
Destructor.
Base class for values in a Measure.
Definition: MeasValue.h:107
MVDouble & operator=(const MVDouble &other)
Copy assignment.
Bool operator!=(const MVDouble &other) const
static void assure(const MeasValue &in)
Tell me your type.
virtual void print(ostream &os) const
Print data.
double Double
Definition: aipstype.h:55
Bool near(const MVDouble &other, Double tol=1e-13) const
bool Bool
Define the standard types used by Casacore.
Definition: aipstype.h:42
Class to distinguish external and Measure internal Double.
Definition: MVDouble.h:83
MVDouble & operator-=(const MVDouble &other)
const Double e
e and functions thereof:
Bool nearAbs(const MVDouble &other, Double tol=1e-13) const
virtual Vector< Quantum< Double > > getRecordValue() const
Get the internal value as a Vector&lt;Quantity&gt;.
virtual Bool putValue(const Vector< Quantum< Double > > &in)
Set the internal value if correct values and dimensions.
MVDouble()
Default constructor: generate a zero value.