casa
$Rev:20696$
|
00001 //# LECanonicalIO.h: Class for IO in little endian canonical format 00002 //# Copyright (C) 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 //# $Id: LECanonicalIO.h 20551 2009-03-25 00:11:33Z Malte.Marquarding $ 00027 00028 #ifndef CASA_LECANONICALIO_H 00029 #define CASA_LECANONICALIO_H 00030 00031 #include <casa/aips.h> 00032 #include <casa/IO/TypeIO.h> 00033 #include <casa/BasicSL/Complexfwd.h> 00034 00035 namespace casa { //# NAMESPACE CASA - BEGIN 00036 00037 class ByteIO; 00038 class String; 00039 00040 // <summary>Class for IO in little endian canonical format.</summary> 00041 00042 // <use visibility=export> 00043 00044 // <reviewed reviewer="Friso Olnon" date="1996/11/06" tests="tTypeIO" demos=""> 00045 // </reviewed> 00046 00047 // <prerequisite> 00048 // <li> <linkto class=ByteIO>ByteIO</linkto> class and derived classes 00049 // <li> <linkto class=TypeIO>TypeIO</linkto>class 00050 // <li> <linkto class=LECanonicalConversion>LECanonicalConversion</linkto> 00051 // </prerequisite> 00052 00053 // <synopsis> 00054 // LECanonicalIO is a specialization of class TypeIO to store 00055 // data in little endian canonical format. 00056 // <p> 00057 // The class converts the data to/from canonical data and reads/writes 00058 // them from/into the ByteIO object given at construction time. 00059 // Conversion is only done when really needed. If not needed, the 00060 // data is directly read or written. 00061 // <p> 00062 // LECanonical format is little-endian IEEE format, where longs are 8 bytes. 00063 // Bools are stored as bits to be as space-efficient as possible. 00064 // This means that on a 32-bit SUN or HP conversions only have to be done 00065 // for Bools and longs. For a DEC-alpha, however, the data will always 00066 // be converted because it is a little-endian machine. 00067 // </synopsis> 00068 00069 00070 class LECanonicalIO: public TypeIO 00071 { 00072 public: 00073 // Constructor. 00074 // The read/write functions will use the given ByteIO object 00075 // as the data store. 00076 // <p> 00077 // The read and write functions use an intermediate buffer to hold the data 00078 // in canonical format. For small arrays it uses a fixed buffer with 00079 // length <src>bufferLength</src>. For arrays not fitting in this buffer, 00080 // it uses a temporary buffer allocated on the heap. 00081 // <p> 00082 // If takeOver is True the this class will delete the supplied 00083 // pointer. Otherwise the caller is responsible for this. 00084 explicit LECanonicalIO (ByteIO* byteIO, uInt bufferLength=4096, 00085 Bool takeOver=False); 00086 00087 // The copy constructor uses reference semantics 00088 LECanonicalIO (const LECanonicalIO& canonicalIO); 00089 00090 // The assignment operator uses reference semantics 00091 LECanonicalIO& operator= (const LECanonicalIO& canonicalIO); 00092 00093 // Destructor, deletes allocated memory. 00094 ~LECanonicalIO(); 00095 00096 // Convert the values and write them to the ByteIO object. 00097 // Bool, complex and String values are handled by the base class. 00098 // <group> 00099 virtual uInt write (uInt nvalues, const Bool* value); 00100 virtual uInt write (uInt nvalues, const Char* data); 00101 virtual uInt write (uInt nvalues, const uChar* data); 00102 virtual uInt write (uInt nvalues, const Short* data); 00103 virtual uInt write (uInt nvalues, const uShort* data); 00104 virtual uInt write (uInt nvalues, const Int* data); 00105 virtual uInt write (uInt nvalues, const uInt* data); 00106 virtual uInt write (uInt nvalues, const Int64* data); 00107 virtual uInt write (uInt nvalues, const uInt64* data); 00108 virtual uInt write (uInt nvalues, const Float* data); 00109 virtual uInt write (uInt nvalues, const Double* data); 00110 virtual uInt write (uInt nvalues, const Complex* value); 00111 virtual uInt write (uInt nvalues, const DComplex* value); 00112 virtual uInt write (uInt nvalues, const String* value); 00113 // </group> 00114 00115 // Read the values from the ByteIO object and convert them. 00116 // Bool, complex and String values are handled by the base class. 00117 // <group> 00118 virtual uInt read (uInt nvalues, Bool* value); 00119 virtual uInt read (uInt nvalues, Char* data); 00120 virtual uInt read (uInt nvalues, uChar* data); 00121 virtual uInt read (uInt nvalues, Short* data); 00122 virtual uInt read (uInt nvalues, uShort* data); 00123 virtual uInt read (uInt nvalues, Int* data); 00124 virtual uInt read (uInt nvalues, uInt* data); 00125 virtual uInt read (uInt nvalues, Int64* data); 00126 virtual uInt read (uInt nvalues, uInt64* data); 00127 virtual uInt read (uInt nvalues, Float* data); 00128 virtual uInt read (uInt nvalues, Double* data); 00129 virtual uInt read (uInt nvalues, Complex* value); 00130 virtual uInt read (uInt nvalues, DComplex* value); 00131 virtual uInt read (uInt nvalues, String* value); 00132 // </group> 00133 00134 private: 00135 //# The buffer 00136 char* itsBuffer; 00137 uInt itsBufferLength; 00138 }; 00139 00140 00141 00142 } //# NAMESPACE CASA - END 00143 00144 #endif