casa
$Rev:20696$
|
00001 //# CanonicalDataConversion.h: A class with virtual functions to convert canonical 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: CanonicalDataConversion.h 20551 2009-03-25 00:11:33Z Malte.Marquarding $ 00027 00028 #ifndef CASA_CANONICALDATACONVERSION_H 00029 #define CASA_CANONICALDATACONVERSION_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 canonical 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 canonical format 00050 // using the static functions in class <linkto class=CanonicalConversion> 00051 // CanonicalConversion</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=CanonicalConversion> 00060 // CanonicalConversion</linkto> 00061 // to be able to use the conversion functions in a polymorphic way. 00062 // </motivation> 00063 00064 // <todo asof="$DATE$"> 00065 // <li> Support data type long double. 00066 // </todo> 00067 00068 00069 class CanonicalDataConversion : public DataConversion 00070 { 00071 public: 00072 // Construct the object. 00073 CanonicalDataConversion(); 00074 00075 virtual ~CanonicalDataConversion(); 00076 00077 // Convert one value from canonical format to local format. 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 // Convert nr values from canonical format to local format. 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 // Convert one value from local format to canonical format. 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 // Convert nr values from local format to canonical format. 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. 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 // <group> 00174 virtual unsigned int externalSize (const char*) const; 00175 virtual unsigned int externalSize (const unsigned char*) const; 00176 virtual unsigned int externalSize (const short*) const; 00177 virtual unsigned int externalSize (const unsigned short*) const; 00178 virtual unsigned int externalSize (const int*) const; 00179 virtual unsigned int externalSize (const unsigned int*) const; 00180 virtual unsigned int externalSize (const Int64*) const; 00181 virtual unsigned int externalSize (const uInt64*) const; 00182 virtual unsigned int externalSize (const float*) const; 00183 virtual unsigned int externalSize (const double*) const; 00184 // </group> 00185 }; 00186 00187 00188 inline CanonicalDataConversion::CanonicalDataConversion() 00189 {} 00190 00191 00192 00193 } //# NAMESPACE CASA - END 00194 00195 #endif