casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
RawDataConversion.h
Go to the documentation of this file.
00001 //# RawDataConversion.h: A class with virtual functions to copy without conversion
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: RawDataConversion.h 20551 2009-03-25 00:11:33Z Malte.Marquarding $
00027 
00028 #ifndef CASA_RAWDATACONVERSION_H
00029 #define CASA_RAWDATACONVERSION_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 copy without conversion
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 copy data without conversion.
00050 // <p>
00051 // This class exists to make it possible to use a <src>DataConversion</src>
00052 // object when no conversion is actually needed.
00053 // </synopsis>
00054 
00055 // <example>
00056 // See example in class <linkto class=DataConversion>DataConversion</linkto>.
00057 // </example>
00058 
00059 // <motivation>
00060 // This class makes it possible to use the conversion framework
00061 // for operations where a conversion is only a simple copy.
00062 // </motivation>
00063 
00064 // <todo asof="$DATE$">
00065 //  <li> Support data type long double.
00066 // </todo>
00067 
00068 
00069 class RawDataConversion : public DataConversion
00070 {
00071 public:
00072     // Construct the object.
00073     RawDataConversion();
00074 
00075     virtual ~RawDataConversion();
00076 
00077     // Copy one value from external to local (is a simple memcpy).
00078     // The from and to buffer should not overlap.
00079     // <group>
00080     virtual unsigned int toLocal (char&           to, const void* from) const;
00081     virtual unsigned int toLocal (unsigned char&  to, const void* from) const;
00082     virtual unsigned int toLocal (short&          to, const void* from) const;
00083     virtual unsigned int toLocal (unsigned short& to, const void* from) const;
00084     virtual unsigned int toLocal (int&            to, const void* from) const;
00085     virtual unsigned int toLocal (unsigned int&   to, const void* from) const;
00086     virtual unsigned int toLocal (Int64&          to, const void* from) const;
00087     virtual unsigned int toLocal (uInt64&         to, const void* from) const;
00088     virtual unsigned int toLocal (float&          to, const void* from) const;
00089     virtual unsigned int toLocal (double&         to, const void* from) const;
00090     // </group>
00091     
00092     // Copy multiple values from external to local (is a simple memcpy).
00093     // The from and to buffer should not overlap.
00094     // <group>
00095     virtual unsigned int toLocal (char*           to, const void* from,
00096                                   unsigned int nr) const;
00097     virtual unsigned int toLocal (unsigned char*  to, const void* from,
00098                                   unsigned int nr) const;
00099     virtual unsigned int toLocal (short*          to, const void* from,
00100                                   unsigned int nr) const;
00101     virtual unsigned int toLocal (unsigned short* to, const void* from,
00102                                   unsigned int nr) const;
00103     virtual unsigned int toLocal (int*            to, const void* from,
00104                                   unsigned int nr) const;
00105     virtual unsigned int toLocal (unsigned int*   to, const void* from,
00106                                   unsigned int nr) const;
00107     virtual unsigned int toLocal (Int64*          to, const void* from,
00108                                   unsigned int nr) const;
00109     virtual unsigned int toLocal (uInt64*         to, const void* from,
00110                                   unsigned int nr) const;
00111     virtual unsigned int toLocal (float*          to, const void* from,
00112                                   unsigned int nr) const;
00113     virtual unsigned int toLocal (double*         to, const void* from,
00114                                   unsigned int nr) const;
00115     // </group>
00116 
00117     // Copy one value from local to external (is a simple memcpy).
00118     // The from and to buffer should not overlap.
00119     // <group>
00120     virtual unsigned int fromLocal (void* to, char           from) const;
00121     virtual unsigned int fromLocal (void* to, unsigned char  from) const;
00122     virtual unsigned int fromLocal (void* to, short          from) const;
00123     virtual unsigned int fromLocal (void* to, unsigned short from) const;
00124     virtual unsigned int fromLocal (void* to, int            from) const;
00125     virtual unsigned int fromLocal (void* to, unsigned int   from) const;
00126     virtual unsigned int fromLocal (void* to, Int64          from) const;
00127     virtual unsigned int fromLocal (void* to, uInt64         from) const;
00128     virtual unsigned int fromLocal (void* to, float          from) const;
00129     virtual unsigned int fromLocal (void* to, double         from) const;
00130     // </group>
00131     
00132     // Copy multiple values from local to external (is a simple memcpy).
00133     // The from and to buffer should not overlap.
00134     // <group>
00135     virtual unsigned int fromLocal (void* to, const char*           from,
00136                                     unsigned int nr) const;
00137     virtual unsigned int fromLocal (void* to, const unsigned char*  from,
00138                                     unsigned int nr) const;
00139     virtual unsigned int fromLocal (void* to, const short*          from,
00140                                     unsigned int nr) const;
00141     virtual unsigned int fromLocal (void* to, const unsigned short* from,
00142                                     unsigned int nr) const;
00143     virtual unsigned int fromLocal (void* to, const int*            from,
00144                                     unsigned int nr) const;
00145     virtual unsigned int fromLocal (void* to, const unsigned int*   from,
00146                                     unsigned int nr) const;
00147     virtual unsigned int fromLocal (void* to, const Int64*          from,
00148                                     unsigned int nr) const;
00149     virtual unsigned int fromLocal (void* to, const uInt64*         from,
00150                                     unsigned int nr) const;
00151     virtual unsigned int fromLocal (void* to, const float*          from,
00152                                     unsigned int nr) const;
00153     virtual unsigned int fromLocal (void* to, const double*         from,
00154                                     unsigned int nr) const;
00155     // </group>
00156 
00157     // Determine if the data for a data type can be simply copied, thus
00158     // if no conversion is needed. This is always True.
00159     // <group>
00160     virtual Bool canCopy (const char*) const;
00161     virtual Bool canCopy (const unsigned char*) const;
00162     virtual Bool canCopy (const short*) const;
00163     virtual Bool canCopy (const unsigned short*) const;
00164     virtual Bool canCopy (const int*) const;
00165     virtual Bool canCopy (const unsigned int*) const;
00166     virtual Bool canCopy (const Int64*) const;
00167     virtual Bool canCopy (const uInt64*) const;
00168     virtual Bool canCopy (const float*) const;
00169     virtual Bool canCopy (const double*) const;
00170     // </group>
00171 
00172     // Get the external size of the data type.
00173     // This returns the <src>sizeof</src>.
00174     // <group>
00175     virtual unsigned int externalSize (const char*) const;
00176     virtual unsigned int externalSize (const unsigned char*) const;
00177     virtual unsigned int externalSize (const short*) const;
00178     virtual unsigned int externalSize (const unsigned short*) const;
00179     virtual unsigned int externalSize (const int*) const;
00180     virtual unsigned int externalSize (const unsigned int*) const;
00181     virtual unsigned int externalSize (const Int64*) const;
00182     virtual unsigned int externalSize (const uInt64*) const;
00183     virtual unsigned int externalSize (const float*) const;
00184     virtual unsigned int externalSize (const double*) const;
00185     // </group>
00186 };
00187 
00188 
00189 inline RawDataConversion::RawDataConversion()
00190 {}
00191 
00192 
00193 
00194 } //# NAMESPACE CASA - END
00195 
00196 #endif