casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
MVDouble.h
Go to the documentation of this file.
00001 //# MVDouble.h: class to distinguish between internal and external Double
00002 //# Copyright (C) 1996,1997,1998,1999,2000,2001
00003 //# Associated Universities, Inc. Washington DC, USA.
00004 //#
00005 //# This library is free software; you can redistribute it and/or modify it
00006 //# under the terms of the GNU Library General Public License as published by
00007 //# the Free Software Foundation; either version 2 of the License, or (at your
00008 //# option) any later version.
00009 //#
00010 //# This library is distributed in the hope that it will be useful, but WITHOUT
00011 //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00012 //# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
00013 //# License for more details.
00014 //#
00015 //# You should have received a copy of the GNU Library General Public License
00016 //# along with this library; if not, write to the Free Software Foundation,
00017 //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
00018 //#
00019 //# Correspondence concerning AIPS++ should be addressed as follows:
00020 //#        Internet email: aips2-request@nrao.edu.
00021 //#        Postal address: AIPS++ Project Office
00022 //#                        National Radio Astronomy Observatory
00023 //#                        520 Edgemont Road
00024 //#                        Charlottesville, VA 22903-2475 USA
00025 //#
00026 //# $Id: MVDouble.h 20551 2009-03-25 00:11:33Z Malte.Marquarding $
00027 
00028 #ifndef CASA_MVDOUBLE_H
00029 #define CASA_MVDOUBLE_H
00030 
00031 
00032 //# Includes
00033 #include <casa/aips.h>
00034 #include <casa/Arrays/Vector.h>
00035 #include <casa/Quanta/Quantum.h>
00036 #include <casa/Quanta/MeasValue.h>
00037 #include <casa/iosfwd.h>
00038 
00039 namespace casa { //# NAMESPACE CASA - BEGIN
00040 
00041 //# Forward Declarations
00042 
00043 //# Constants (SUN compiler does not accept non-simple default arguments)
00044 
00045 // <summary> Class to distinguish external and Measure internal Double </summary>
00046 
00047 // <use visibility=export>
00048 
00049 // <reviewed reviewer="tcornwel" date="1996/02/23" tests="tMeasMath" demos="">
00050 // </reviewed>
00051 
00052 // <prerequisite>
00053 // <li> <linkto class=MeasValue>MeasValue</linkto>
00054 // </prerequisite>
00055 //
00056 // <etymology>
00057 // From Measure, Value and Double
00058 // </etymology>
00059 //
00060 // <synopsis>
00061 // An MVDouble is a simple Double, to be used in simple, single value
00062 // Measures. Requirements can be found in the 
00063 // <linkto class=MeasValue>MeasValue</linkto> base class.<br>
00064 // The only reasonable constructor is (but all MeasValue constructors are present)
00065 // <src>MVDouble(Double)</src>; and an <src>operator Double</src> takes
00066 // care of all other possibilities. Its external use is for
00067 //  <linkto class=MeasConvert>MeasConvert</linkto>, to distinguish between
00068 // input in internal Measure units, and values which have to have
00069 // units applied.
00070 // </synopsis>
00071 //
00072 // <example>
00073 // See e.g. <linkto class=MFrequency>MFrequency</linkto>
00074 // </example>
00075 //
00076 // <motivation>
00077 // To aid coordinate transformations possibilities
00078 // </motivation>
00079 //
00080 // <todo asof="1995/09/04">
00081 // </todo>
00082 
00083 class MVDouble : public MeasValue {
00084 
00085 public:
00086   
00087   //# Constructors
00088   // Default constructor: generate a zero value
00089   MVDouble();
00090   // Copy constructor
00091   MVDouble(const MVDouble &other);
00092   // Copy assignment
00093   MVDouble &operator=(const MVDouble &other);
00094   // Constructor from Double
00095   MVDouble(Double d);
00096   // Constructor from Quantum : value taken will be the canonical value
00097   // <group>
00098   MVDouble(const Quantity &other);
00099   MVDouble(const Quantum<Vector<Double> > &other);
00100   // </group>
00101   // Constructor from Vector. A zero value will be taken for an empty vector,
00102   // the canonical value for a quantum vector.
00103   // <thrown>
00104   //  <li> AipsError if vector length > 1
00105   // </thrown>
00106   // <group>
00107   MVDouble(const Vector<Double> &other);
00108   MVDouble(const Vector<Quantity> &other);
00109   // </group>
00110   
00111   // Destructor
00112   ~MVDouble();
00113   
00114   //# Operators
00115   // Conversion operator
00116   operator Double() const;
00117   
00118   // Addition
00119   // <group>
00120   MVDouble &operator+=(const MVDouble &other);
00121   MVDouble &operator-=(const MVDouble &other);
00122   // </group>
00123   // Comparisons
00124   // <group>
00125   Bool operator==(const MVDouble &other) const;
00126   Bool operator!=(const MVDouble &other) const;
00127   Bool near(const MVDouble &other, Double tol = 1e-13) const;
00128   Bool nearAbs(const MVDouble &other, Double tol = 1e-13) const;
00129   // </group>
00130   
00131   //# General member functions
00132   // Tell me your type
00133   // <group>
00134   virtual uInt type() const;
00135   static void assure(const MeasValue &in);
00136   // </group>
00137   // Print data
00138   virtual void print(ostream &os) const;
00139   // Clone
00140   virtual MeasValue *clone() const;
00141   // Adjust value: taken from base class, a NOP.
00142   // Get the value in internal units
00143   virtual Vector<Double> getVector() const;
00144   // Set the value from internal units (set 0 for empty vector)
00145   virtual void putVector(const Vector<Double> &in);
00146    // Get the internal value as a <src>Vector<Quantity></src>. Usable in
00147   // records. The getXRecordValue() gets additional information for records.
00148   // Note that the Vectors could be empty.
00149   // <group>
00150   virtual Vector<Quantum<Double> > getRecordValue() const;
00151   // </group>
00152   // Set the internal value if correct values and dimensions
00153   virtual Bool putValue(const Vector<Quantum<Double> > &in);
00154  
00155 private:
00156   //# Data
00157   // Value
00158   Double val;
00159 };
00160 
00161 
00162 } //# NAMESPACE CASA - END
00163 
00164 #endif