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

Generated on 31 Aug 2016 for casa by  doxygen 1.6.1