casa
$Rev:20696$
|
Abstract base class for IO on a byte stream. More...
#include <ByteIO.h>
Public Types | |
enum | OpenOption { Old, Update, Append, New, NewNoReplace, Scratch, Delete } |
Define the possible ByteIO open options. More... | |
enum | SeekOption { Begin, Current, End } |
Define the possible seek options. More... | |
Public Member Functions | |
ByteIO () | |
The constructor does nothing. | |
virtual | ~ByteIO () |
virtual void | write (uInt size, const void *buf)=0 |
Write size bytes to the byte stream. | |
virtual Int | read (uInt size, void *buf, Bool throwException=True)=0 |
Read size bytes from the byte stream. | |
virtual void | reopenRW () |
Reopen the underlying IO stream for read/write access. | |
Int64 | seek (Int offset, ByteIO::SeekOption=ByteIO::Begin) |
This function sets the position on the given offset. | |
Int64 | seek (Int64 offset, ByteIO::SeekOption=ByteIO::Begin) |
virtual Int64 | length ()=0 |
Get the length of the byte stream. | |
virtual Bool | isReadable () const =0 |
Is the byte stream readable? | |
virtual Bool | isWritable () const =0 |
Is the byte stream writable? | |
virtual Bool | isSeekable () const =0 |
Is the byte stream seekable? | |
Protected Member Functions | |
ByteIO (const ByteIO &byteIO) | |
Make copy constructor and assignment protected, so a user cannot use them (but a derived class can). | |
ByteIO & | operator= (const ByteIO &byteIO) |
virtual Int64 | doSeek (Int64 offset, ByteIO::SeekOption)=0 |
Abstract base class for IO on a byte stream.
Public interface
<h3>Review Status</h3><dl><dt>Reviewed By:<dd>Friso Olnon<dt>Date Reviewed:<dd>1996/11/06<dt>Test programs:<dd>tByteIO</dl> <h3>Synopsis</h3> ByteIO is the abstract base class for all classes doing IO on byte streams. Examples of derived classes are \link casa::RegularFileIO RegularFileIO \endlink and \link casa::MemoryIO MemoryIO \endlink . <p> ByteIO contains two enumerations, which define the possible open and seek options on byte streams. These enumerations are used throughout the IO framework. <h3>Motivation</h3> Make polymorphic operations on byte streams possible.
Define the possible ByteIO open options.
casa::ByteIO::ByteIO | ( | ) | [inline] |
virtual casa::ByteIO::~ByteIO | ( | ) | [virtual] |
casa::ByteIO::ByteIO | ( | const ByteIO & | byteIO | ) | [inline, protected] |
virtual Int64 casa::ByteIO::doSeek | ( | Int64 | offset, |
ByteIO::SeekOption | |||
) | [protected, pure virtual] |
Implemented in casa::MemoryIO, casa::TapeIO, casa::FilebufIO, casa::LargeFilebufIO, casa::LargeFiledesIO, casa::FiledesIO, casa::MMapfdIO, and casa::StreamIO.
Referenced by seek().
virtual Bool casa::ByteIO::isReadable | ( | ) | const [pure virtual] |
Is the byte stream readable?
Implemented in casa::MemoryIO, casa::TapeIO, casa::FilebufIO, casa::LargeFilebufIO, casa::LargeFiledesIO, casa::FiledesIO, and casa::StreamIO.
virtual Bool casa::ByteIO::isSeekable | ( | ) | const [pure virtual] |
Is the byte stream seekable?
Implemented in casa::MemoryIO, casa::TapeIO, casa::FilebufIO, casa::LargeFilebufIO, casa::LargeFiledesIO, casa::FiledesIO, and casa::StreamIO.
virtual Bool casa::ByteIO::isWritable | ( | ) | const [pure virtual] |
Is the byte stream writable?
Implemented in casa::MemoryIO, casa::TapeIO, casa::FilebufIO, casa::LargeFilebufIO, casa::LargeFiledesIO, casa::FiledesIO, and casa::StreamIO.
virtual Int64 casa::ByteIO::length | ( | ) | [pure virtual] |
Get the length of the byte stream.
Implemented in casa::MemoryIO, casa::TapeIO, casa::FilebufIO, casa::LargeFilebufIO, casa::LargeFiledesIO, casa::FiledesIO, and casa::StreamIO.
virtual Int casa::ByteIO::read | ( | uInt | size, |
void * | buf, | ||
Bool | throwException = True |
||
) | [pure virtual] |
Read size
bytes from the byte stream.
Returns the number of bytes actually read, or a negative number if an error occured. Will also throw an Exception (AipsError) if the requested number of bytes could not be read unless throwException is set to False.
Implemented in casa::MemoryIO, casa::TapeIO, casa::FilebufIO, casa::LargeFilebufIO, casa::LargeFiledesIO, casa::FiledesIO, casa::MMapfdIO, and casa::StreamIO.
virtual void casa::ByteIO::reopenRW | ( | ) | [virtual] |
Reopen the underlying IO stream for read/write access.
Nothing will be done if the stream is writable already. Otherwise it will be reopened and an exception will be thrown if it is not possible to reopen it for read/write access. The default implementation in this base class throws a "not possible" exception if a reopen has to be done.
Reimplemented in casa::LargeRegularFileIO, and casa::RegularFileIO.
Int64 casa::ByteIO::seek | ( | Int | offset, |
ByteIO::SeekOption | option = ByteIO::Begin |
||
) | [inline] |
Int64 casa::ByteIO::seek | ( | Int64 | offset, |
ByteIO::SeekOption | option = ByteIO::Begin |
||
) | [inline] |
virtual void casa::ByteIO::write | ( | uInt | size, |
const void * | buf | ||
) | [pure virtual] |
Write size
bytes to the byte stream.
Implemented in casa::MemoryIO, casa::TapeIO, casa::FilebufIO, casa::LargeFilebufIO, casa::LargeFiledesIO, casa::FiledesIO, casa::MMapfdIO, and casa::StreamIO.