casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
LECanonicalIO.h
Go to the documentation of this file.
1 //# LECanonicalIO.h: Class for IO in little endian canonical format
2 //# Copyright (C) 2002
3 //# Associated Universities, Inc. Washington DC, USA.
4 //#
5 //# This library is free software; you can redistribute it and/or modify it
6 //# under the terms of the GNU Library General Public License as published by
7 //# the Free Software Foundation; either version 2 of the License, or (at your
8 //# option) any later version.
9 //#
10 //# This library is distributed in the hope that it will be useful, but WITHOUT
11 //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 //# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
13 //# License for more details.
14 //#
15 //# You should have received a copy of the GNU Library General Public License
16 //# along with this library; if not, write to the Free Software Foundation,
17 //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
18 //#
19 //# Correspondence concerning AIPS++ should be addressed as follows:
20 //# Internet email: aips2-request@nrao.edu.
21 //# Postal address: AIPS++ Project Office
22 //# National Radio Astronomy Observatory
23 //# 520 Edgemont Road
24 //# Charlottesville, VA 22903-2475 USA
25 //#
26 //# $Id$
27 
28 #ifndef CASA_LECANONICALIO_H
29 #define CASA_LECANONICALIO_H
30 
31 #include <casacore/casa/aips.h>
34 
35 namespace casacore { //# NAMESPACE CASACORE - BEGIN
36 
37 class ByteIO;
38 class String;
39 
40 // <summary>Class for IO in little endian canonical format.</summary>
41 
42 // <use visibility=export>
43 
44 // <reviewed reviewer="Friso Olnon" date="1996/11/06" tests="tTypeIO" demos="">
45 // </reviewed>
46 
47 // <prerequisite>
48 // <li> <linkto class=ByteIO>ByteIO</linkto> class and derived classes
49 // <li> <linkto class=TypeIO>TypeIO</linkto>class
50 // <li> <linkto class=LECanonicalConversion>LECanonicalConversion</linkto>
51 // </prerequisite>
52 
53 // <synopsis>
54 // LECanonicalIO is a specialization of class TypeIO to store
55 // data in little endian canonical format.
56 // <p>
57 // The class converts the data to/from canonical data and reads/writes
58 // them from/into the ByteIO object given at construction time.
59 // Conversion is only done when really needed. If not needed, the
60 // data is directly read or written.
61 // <p>
62 // LECanonical format is little-endian IEEE format, where longs are 8 bytes.
63 // Bools are stored as bits to be as space-efficient as possible.
64 // This means that on a 32-bit SUN or HP conversions only have to be done
65 // for Bools and longs. For a DEC-alpha, however, the data will always
66 // be converted because it is a little-endian machine.
67 // </synopsis>
68 
69 
70 class LECanonicalIO: public TypeIO
71 {
72 public:
73  // Constructor.
74  // The read/write functions will use the given ByteIO object
75  // as the data store.
76  // <p>
77  // The read and write functions use an intermediate buffer to hold the data
78  // in canonical format. For small arrays it uses a fixed buffer with
79  // length <src>bufferLength</src>. For arrays not fitting in this buffer,
80  // it uses a temporary buffer allocated on the heap.
81  // <p>
82  // If takeOver is True the this class will delete the supplied
83  // pointer. Otherwise the caller is responsible for this.
84  explicit LECanonicalIO (ByteIO* byteIO, uInt bufferLength=4096,
85  Bool takeOver=False);
86 
87  // The copy constructor uses reference semantics
88  LECanonicalIO (const LECanonicalIO& canonicalIO);
89 
90  // The assignment operator uses reference semantics
91  LECanonicalIO& operator= (const LECanonicalIO& canonicalIO);
92 
93  // Destructor, deletes allocated memory.
95 
96  // Convert the values and write them to the ByteIO object.
97  // Bool, complex and String values are handled by the base class.
98  // <group>
99  virtual size_t write (size_t nvalues, const Bool* value);
100  virtual size_t write (size_t nvalues, const Char* data);
101  virtual size_t write (size_t nvalues, const uChar* data);
102  virtual size_t write (size_t nvalues, const Short* data);
103  virtual size_t write (size_t nvalues, const uShort* data);
104  virtual size_t write (size_t nvalues, const Int* data);
105  virtual size_t write (size_t nvalues, const uInt* data);
106  virtual size_t write (size_t nvalues, const Int64* data);
107  virtual size_t write (size_t nvalues, const uInt64* data);
108  virtual size_t write (size_t nvalues, const Float* data);
109  virtual size_t write (size_t nvalues, const Double* data);
110  virtual size_t write (size_t nvalues, const Complex* value);
111  virtual size_t write (size_t nvalues, const DComplex* value);
112  virtual size_t write (size_t nvalues, const String* value);
113  // </group>
114 
115  // Read the values from the ByteIO object and convert them.
116  // Bool, complex and String values are handled by the base class.
117  // <group>
118  virtual size_t read (size_t nvalues, Bool* value);
119  virtual size_t read (size_t nvalues, Char* data);
120  virtual size_t read (size_t nvalues, uChar* data);
121  virtual size_t read (size_t nvalues, Short* data);
122  virtual size_t read (size_t nvalues, uShort* data);
123  virtual size_t read (size_t nvalues, Int* data);
124  virtual size_t read (size_t nvalues, uInt* data);
125  virtual size_t read (size_t nvalues, Int64* data);
126  virtual size_t read (size_t nvalues, uInt64* data);
127  virtual size_t read (size_t nvalues, Float* data);
128  virtual size_t read (size_t nvalues, Double* data);
129  virtual size_t read (size_t nvalues, Complex* value);
130  virtual size_t read (size_t nvalues, DComplex* value);
131  virtual size_t read (size_t nvalues, String* value);
132  // </group>
133 
134 private:
135  //# The buffer
136  char* itsBuffer;
138 };
139 
140 
141 
142 } //# NAMESPACE CASACORE - END
143 
144 #endif
long long Int64
Define the extra non-standard types used by Casacore (like proposed uSize, Size)
Definition: aipsxtype.h:38
int Int
Definition: aipstype.h:50
LECanonicalIO & operator=(const LECanonicalIO &canonicalIO)
The assignment operator uses reference semantics.
unsigned long long uInt64
Definition: aipsxtype.h:39
unsigned char uChar
Definition: aipstype.h:47
virtual size_t read(size_t nvalues, Bool *value)
Read the values from the ByteIO object and convert them.
char Char
Definition: aipstype.h:46
LECanonicalIO(ByteIO *byteIO, uInt bufferLength=4096, Bool takeOver=False)
Constructor.
~LECanonicalIO()
Destructor, deletes allocated memory.
short Short
Definition: aipstype.h:48
ABSTRACT CLASSES Deliberately vague to be general enough to allow for many different types of data
Definition: PlotData.h:48
const ByteIO & byteIO() const
Functions to return a reference to the ByteIO class.
double Double
Definition: aipstype.h:55
Abstract base class for IO on a byte stream.
Definition: ByteIO.h:61
Abstract base class for IO of data in a type-dependent format.
Definition: TypeIO.h:79
bool Bool
Define the standard types used by Casacore.
Definition: aipstype.h:42
float Float
Definition: aipstype.h:54
const Bool False
Definition: aipstype.h:44
virtual size_t write(size_t nvalues, const Bool *value)
Convert the values and write them to the ByteIO object.
String: the storage and methods of handling collections of characters.
Definition: String.h:223
Class for IO in little endian canonical format.
Definition: LECanonicalIO.h:70
LatticeExprNode value(const LatticeExprNode &expr)
This function returns the value of the expression without a mask.
unsigned int uInt
Definition: aipstype.h:51
unsigned short uShort
Definition: aipstype.h:49
#define casacore
&lt;X11/Intrinsic.h&gt; #defines true, false, casacore::Bool, and String.
Definition: X11Intrinsic.h:42