casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
Public Types | Public Member Functions | Protected Member Functions
casa::ByteIO Class Reference

Abstract base class for IO on a byte stream. More...

#include <ByteIO.h>

Inheritance diagram for casa::ByteIO:
casa::FilebufIO casa::FiledesIO casa::LargeFilebufIO casa::LargeFiledesIO casa::MemoryIO casa::StreamIO casa::TapeIO casa::RegularFileIO casa::LargeRegularFileIO casa::MMapfdIO casa::MMapIO

List of all members.

Public Types

enum  OpenOption {
 Define the possible ByteIO open options. More...
enum  SeekOption {
 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).
ByteIOoperator= (const ByteIO &byteIO)
virtual Int64 doSeek (Int64 offset, ByteIO::SeekOption)=0

Detailed Description

Abstract base class for IO on a byte stream.

Intended use:

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> 

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 .
ByteIO contains two enumerations, which define the possible
open and seek options on byte streams. These enumerations
are used throughout the IO framework.

Make polymorphic operations on byte streams possible.

Definition at line 60 of file ByteIO.h.

Member Enumeration Documentation

Define the possible ByteIO open options.


read/write; file must exist.


read/write; create file if not exist.


read/write; create file if not exist.


read/write; file may not exist yet.


read/write; delete file at close.


read/write; file must exist; delete at close.

Definition at line 64 of file ByteIO.h.

Define the possible seek options.


Seek from beginning of file.


Seek from current position.


Seek from the end of the file.

Definition at line 81 of file ByteIO.h.

Constructor & Destructor Documentation

casa::ByteIO::ByteIO ( ) [inline]

The constructor does nothing.

Definition at line 147 of file ByteIO.h.

virtual casa::ByteIO::~ByteIO ( ) [virtual]
casa::ByteIO::ByteIO ( const ByteIO byteIO) [inline, protected]

Make copy constructor and assignment protected, so a user cannot use them (but a derived class can).

Definition at line 150 of file ByteIO.h.

Member Function Documentation

virtual Int64 casa::ByteIO::doSeek ( Int64  offset,
) [protected, pure virtual]
virtual Bool casa::ByteIO::isReadable ( ) const [pure virtual]
virtual Bool casa::ByteIO::isSeekable ( ) const [pure virtual]
virtual Bool casa::ByteIO::isWritable ( ) const [pure virtual]
virtual Int64 casa::ByteIO::length ( ) [pure virtual]
ByteIO & casa::ByteIO::operator= ( const ByteIO byteIO) [inline, protected]

Definition at line 153 of file ByteIO.h.

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]

This function sets the position on the given offset.

The seek option defines from which file position the seek is done. -1 is returned if not seekable.

Definition at line 162 of file ByteIO.h.

References doSeek().

Int64 casa::ByteIO::seek ( Int64  offset,
ByteIO::SeekOption  option = ByteIO::Begin 
) [inline]

Definition at line 158 of file ByteIO.h.

References doSeek().

virtual void casa::ByteIO::write ( uInt  size,
const void *  buf 
) [pure virtual]

The documentation for this class was generated from the following file: