casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
MeasValue.h
Go to the documentation of this file.
00001 //# MeasValue.h: Base class for values in a Measure
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 //#
00027 //# $Id: MeasValue.h 20551 2009-03-25 00:11:33Z Malte.Marquarding $
00028 
00029 #ifndef CASA_MEASVALUE_H
00030 #define CASA_MEASVALUE_H
00031 
00032 
00033 //# Includes
00034 #include <casa/aips.h>
00035 #include <casa/iosfwd.h>
00036 
00037 namespace casa { //# NAMESPACE CASA - BEGIN
00038 
00039 //# Forward Declarations
00040 template <class Qtype> class Quantum;
00041 template <class T> class Vector;
00042 
00043 // <summary>
00044 // Base class for values in a Measure
00045 // </summary>
00046 
00047 // <use visibility=export>
00048 
00049 // <reviewed reviewer="tcornwel" date="1996/02/22" tests="tMeasMath" demos="">
00050 // </reviewed>
00051 
00052 // <prerequisite>
00053 //   <li> <linkto class=Measure>Measure</linkto> class
00054 // </prerequisite>
00055 //
00056 // <etymology>
00057 // </etymology>
00058 //
00059 // <synopsis>
00060 // MeasValue forms the abstract base class for the values of quantities within
00061 // a reference frame. Examples of derived classes are:
00062 // <ul>
00063 //   <li> <linkto class=MVEpoch>MVEpoch</linkto>: a moment in time
00064 //   <li> <linkto class=MVDirection>MVDirection</linkto>: a direction in space
00065 //   <li> <linkto class=MVPosition>MVPosition</linkto>: a position on Earth
00066 //   <li> <linkto class=MVFrequency>MVFrequency</linkto>
00067 //   <li> <linkto class=MVRadialVelocity>MVRadialVelocity</linkto>
00068 //   <li> <linkto class=MVDoppler>MVDoppler</linkto>
00069 // </ul>
00070 // MeasValue is the generic name for the more specific instances like, e.g.,
00071 // <linkto class=MVEpoch>MVEpoch</linkto>, an instant in time.<br>
00072 // MeasValues can in general be constructed from an appropiate value, or array
00073 // of values.<br>
00074 // The value can be expressed in the internally used units (e.g.
00075 // days for time, a 3-vector for direction in space), as an array of internally
00076 // used units, or as a <linkto class=Quantum>Quantum</linkto>: a value with
00077 // appropiate units. <src>Vector<Quantum<type> ></src>
00078 // and <src>Quantum<Vector<type> ></src> can
00079 // also be used.
00080 //
00081 // The value of the <src>MeasValue</src> can be obtained by a variety of 
00082 // <src>get</src> functions, returning in general internal or <src>Quantum</src>
00083 // values. Special formatting (like hh:mm:ss.t, dd.mm.ss.t, yy/mm/dd etc)
00084 // are catered for in <em>conversion-type</em> classes like 
00085 // <linkto class=MVTime>MVTime</linkto>, <linkto class=MVAngle>MVAngle</linkto>
00086 //
00087 // Note that the class is a pure virtual class. No instances can be created,
00088 // but it describes the minimum set of functions necessary in derived functions.
00089 // <note role=warning> In the member description a number of <em>dummy</em> routines are
00090 // present. They are the only way I have found to get <em>cxx2html</em> to
00091 // get the belonging text properly presented.
00092 // </note>
00093 // </synopsis>
00094 //
00095 // <example>
00096 // See individual MV and Measure classes
00097 // </example>
00098 //
00099 // <motivation>
00100 // To be able to specify a physical entity appropiate for the measured
00101 // quantity.
00102 // </motivation>
00103 //
00104 // <todo asof="1997/04/15">
00105 // </todo>
00106 
00107 class MeasValue {
00108 
00109 public:
00110   //# Enumerations
00111   
00112   //# Typedefs
00113   
00114   //# Friends
00115   // Output a MeasValue
00116   friend ostream &operator<<(ostream &os, const MeasValue &meas);
00117   
00118   //# Constructor
00119   // Each derived class should have at least the following constructors:
00120   // <srcblock>
00121   //    MV()                    // some default
00122   //    MV(Double)              // some default or error if vector expected
00123   //    MV(Vector<Double>)      // with check for array number of elements
00124   //    MV(Quantity)
00125   //    MV(Vector<Quantity>)
00126   //    MV(Quantum<Vector<Double> >
00127   // </srcblock>
00128   // Float (or other standard type) versions could be added if appropiate.
00129   // Dummy for cxx2html
00130   void dummy_constr() const {;};
00131   
00132   //# Destructor
00133   // Destructor
00134   virtual ~MeasValue();
00135 
00136   //# Operators
00137   // The following operators should be present at least.
00138   // <srcblock>
00139   // MV &operator+=(const MV &meas);
00140   // MV &operator-=(const MV &meas);
00141   // Bool operator==(const MV &meas) const;
00142   // Bool operator!=(const MV &meas) const;
00143   // Bool near(const MV &meas, Double tol = 1e-13) const;
00144   // Bool nearAbs(const MV &meas, Double tol = 1e-13) const;
00145   // </srcblock>
00146   // Dummy for cxx2html
00147   void dummy_operator() const {;};
00148   
00149   //# General Member Functions
00150   // Assert that we are the correct MeasValue type
00151   // <thrown>
00152   //   <li> AipsError if wrong MeasValue type
00153   // </thrown>
00154   // Each Measure should have:
00155   // <src> static void assure(const MeasValue &in); </src>
00156   // Get the type (== Register(M*)) of derived MeasValue
00157   // <group>
00158   virtual uInt type() const = 0;
00159   // </group>
00160   // Print a MeasValue
00161   virtual void print(ostream &os) const = 0;
00162   
00163   // Clone a MeasValue
00164   virtual MeasValue *clone() const = 0;
00165 
00166   // Get the internal value as a <src>Vector<Double></src>.
00167   // Note that the vector could
00168   // be empty, or not be a true representation (different data sizes e.g.)
00169   virtual Vector<Double> getVector() const = 0;
00170 
00171   // Get the internal value as a <src>Vector<Quantity></src>. Usable in
00172   // records. The getXRecordValue() gets additional information for records.
00173   // The getTMRecordValue() gets the record values as deemed appropriate for 
00174   // the TableMeasures.
00175   // Note that the Vectors could be empty.
00176   // <group>
00177   virtual Vector<Quantum<Double> > getRecordValue() const = 0;
00178   virtual Vector<Quantum<Double> > getXRecordValue() const;
00179   virtual Vector<Quantum<Double> > getTMRecordValue() const;
00180   // </group>
00181   // Set the internal value from a Vector of values (obtained in principle
00182   // with a getVector()). It will be assumed that the Vector is correctly 
00183   // formatted. If Vector is too long, the remainder will be discarded.
00184   // If Vector is too short, action will depend on the individual classes,
00185   // but in general act the same way as a constructor with a short Vector. 
00186   virtual void putVector(const Vector<Double> &in) = 0;
00187 
00188   // Set the internal value if correct values and dimensions
00189   virtual Bool putValue(const Vector<Quantum<Double> > &in) = 0;
00190 
00191   // Some of the Measure values used need the occasional adjustments to proper
00192   // values. Examples are MVDirection (direction cosines) which have to be
00193   // normalised to a length of 1 and MEpoch (time) which have to have its
00194   // precision maintained. For others it is an effctive no-operation.
00195   // <group>
00196   // Adjust value
00197   virtual void adjust();
00198   // Adjust value and return a normalisation value
00199   virtual void adjust(Double &val);
00200   // Re-adjust, i.e. undo a previous adjust, with value
00201   virtual void readjust(Double val);
00202   // </group>
00203 private:
00204 };
00205 
00206 //# Global functions
00207 // <summary> Global functions </summary>
00208 // <group name=Output>
00209 // Output declaration
00210 ostream &operator<<(ostream &os, const MeasValue &meas);
00211 // </group>
00212 
00213 
00214 } //# NAMESPACE CASA - END
00215 
00216 #endif