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