casacore
CanonicalIO.h
Go to the documentation of this file.
1 //# CanonicalIO.h: Class for IO in canonical format
2 //# Copyright (C) 1996,1999,2001
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_CANONICALIO_H
29 #define CASA_CANONICALIO_H
30 
31 #include <casacore/casa/aips.h>
32 #include <casacore/casa/IO/TypeIO.h>
33 //# The following should be a forward declaration. But our Complex & DComplex
34 //# classes are a typedef hence this does not work. Replace the following with
35 //# forward declarations when Complex and DComplex are no longer typedefs.
36 #include <casacore/casa/BasicSL/Complex.h>
37 
38 namespace casacore { //# NAMESPACE CASACORE - BEGIN
39 
40 class ByteIO;
41 class String;
42 
43 // <summary>Class for IO in canonical format.</summary>
44 
45 // <use visibility=export>
46 
47 // <reviewed reviewer="Friso Olnon" date="1996/11/06" tests="tTypeIO" demos="">
48 // </reviewed>
49 
50 // <prerequisite>
51 // <li> <linkto class=ByteIO>ByteIO</linkto> class and derived classes
52 // <li> <linkto class=TypeIO>TypeIO</linkto>class
53 // <li> <linkto class=CanonicalConversion>CanonicalConversion</linkto>
54 // </prerequisite>
55 
56 // <synopsis>
57 // CanonicalIO is a specialization of class TypeIO to store
58 // data in canonical format.
59 // <p>
60 // The class converts the data to/from canonical data and reads/writes
61 // them from/into the ByteIO object given at construction time.
62 // Conversion is only done when really needed. If not needed, the
63 // data is directly read or written.
64 // <p>
65 // Canonical format is big-endian IEEE format, where longs are 8 bytes.
66 // Bools are stored as bits to be as space-efficient as possible.
67 // This means that on a 32-bit SUN or HP conversions only have to be done
68 // for Bools and longs. For a DEC-alpha, however, the data will always
69 // be converted because it is a little-endian machine.
70 // </synopsis>
71 
72 
73 class CanonicalIO: public TypeIO
74 {
75 public:
76  // Constructor.
77  // The read/write functions will use the given ByteIO object
78  // as the data store.
79  // <p>
80  // The read and write functions use an intermediate buffer to hold the data
81  // in canonical format. For small arrays it uses a fixed buffer with
82  // length <src>bufferLength</src>. For arrays not fitting in this buffer,
83  // it uses a temporary buffer allocated on the heap.
84  // <p>
85  // If takeOver is True the this class will delete the supplied
86  // pointer. Otherwise the caller is responsible for this.
87  explicit CanonicalIO (ByteIO* byteIO, uInt bufferLength=4096,
88  Bool takeOver=False);
89 
90  // The copy constructor uses reference semantics
91  CanonicalIO (const CanonicalIO& canonicalIO);
92 
93  // The assignment operator uses reference semantics
94  CanonicalIO& operator= (const CanonicalIO& canonicalIO);
95 
96  // Destructor, deletes allocated memory.
98 
99  // Convert the values and write them to the ByteIO object.
100  // Bool, complex and String values are handled by the base class.
101  // <group>
102  virtual size_t write (size_t nvalues, const Bool* value);
103  virtual size_t write (size_t nvalues, const Char* data);
104  virtual size_t write (size_t nvalues, const uChar* data);
105  virtual size_t write (size_t nvalues, const Short* data);
106  virtual size_t write (size_t nvalues, const uShort* data);
107  virtual size_t write (size_t nvalues, const Int* data);
108  virtual size_t write (size_t nvalues, const uInt* data);
109  virtual size_t write (size_t nvalues, const Int64* data);
110  virtual size_t write (size_t nvalues, const uInt64* data);
111  virtual size_t write (size_t nvalues, const Float* data);
112  virtual size_t write (size_t nvalues, const Double* data);
113  virtual size_t write (size_t nvalues, const Complex* value);
114  virtual size_t write (size_t nvalues, const DComplex* value);
115  virtual size_t write (size_t nvalues, const String* value);
116  // </group>
117 
118  // Read the values from the ByteIO object and convert them.
119  // Bool, complex and String values are handled by the base class.
120  // <group>
121  virtual size_t read (size_t nvalues, Bool* value);
122  virtual size_t read (size_t nvalues, Char* data);
123  virtual size_t read (size_t nvalues, uChar* data);
124  virtual size_t read (size_t nvalues, Short* data);
125  virtual size_t read (size_t nvalues, uShort* data);
126  virtual size_t read (size_t nvalues, Int* data);
127  virtual size_t read (size_t nvalues, uInt* data);
128  virtual size_t read (size_t nvalues, Int64* data);
129  virtual size_t read (size_t nvalues, uInt64* data);
130  virtual size_t read (size_t nvalues, Float* data);
131  virtual size_t read (size_t nvalues, Double* data);
132  virtual size_t read (size_t nvalues, Complex* value);
133  virtual size_t read (size_t nvalues, DComplex* value);
134  virtual size_t read (size_t nvalues, String* value);
135  // </group>
136 
137 private:
138  //# The buffer
139  char* itsBuffer;
141 };
142 
143 
144 
145 } //# NAMESPACE CASACORE - END
146 
147 #endif
virtual size_t write(size_t nvalues, const String *value)
virtual size_t read(size_t nvalues, DComplex *value)
virtual size_t read(size_t nvalues, Int *data)
virtual size_t write(size_t nvalues, const Complex *value)
CanonicalIO(const CanonicalIO &canonicalIO)
The copy constructor uses reference semantics.
virtual size_t read(size_t nvalues, Int64 *data)
virtual size_t write(size_t nvalues, const Int64 *data)
virtual size_t write(size_t nvalues, const uChar *data)
virtual size_t write(size_t nvalues, const uInt *data)
CanonicalIO & operator=(const CanonicalIO &canonicalIO)
The assignment operator uses reference semantics.
CanonicalIO(ByteIO *byteIO, uInt bufferLength=4096, Bool takeOver=False)
Constructor.
virtual size_t read(size_t nvalues, Complex *value)
virtual size_t read(size_t nvalues, Double *data)
virtual size_t read(size_t nvalues, Short *data)
virtual size_t read(size_t nvalues, uInt *data)
~CanonicalIO()
Destructor, deletes allocated memory.
virtual size_t read(size_t nvalues, uShort *data)
virtual size_t write(size_t nvalues, const Char *data)
virtual size_t write(size_t nvalues, const DComplex *value)
virtual size_t write(size_t nvalues, const uInt64 *data)
virtual size_t write(size_t nvalues, const Bool *value)
Convert the values and write them to the ByteIO object.
virtual size_t read(size_t nvalues, Float *data)
virtual size_t read(size_t nvalues, uInt64 *data)
virtual size_t read(size_t nvalues, Bool *value)
Read the values from the ByteIO object and convert them.
virtual size_t read(size_t nvalues, String *value)
virtual size_t write(size_t nvalues, const Short *data)
virtual size_t write(size_t nvalues, const Int *data)
virtual size_t read(size_t nvalues, uChar *data)
virtual size_t write(size_t nvalues, const Double *data)
virtual size_t read(size_t nvalues, Char *data)
virtual size_t write(size_t nvalues, const uShort *data)
virtual size_t write(size_t nvalues, const Float *data)
String: the storage and methods of handling collections of characters.
Definition: String.h:225
const ByteIO & byteIO() const
Functions to return a reference to the ByteIO class.
this file contains all the compiler specific defines
Definition: mainpage.dox:28
unsigned char uChar
Definition: aipstype.h:47
const Bool False
Definition: aipstype.h:44
short Short
Definition: aipstype.h:48
unsigned int uInt
Definition: aipstype.h:51
unsigned short uShort
Definition: aipstype.h:49
long long Int64
Define the extra non-standard types used by Casacore (like proposed uSize, Size)
Definition: aipsxtype.h:38
float Float
Definition: aipstype.h:54
int Int
Definition: aipstype.h:50
bool Bool
Define the standard types used by Casacore.
Definition: aipstype.h:42
LatticeExprNode value(const LatticeExprNode &expr)
This function returns the value of the expression without a mask.
double Double
Definition: aipstype.h:55
char Char
Definition: aipstype.h:46
unsigned long long uInt64
Definition: aipsxtype.h:39