casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
VAXDataConversion.h
Go to the documentation of this file.
00001 //# VAXDataConversion.h: A class with virtual functions to convert VAX format
00002 //# Copyright (C) 1996,1999,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: VAXDataConversion.h 20551 2009-03-25 00:11:33Z Malte.Marquarding $
00027 
00028 #ifndef CASA_VAXDATACONVERSION_H
00029 #define CASA_VAXDATACONVERSION_H
00030 
00031 //# Includes
00032 #include <casa/OS/DataConversion.h>
00033 
00034 
00035 namespace casa { //# NAMESPACE CASA - BEGIN
00036 
00037 // <summary>
00038 // A class with virtual functions to convert VAX format
00039 // </summary>
00040 
00041 // <use visibility=export>
00042 
00043 // <reviewed reviewer="Friso Olnon" date="1996/11/06" tests="tDataConversion" demos="">
00044 // </reviewed>
00045 
00046 // <synopsis>
00047 // This class is a specialization of the abstract base class
00048 // <linkto class=DataConversion>DataConversion</linkto>.
00049 // It contains functions to convert data from/to the old VAX format
00050 // using the static functions in class <linkto class=VAXConversion>
00051 // VAXConversion</linkto>.
00052 // </synopsis>
00053 
00054 // <example>
00055 // See example in class <linkto class=DataConversion>DataConversion</linkto>.
00056 // </example>
00057 
00058 // <motivation>
00059 // This class is an addition to <linkto class=VAXConversion>VAXConversion
00060 // </linkto> to be able to use the conversion functions in a polymorphic way.
00061 // </motivation>
00062 
00063 // <todo asof="$DATE$">
00064 //  <li> Support data type long double.
00065 // </todo>
00066 
00067 
00068 class VAXDataConversion : public DataConversion
00069 {
00070 public:
00071     // Construct the object.
00072     VAXDataConversion();
00073 
00074     virtual ~VAXDataConversion();
00075 
00076     // Convert one value from VAX format to local format.
00077     // The from and to buffer should not overlap.
00078     // <group>
00079     virtual unsigned int toLocal (char&           to, const void* from) const;
00080     virtual unsigned int toLocal (unsigned char&  to, const void* from) const;
00081     virtual unsigned int toLocal (short&          to, const void* from) const;
00082     virtual unsigned int toLocal (unsigned short& to, const void* from) const;
00083     virtual unsigned int toLocal (int&            to, const void* from) const;
00084     virtual unsigned int toLocal (unsigned int&   to, const void* from) const;
00085     virtual unsigned int toLocal (Int64&          to, const void* from) const;
00086     virtual unsigned int toLocal (uInt64&         to, const void* from) const;
00087     virtual unsigned int toLocal (float&          to, const void* from) const;
00088     virtual unsigned int toLocal (double&         to, const void* from) const;
00089     // </group>
00090     
00091     // Convert nr values from VAX format to local format.
00092     // The from and to buffer should not overlap.
00093     // <group>
00094     virtual unsigned int toLocal (char*           to, const void* from,
00095                                   unsigned int nr) const;
00096     virtual unsigned int toLocal (unsigned char*  to, const void* from,
00097                                   unsigned int nr) const;
00098     virtual unsigned int toLocal (short*          to, const void* from,
00099                                   unsigned int nr) const;
00100     virtual unsigned int toLocal (unsigned short* to, const void* from,
00101                                   unsigned int nr) const;
00102     virtual unsigned int toLocal (int*            to, const void* from,
00103                                   unsigned int nr) const;
00104     virtual unsigned int toLocal (unsigned int*   to, const void* from,
00105                                   unsigned int nr) const;
00106     virtual unsigned int toLocal (Int64*          to, const void* from,
00107                                   unsigned int nr) const;
00108     virtual unsigned int toLocal (uInt64*         to, const void* from,
00109                                   unsigned int nr) const;
00110     virtual unsigned int toLocal (float*          to, const void* from,
00111                                   unsigned int nr) const;
00112     virtual unsigned int toLocal (double*         to, const void* from,
00113                                   unsigned int nr) const;
00114     // </group>
00115 
00116     // Convert one value from local format to VAX format.
00117     // The from and to buffer should not overlap.
00118     // <group>
00119     virtual unsigned int fromLocal (void* to, char           from) const;
00120     virtual unsigned int fromLocal (void* to, unsigned char  from) const;
00121     virtual unsigned int fromLocal (void* to, short          from) const;
00122     virtual unsigned int fromLocal (void* to, unsigned short from) const;
00123     virtual unsigned int fromLocal (void* to, int            from) const;
00124     virtual unsigned int fromLocal (void* to, unsigned int   from) const;
00125     virtual unsigned int fromLocal (void* to, Int64          from) const;
00126     virtual unsigned int fromLocal (void* to, uInt64         from) const;
00127     virtual unsigned int fromLocal (void* to, float          from) const;
00128     virtual unsigned int fromLocal (void* to, double         from) const;
00129     // </group>
00130     
00131     // Convert nr values from local format to VAX format.
00132     // The from and to buffer should not overlap.
00133     // <group>
00134     virtual unsigned int fromLocal (void* to, const char*           from,
00135                                     unsigned int nr) const;
00136     virtual unsigned int fromLocal (void* to, const unsigned char*  from,
00137                                     unsigned int nr) const;
00138     virtual unsigned int fromLocal (void* to, const short*          from,
00139                                     unsigned int nr) const;
00140     virtual unsigned int fromLocal (void* to, const unsigned short* from,
00141                                     unsigned int nr) const;
00142     virtual unsigned int fromLocal (void* to, const int*            from,
00143                                     unsigned int nr) const;
00144     virtual unsigned int fromLocal (void* to, const unsigned int*   from,
00145                                     unsigned int nr) const;
00146     virtual unsigned int fromLocal (void* to, const Int64*          from,
00147                                     unsigned int nr) const;
00148     virtual unsigned int fromLocal (void* to, const uInt64*         from,
00149                                     unsigned int nr) const;
00150     virtual unsigned int fromLocal (void* to, const float*          from,
00151                                     unsigned int nr) const;
00152     virtual unsigned int fromLocal (void* to, const double*         from,
00153                                     unsigned int nr) const;
00154     // </group>
00155 
00156     // Determine if the data for a data type can be simply copied, thus
00157     // if no conversion is needed.
00158     // <group>
00159     virtual Bool canCopy (const char*) const;
00160     virtual Bool canCopy (const unsigned char*) const;
00161     virtual Bool canCopy (const short*) const;
00162     virtual Bool canCopy (const unsigned short*) const;
00163     virtual Bool canCopy (const int*) const;
00164     virtual Bool canCopy (const unsigned int*) const;
00165     virtual Bool canCopy (const Int64*) const;
00166     virtual Bool canCopy (const uInt64*) const;
00167     virtual Bool canCopy (const float*) const;
00168     virtual Bool canCopy (const double*) const;
00169     // </group>
00170 
00171     // Get the external size of the data type.
00172     // <group>
00173     virtual unsigned int externalSize (const char*) const;
00174     virtual unsigned int externalSize (const unsigned char*) const;
00175     virtual unsigned int externalSize (const short*) const;
00176     virtual unsigned int externalSize (const unsigned short*) const;
00177     virtual unsigned int externalSize (const int*) const;
00178     virtual unsigned int externalSize (const unsigned int*) const;
00179     virtual unsigned int externalSize (const Int64*) const;
00180     virtual unsigned int externalSize (const uInt64*) const;
00181     virtual unsigned int externalSize (const float*) const;
00182     virtual unsigned int externalSize (const double*) const;
00183     // </group>
00184 };
00185 
00186 
00187 inline VAXDataConversion::VAXDataConversion()
00188 {}
00189 
00190 
00191 
00192 } //# NAMESPACE CASA - END
00193 
00194 #endif