casa
$Rev:20696$
|
00001 //# StreamIO.h: Class for connection oriented IO to/from a socket 00002 //# Copyright (C) 2001 00003 //# Associated Universities, Inc. Washington DC, USA. 00004 //# 00005 //# This library is free software; you can redistribute it and/or modify it 00006 //# under the terms of the GNU Library General Public License as published by 00007 //# the Free Software Foundation; either version 2 of the License, or (at your 00008 //# option) any later version. 00009 //# 00010 //# This library is distributed in the hope that it will be useful, but WITHOUT 00011 //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 00012 //# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public 00013 //# License for more details. 00014 //# 00015 //# You should have received a copy of the GNU Library General Public License 00016 //# along with this library; if not, write to the Free Software Foundation, 00017 //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA. 00018 //# 00019 //# Correspondence concerning AIPS++ should be addressed as follows: 00020 //# Internet email: aips2-request@nrao.edu. 00021 //# Postal address: AIPS++ Project Office 00022 //# National Radio Astronomy Observatory 00023 //# 520 Edgemont Road 00024 //# Charlottesville, VA 22903-2475 USA 00025 //# 00026 //# $Id: StreamIO.h 20551 2009-03-25 00:11:33Z Malte.Marquarding $ 00027 00028 #ifndef CASA_STREAMIO_H 00029 #define CASA_STREAMIO_H 00030 00031 #include <casa/aips.h> 00032 #include <casa/IO/ByteIO.h> 00033 00034 namespace casa { //# NAMESPACE CASA - BEGIN 00035 00036 class String; 00037 00038 // <summary>Class for IO on connection oriented socket</summary> 00039 00040 // <use visibility=export> 00041 00042 // <reviewed reviewer="" date="yyyy/mm/dd" tests="" demos=""> 00043 // </reviewed> 00044 00045 // <prerequisite> 00046 // <li> <linkto class=ByteIO>ByteIO</linkto> class 00047 // <li> Tape descriptors 00048 // </prerequisite> 00049 00050 // <synopsis> 00051 // This class is a specialization of class 00052 // <linkto class=ByteIO>ByteIO</linkto>. It uses a file descriptor 00053 // to read/write data to a Internet (AF_INET) stream. 00054 // <p> 00055 // </synopsis> 00056 00057 // <example> 00058 // </example> 00059 00060 // <motivation> 00061 // This class was needed for the online version of the VLA filler. 00062 // </motivation> 00063 00064 00065 class StreamIO: public ByteIO 00066 { 00067 public: 00068 // Construct a stream that is attached to the specified host on the specified 00069 // portnumber. Name lookup is not currently done so that the dotted quad 00070 // notation must be used. 00071 StreamIO(const String& hostname, uShort portNumber); 00072 00073 // The destructor closes the file. 00074 virtual ~StreamIO(); 00075 00076 // Write the specified number of bytes. 00077 virtual void write(uInt size, const void* buf); 00078 00079 // Read <src>size</src> bytes from the tape. Returns the number of bytes 00080 // actually read or a negative number if an error occured. Will throw an 00081 // exception (AipsError) if the requested number of bytes could not be read, 00082 // or an error occured, unless throwException is set to False. 00083 virtual Int read(uInt size, void* buf, Bool throwException=True); 00084 00085 // Get the length of the stream. Not a meaningful function for this 00086 // class and this function always returns -1. 00087 virtual Int64 length(); 00088 00089 // Is the stream readabale? This function always returns True. 00090 virtual Bool isReadable() const; 00091 00092 // Is the tape device writable? This function always returns True. 00093 virtual Bool isWritable() const; 00094 00095 // Is the tape device seekable? This function always returns False. 00096 virtual Bool isSeekable() const; 00097 00098 protected: 00099 // Reset the position pointer to the given value. It returns the new 00100 // position. As stream devices are not seekable calling this function will 00101 // always throw an AipsError exception. 00102 virtual Int64 doSeek(Int64 offset, ByteIO::SeekOption); 00103 00104 private: 00105 // The following functions are made private so that the compiler does not 00106 // generate default ones. They cannot be used and are not defined. 00107 StreamIO (const StreamIO& other); 00108 StreamIO& operator= (const StreamIO& other); 00109 00110 int itsSockDesc; 00111 }; 00112 00113 } //# NAMESPACE CASA - END 00114 00115 #endif