casacore
Loading...
Searching...
No Matches
StreamIO.h
Go to the documentation of this file.
1// # StreamIO.h: Class for connection oriented IO to/from a socket
2// # Copyright (C) 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_STREAMIO_H
27#define CASA_STREAMIO_H
28
29#include <casacore/casa/aips.h>
30#include <casacore/casa/IO/ByteIO.h>
31
32namespace casacore { // # NAMESPACE CASACORE - BEGIN
33
34class String;
35
36// <summary>Class for IO on connection oriented socket</summary>
37
38// <use visibility=export>
39
40// <reviewed reviewer="" date="yyyy/mm/dd" tests="" demos="">
41// </reviewed>
42
43// <prerequisite>
44// <li> <linkto class=ByteIO>ByteIO</linkto> class
45// <li> Tape descriptors
46// </prerequisite>
47
48// <synopsis>
49// This class is a specialization of class
50// <linkto class=ByteIO>ByteIO</linkto>. It uses a file descriptor
51// to read/write data to a Internet (AF_INET) stream.
52// <p>
53// </synopsis>
54
55// <example>
56// </example>
57
58// <motivation>
59// This class was needed for the online version of the VLA filler.
60// </motivation>
61
62class StreamIO : public ByteIO {
63 public:
64 // Construct a stream that is attached to the specified host on the specified
65 // portnumber. Name lookup is not currently done so that the dotted quad
66 // notation must be used.
67 StreamIO(const String& hostname, uShort portNumber);
68
69 // The destructor closes the file.
70 virtual ~StreamIO();
71
72 // Write the specified number of bytes.
73 virtual void write(Int64 size, const void* buf);
74
75 // Read <src>size</src> bytes from the tape. Returns the number of bytes
76 // actually read or a negative number if an error occured. Will throw an
77 // exception (AipsError) if the requested number of bytes could not be read,
78 // or an error occured, unless throwException is set to False.
79 virtual Int64 read(Int64 size, void* buf, Bool throwException = True);
80
81 // Get the length of the stream. Not a meaningful function for this
82 // class and this function always returns -1.
83 virtual Int64 length();
84
85 // Is the stream readable? This function always returns True.
86 virtual Bool isReadable() const;
87
88 // Is the stream writable? This function always returns True.
89 virtual Bool isWritable() const;
90
91 // Is the stream seekable? This function always returns False.
92 virtual Bool isSeekable() const;
93
94 protected:
95 // Reset the position pointer to the given value. It returns the new
96 // position. As stream devices are not seekable calling this function will
97 // always throw an AipsError exception.
99
100 private:
101 // The following functions are made private so that the compiler does not
102 // generate default ones. They cannot be used and are not defined.
103 StreamIO(const StreamIO& other);
105
107};
108
109} // namespace casacore
110
111#endif
SeekOption
Define the possible seek options.
Definition ByteIO.h:77
ByteIO()
The constructor does nothing.
Definition ByteIO.h:167
virtual ~StreamIO()
The destructor closes the file.
virtual Bool isReadable() const
Is the stream readable?
virtual Bool isSeekable() const
Is the stream seekable?
StreamIO(const String &hostname, uShort portNumber)
Construct a stream that is attached to the specified host on the specified portnumber.
virtual Int64 doSeek(Int64 offset, ByteIO::SeekOption)
Reset the position pointer to the given value.
StreamIO(const StreamIO &other)
The following functions are made private so that the compiler does not generate default ones.
virtual Int64 length()
Get the length of the stream.
virtual Bool isWritable() const
Is the stream writable?
virtual Int64 read(Int64 size, void *buf, Bool throwException=True)
Read size bytes from the tape.
virtual void write(Int64 size, const void *buf)
Write the specified number of bytes.
StreamIO & operator=(const StreamIO &other)
String: the storage and methods of handling collections of characters.
Definition String.h:355
For temporary backward namespace compatibility, use casa as alias for casacore.
Definition mainpage.dox:28
int offset(int, int) const
compute a linear offset from array indicies
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
bool Bool
Define the standard types used by Casacore.
Definition aipstype.h:40
size_t size() const
Definition Block.h:566
const Bool True
Definition aipstype.h:41