Loading...
Searching...
No Matches
casacore::ByteIO Class Referenceabstract
casa package (libcasa_casa) » IO_module

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 (Int64 size, const void *buf)=0
| Write size bytes to the byte stream.
virtual void | pwrite (Int64 size, Int64 offset, const void *buf)
| Write size bytes to the byte stream at offset.
virtual Int64 | read (Int64 size, void *buf, Bool throwException=True)=0
| Read size bytes from the byte stream.
virtual Int64 | pread (Int64 size, Int64 offset, void *buf, Bool throwException=True)
| Like read but reads from offset of start of the file The file offset is not changed.
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 void | flush ()
| Flush the data to the file.
virtual void | fsync ()
| Fsync the file (i.e.
virtual void | resync ()
| Resync the file (i.e.
virtual void | truncate (Int64 size)
| Truncate the file to the given size.
virtual String | fileName () const
| Get the file name of the file attached.
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

## Detailed Description

Abstract base class for IO on a byte stream.

### Intended use:

Public interface

### Review Status

Reviewed By:
  Friso Olnon
Date Reviewed:
  1996/11/06
Test programs:
  tByteIO

### Synopsis

ByteIO is the abstract base class for all classes doing IO on byte streams. Examples of derived classes are RegularFileIO and MemoryIO.

ByteIO contains two enumerations, which define the possible open and seek options on byte streams. These enumerations are used throughout the IO framework.

### Motivation

Make polymorphic operations on byte streams possible.

Definition at line 59 of file ByteIO.h.

## Member Enumeration Documentation

## OpenOption

enum casacore::ByteIO::OpenOption

Define the possible ByteIO open options.

Enumerator
Old |
Update | read/write; file must exist.
Append | read/write; create file if not exist.
New | read/write; create file if not exist.
NewNoReplace | read/write; file may not exist yet.
Scratch | read/write; delete file at close.
Delete | read/write; file must exist; delete at close.

Definition at line 63 of file ByteIO.h.

## SeekOption

enum casacore::ByteIO::SeekOption

Define the possible seek options.

Enumerator
Begin | Seek from beginning of file.
Current | Seek from current position.
End | Seek from the end of the file.

Definition at line 80 of file ByteIO.h.

## Constructor & Destructor Documentation

## ByteIO() [1/2]

casacore::ByteIO::ByteIO | ( |  | ) |

inline

The constructor does nothing.

Definition at line 174 of file ByteIO.h.

Referenced by ByteIO(), isSeekable(), and operator=().

## ~ByteIO()

virtual casacore::ByteIO::~ByteIO | ( |  | ) |

virtual

## ByteIO() [2/2]

casacore::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 177 of file ByteIO.h.

References ByteIO().

## Member Function Documentation

## doSeek()

virtual Int64 casacore::ByteIO::doSeek | ( | Int64 | offset,
|  | ByteIO::SeekOption | )

protected pure virtual

Implemented in casacore::FilebufIO, casacore::FiledesIO, casacore::MemoryIO, casacore::MFFileIO, casacore::MMapfdIO, casacore::StreamIO, and casacore::TapeIO.

References casacore::offset().

Referenced by seek(), and seek().

## fileName()

virtual String casacore::ByteIO::fileName | ( |  | ) | const

virtual

Get the file name of the file attached.

The default implementation returns an empty string.

Reimplemented in casacore::FilebufIO, casacore::FiledesIO, casacore::MFFileIO, casacore::RegularFileIO, and casacore::TapeIO.

## flush()

virtual void casacore::ByteIO::flush | ( |  | ) |

virtual

Flush the data to the file.

The default implementation does nothing.

Reimplemented in casacore::FilebufIO, casacore::MFFileIO, and casacore::MMapfdIO.

## fsync()

virtual void casacore::ByteIO::fsync | ( |  | ) |

virtual

Fsync the file (i.e.

force the data to be physically written). The default implementation does nothing.

Reimplemented in casacore::FiledesIO, and casacore::MFFileIO.

## isReadable()

virtual Bool casacore::ByteIO::isReadable | ( |  | ) | const

pure virtual

Is the byte stream readable?

Implemented in casacore::FilebufIO, casacore::FiledesIO, casacore::MemoryIO, casacore::MFFileIO, casacore::StreamIO, and casacore::TapeIO.

## isSeekable()

virtual Bool casacore::ByteIO::isSeekable | ( |  | ) | const

pure virtual

Is the byte stream seekable?

Implemented in casacore::FilebufIO, casacore::FiledesIO, casacore::MemoryIO, casacore::MFFileIO, casacore::StreamIO, and casacore::TapeIO.

References ByteIO().

## isWritable()

virtual Bool casacore::ByteIO::isWritable | ( |  | ) | const

pure virtual

Is the byte stream writable?

Implemented in casacore::FilebufIO, casacore::FiledesIO, casacore::MemoryIO, casacore::MFFileIO, casacore::StreamIO, and casacore::TapeIO.

## length()

virtual Int64 casacore::ByteIO::length | ( |  | ) |

pure virtual

Get the length of the byte stream.

Implemented in casacore::FilebufIO, casacore::FiledesIO, casacore::MemoryIO, casacore::MFFileIO, casacore::StreamIO, and casacore::TapeIO.

## operator=()

ByteIO & casacore::ByteIO::operator= | ( | const ByteIO & | byteIO | ) |

inline protected

Definition at line 180 of file ByteIO.h.

References ByteIO().

## pread()

virtual Int64 casacore::ByteIO::pread | ( | Int64 | size,
|  | Int64 | offset,
|  | void * | buf,
|  | Bool | throwException = True )

virtual

Like read but reads from offset of start of the file The file offset is not changed.

Reimplemented in casacore::FiledesIO.

References casacore::offset(), casacore::size(), and casacore::True.

## pwrite()

virtual void casacore::ByteIO::pwrite | ( | Int64 | size,
|  | Int64 | offset,
|  | const void * | buf )

virtual

Write size bytes to the byte stream at offset.

The file offset is not changed

Reimplemented in casacore::FiledesIO.

References casacore::offset(), and casacore::size().

## read()

virtual Int64 casacore::ByteIO::read | ( | Int64 | 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 occurred. Will also throw an Exception (AipsError) if the requested number of bytes could not be read unless throwException is set to False.

Implemented in casacore::FilebufIO, casacore::FiledesIO, casacore::MemoryIO, casacore::MFFileIO, casacore::MMapfdIO, casacore::StreamIO, and casacore::TapeIO.

References casacore::size(), and casacore::True.

## reopenRW()

virtual void casacore::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 casacore::FileUnbufferedIO, casacore::MFFileIO, and casacore::RegularFileIO.

References Begin, and casacore::offset().

## resync()

virtual void casacore::ByteIO::resync | ( |  | ) |

virtual

Resync the file (i.e.

empty the current buffer). The default implementation does nothing.

Reimplemented in casacore::FilebufIO.

## seek() [1/2]

Int64 casacore::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 189 of file ByteIO.h.

References doSeek(), and casacore::offset().

## seek() [2/2]

Int64 casacore::ByteIO::seek | ( | Int64 | offset,
|  | ByteIO::SeekOption | option = ByteIO::Begin )

inline

Definition at line 185 of file ByteIO.h.

References doSeek(), and casacore::offset().

## truncate()

virtual void casacore::ByteIO::truncate | ( | Int64 | size | ) |

virtual

Truncate the file to the given size.

The default implementation does nothing.

Reimplemented in casacore::FilebufIO, casacore::FiledesIO, and casacore::MFFileIO.

References casacore::size().

## write()

virtual void casacore::ByteIO::write | ( | Int64 | size,
|  | const void * | buf )

pure virtual

Write size bytes to the byte stream.

Implemented in casacore::FilebufIO, casacore::FiledesIO, casacore::MemoryIO, casacore::MFFileIO, casacore::MMapfdIO, casacore::StreamIO, and casacore::TapeIO.

References casacore::size().

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

- casa/IO/ByteIO.h