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