casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
MCEpoch.h
Go to the documentation of this file.
00001 //# MCEpoch.h: MEpoch conversion routines 
00002 //# Copyright (C) 1995,1996,1997,1998,1999,2002
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: MCEpoch.h 21130 2011-10-18 07:39:05Z gervandiepen $
00028 
00029 #ifndef MEASURES_MCEPOCH_H
00030 #define MEASURES_MCEPOCH_H
00031 
00032 //# Includes
00033 #include <casa/aips.h>
00034 #include <measures/Measures/MeasBase.h>
00035 #include <measures/Measures/MeasRef.h>
00036 #include <measures/Measures/MCBase.h>
00037 #include <measures/Measures/MConvertBase.h>
00038 #include <measures/Measures/MEpoch.h>
00039 #include <casa/OS/Mutex.h>
00040 
00041 namespace casa { //# NAMESPACE CASA - BEGIN
00042 
00043 //# Forward Declarations
00044 class MCEpoch;
00045 class Nutation;
00046 class String;
00047 
00048 //# Typedefs
00049 
00050 // <summary> MEpoch conversion routines </summary>
00051 
00052 // <use visibility=local>
00053 
00054 // <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests="tMeasure" demos="">
00055 // </reviewed>
00056 
00057 // <prerequisite>
00058 //   <li> <linkto class=Measure>Measure</linkto> class
00059 //   <li> <linkto class=MCBase>MCBase</linkto> base class
00060 //   <li> <linkto class=MConvertBase>overall conversion</linkto>  class
00061 // </prerequisite>
00062 //
00063 // <etymology>
00064 // Measure, Convert and Epoch
00065 // </etymology>
00066 //
00067 // <synopsis>
00068 // Contains state machinery and caching for actual conversions
00069 // </synopsis>
00070 //
00071 // <example>
00072 // Convert (with all steps explicit) a UTC to an IAT time.
00073 // <srcblock>
00074 //      #include <measures/Measures.h>
00075 //      #include <measures/Measures/MEpoch.h>
00076 //      #include <measures/Measures/MCEpoch.h>
00077 //      cout << "TAI for UTC = MJD(50237.29): " <<
00078 //              MEpoch::Convert(MEpoch(MVEpoch(Quantity(50237.29, "d")),
00079 //                                     MEpoch::Ref(MEpoch::UTC)),
00080 //                              MEpoch::Ref(MEpoch::TAI))() <<
00081 //              endl;
00082 // </srcblock>
00083 // </example>
00084 //
00085 // <motivation>
00086 // </motivation>
00087 //
00088 // <todo asof="1998/09/21">
00089 //      <li> Nothing I know
00090 // </todo>
00091 
00092 class MCEpoch : public MCBase {
00093 
00094 public:
00095 
00096   //# Friends
00097   friend class MeasConvert<MEpoch>;
00098   
00099   //# Constructors
00100   // Default constructor
00101   MCEpoch();
00102   
00103   //# Destructor
00104   ~MCEpoch();
00105 
00106   //# Member functions
00107   // Show the state of the conversion engine (mainly for debugging purposes)
00108   static String showState();
00109   
00110 private:
00111   //# Enumerations
00112   // The list of actual routines provided.
00113   // <note role=warning> Each <src>AA_BB</src> in the list points to routine
00114   // that can be used in the FromTo list in the getConvert routine.
00115   // In addition the type to which each is converted should be in the
00116   // ToRef array, again in the proper order. </note>
00117   enum Routes {
00118     LAST_GAST,
00119     GAST_LAST,
00120     LMST_GMST1,
00121     GMST1_LMST,
00122     GMST1_UT1,
00123     UT1_GMST1,
00124     GAST_UT1,
00125     UT1_GAST,
00126     UT1_UTC,
00127     UTC_UT1,
00128     UT1_UT2,
00129     UT2_UT1,
00130     UTC_TAI,
00131     TAI_UTC,
00132     TAI_TDT,
00133     TDT_TAI,
00134     TDT_TDB,
00135     TDB_TDT,
00136     TDT_TCG,
00137     TCG_TDT,
00138     TDB_TCB,
00139     TCB_TDB,
00140     N_Routes,
00141     RAZING
00142   };
00143   
00144   //# Typedefs
00145   
00146   //# Operators
00147   
00148   //# General Member Functions
00149   
00150   //# Enumerations
00151   
00152   //# Cached Data
00153   Nutation *NUTATFROM;
00154   Nutation *NUTATTO;
00155 
00156   //# State machine data
00157   // Transition list
00158   static uInt ToRef_p[N_Routes][3];
00159   // Transition matrix
00160   static uInt FromTo_p[MEpoch::N_Types][MEpoch::N_Types];
00161   // Mutex for thread-safety.
00162   static MutexedInit theirMutexedInit;
00163 
00164   // Fill the global state in a thread-safe way.
00165   static void fillState()
00166     { theirMutexedInit.exec(); }
00167   
00168   //# Constructors
00169   // Copy constructor (not implemented)
00170   MCEpoch(const MCEpoch &other);
00171   // Assignment (not implemented)
00172   MCEpoch &operator=(const MCEpoch &other);
00173   
00174   //# Member functions
00175   
00176   // Create conversion function pointer
00177   virtual void getConvert(MConvertBase &mc,
00178                           const MRBase &inref,
00179                           const MRBase &outref);
00180   
00181   // Create help structures for Measure conversion routines
00182   virtual void initConvert(uInt which, MConvertBase &mc);
00183   
00184   // Delete the pointers used in the MeasConvert help structure cache
00185   virtual void clearConvert();
00186   
00187   // Routine to convert time from one reference frame to another
00188   virtual void doConvert(MeasValue &in,
00189                          MRBase &inref,
00190                          MRBase &outref,
00191                          const MConvertBase &mc);
00192   // Conversion routine to cater for inheritance question
00193   void doConvert(MVEpoch &in,
00194                  MRBase &inref,
00195                  MRBase &outref,
00196                  const MConvertBase &mc);
00197   
00198 private:
00199   // Fill the global state in a thread-safe way.
00200   static void doFillState (void*);  
00201 };
00202 
00203 
00204 } //# NAMESPACE CASA - END
00205 
00206 #endif