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