casacore
ByteSource.h
Go to the documentation of this file.
1 //# ByteSource.h: Class for read-only access to data in a given 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_BYTESOURCE_H
29 #define CASA_BYTESOURCE_H
30 
31 #include <casacore/casa/aips.h>
32 #include <casacore/casa/IO/BaseSinkSource.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 TypeIO;
41 class String;
42 
43 // <summary>Class for read-only access to data in a given format.</summary>
44 
45 // <use visibility=export>
46 
47 // <reviewed reviewer="Friso Olnon" date="1996/11/06" tests="tByteSink" demos="">
48 // </reviewed>
49 
50 // <prerequisite>
51 // <li> <linkto class=BaseSinkSource>BaseSinkSource</linkto> class
52 // <li> <linkto class=TypeIO>TypeIO</linkto> class and derived classes
53 // </prerequisite>
54 
55 // <etymology>
56 // A source is the place where bytes are read from.
57 // </etymology>
58 
59 // <synopsis>
60 // ByteSource provides read-only access to a typed byte stream in the
61 // Casacore IO framework. The base class <src>BaseSinkSource</src>
62 // contains common functions like <src>seek</src>.
63 // <p>
64 // The object is constructed using a typed byte stream. This stream
65 // is an instance of a class derived from class
66 // <linkto class=TypeIO>TypeIO</linkto>. This makes it possible to
67 // read the data in any format (e.g. CanonicalIO or RawIO).
68 // <br> In its turn TypeIO uses an instance of a class derived from class
69 // <linkto class=ByteIO>ByteIO</linkto>. This makes it possible to
70 // use any input stream (e.g. file, memory).
71 // </synopsis>
72 
73 // <example>
74 // <srcblock>
75 // // Construct the correct input stream.
76 // RegularFileIO filio ("file.name");
77 // CanonicalIO canio (&filio);
78 // ByteSource source (&canio);
79 // // Read data.
80 // Int vali;
81 // Bool flag;
82 // source >> vali >> flag;
83 // </srcblock>
84 // </example>
85 
86 // <motivation>
87 // This class makes it possible to deny write-access to an IO stream.
88 // </motivation>
89 
90 
91 class ByteSource: virtual public BaseSinkSource
92 {
93 public:
94  // Default constructor.
95  // This creates an invalid object, but is present for convenience.
97 
98  // Construct from given TypeIO object. The constructor does not copy the
99  // object, but only keeps a pointer to it. If takeOver is true the this
100  // class will delete the supplied pointer. Otherwise the caller is
101  // responsible for this.
103 
104  // The copy constructor uses reference semantics
105  ByteSource (const ByteSource& source);
106 
107  // The assignment operator uses reference semantics
109 
110  // destructor
112 
113  // These functions read one value of the given type.
114  // If this function does not succeed, an exception will be thrown.
115  // <group>
130  // </group>
131 
132  // These functions read multiple values of the given type.
133  // If this function does not succeed, an exception will be thrown.
134  // <group>
135  void read (size_t nvalues, Bool* value);
136  void read (size_t nvalues, Char* value);
137  void read (size_t nvalues, uChar* value);
138  void read (size_t nvalues, Short* value);
139  void read (size_t nvalues, uShort* value);
140  void read (size_t nvalues, Int* value);
141  void read (size_t nvalues, uInt* value);
142  void read (size_t nvalues, Int64* value);
143  void read (size_t nvalues, uInt64* value);
144  void read (size_t nvalues, Float* value);
145  void read (size_t nvalues, Double* value);
146  void read (size_t nvalues, Complex* value);
147  void read (size_t nvalues, DComplex* value);
148  void read (size_t nvalues, String* value);
149  // </group>
150 
151 protected:
152 };
153 
154 
155 
156 } //# NAMESPACE CASACORE - END
157 
158 #endif
TypeIO & typeIO()
This functions returns a reference to itsTypeIO.
void read(size_t nvalues, Short *value)
ByteSource()
Default constructor.
void read(size_t nvalues, Bool *value)
These functions read multiple values of the given type.
ByteSource & operator>>(Bool &value)
These functions read one value of the given type.
void read(size_t nvalues, Double *value)
~ByteSource()
destructor
ByteSource & operator=(const ByteSource &source)
The assignment operator uses reference semantics.
void read(size_t nvalues, String *value)
void read(size_t nvalues, Char *value)
void read(size_t nvalues, uInt *value)
ByteSource(const ByteSource &source)
The copy constructor uses reference semantics.
void read(size_t nvalues, Float *value)
void read(size_t nvalues, uChar *value)
void read(size_t nvalues, DComplex *value)
void read(size_t nvalues, uShort *value)
void read(size_t nvalues, uInt64 *value)
void read(size_t nvalues, Int64 *value)
void read(size_t nvalues, Complex *value)
ByteSource(TypeIO *typeIO, Bool takeOver=False)
Construct from given TypeIO object.
void read(size_t nvalues, Int *value)
String: the storage and methods of handling collections of characters.
Definition: String.h:225
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