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
62
63class StreamIO: public ByteIO
64{
65public:
66 // Construct a stream that is attached to the specified host on the specified
67 // portnumber. Name lookup is not currently done so that the dotted quad
68 // notation must be used.
69 StreamIO(const String& hostname, uShort portNumber);
70
71 // The destructor closes the file.
72 virtual ~StreamIO();
73
74 // Write the specified number of bytes.
75 virtual void write(Int64 size, const void* buf);
76
77 // Read <src>size</src> bytes from the tape. Returns the number of bytes
78 // actually read or a negative number if an error occured. Will throw an
79 // exception (AipsError) if the requested number of bytes could not be read,
80 // or an error occured, unless throwException is set to False.
81 virtual Int64 read(Int64 size, void* buf, Bool throwException=True);
82
83 // Get the length of the stream. Not a meaningful function for this
84 // class and this function always returns -1.
85 virtual Int64 length();
86
87 // Is the stream readable? This function always returns True.
88 virtual Bool isReadable() const;
89
90 // Is the stream writable? This function always returns True.
91 virtual Bool isWritable() const;
92
93 // Is the stream seekable? This function always returns False.
94 virtual Bool isSeekable() const;
95
96protected:
97 // Reset the position pointer to the given value. It returns the new
98 // position. As stream devices are not seekable calling this function will
99 // always throw an AipsError exception.
101
102private:
103 // The following functions are made private so that the compiler does not
104 // generate default ones. They cannot be used and are not defined.
105 StreamIO (const StreamIO& other);
107
109};
110
111} //# NAMESPACE CASACORE - END
112
113#endif
SeekOption
Define the possible seek options.
Definition ByteIO.h:80
virtual ~StreamIO()
The destructor closes the file.
virtual Bool isReadable() const
Is the stream readable? This function always returns True.
virtual Bool isSeekable() const
Is the stream seekable? This function always returns False.
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? This function always returns True.
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:223
this file contains all the compiler specific defines
Definition mainpage.dox:28
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
const Bool True
Definition aipstype.h:41