casacore
|
#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. More... | |
virtual | ~ByteIO () |
virtual void | write (Int64 size, const void *buf)=0 |
Write size bytes to the byte stream. More... | |
virtual void | pwrite (Int64 size, Int64 offset, const void *buf) |
Write size bytes to the byte stream at offset . More... | |
virtual Int64 | read (Int64 size, void *buf, Bool throwException=True)=0 |
Read size bytes from the byte stream. More... | |
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. More... | |
virtual void | reopenRW () |
Reopen the underlying IO stream for read/write access. More... | |
Int64 | seek (Int offset, ByteIO::SeekOption=ByteIO::Begin) |
This function sets the position on the given offset. More... | |
Int64 | seek (Int64 offset, ByteIO::SeekOption=ByteIO::Begin) |
virtual void | flush () |
Flush the data to the file. More... | |
virtual void | fsync () |
Fsync the file (i.e. More... | |
virtual void | resync () |
Resync the file (i.e. More... | |
virtual String | fileName () const |
Get the file name of the file attached. More... | |
virtual Int64 | length ()=0 |
Get the length of the byte stream. More... | |
virtual Bool | isReadable () const =0 |
Is the byte stream readable? More... | |
virtual Bool | isWritable () const =0 |
Is the byte stream writable? More... | |
virtual Bool | isSeekable () const =0 |
Is the byte stream seekable? More... | |
Protected Member Functions | |
ByteIO (const ByteIO &byteIO) | |
Make copy constructor and assignment protected, so a user cannot use them (but a derived class can). More... | |
ByteIO & | operator= (const ByteIO &byteIO) |
virtual Int64 | doSeek (Int64 offset, ByteIO::SeekOption)=0 |
Abstract base class for IO on a byte stream.
Public interface
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.
Make polymorphic operations on byte streams possible.
Define the possible ByteIO open options.
|
inline |
|
virtual |
|
inlineprotected |
|
protectedpure virtual |
Implemented in casacore::TapeIO, casacore::StreamIO, casacore::MMapfdIO, casacore::MFFileIO, casacore::MemoryIO, casacore::FiledesIO, and casacore::FilebufIO.
Referenced by seek().
|
virtual |
Get the file name of the file attached.
The default implementation returns an empty string.
Reimplemented in casacore::TapeIO, casacore::RegularFileIO, casacore::MFFileIO, casacore::FiledesIO, and casacore::FilebufIO.
|
virtual |
Flush the data to the file.
The default implementation does nothing.
Reimplemented in casacore::MMapfdIO, casacore::MFFileIO, and casacore::FilebufIO.
|
virtual |
Fsync the file (i.e.
force the data to be physically written). The default implementation does nothing.
Reimplemented in casacore::MFFileIO, and casacore::FiledesIO.
|
pure virtual |
Is the byte stream readable?
Implemented in casacore::TapeIO, casacore::StreamIO, casacore::MFFileIO, casacore::MemoryIO, casacore::FiledesIO, and casacore::FilebufIO.
|
pure virtual |
Is the byte stream seekable?
Implemented in casacore::TapeIO, casacore::StreamIO, casacore::MFFileIO, casacore::MemoryIO, casacore::FiledesIO, and casacore::FilebufIO.
|
pure virtual |
Is the byte stream writable?
Implemented in casacore::TapeIO, casacore::StreamIO, casacore::MFFileIO, casacore::MemoryIO, casacore::FiledesIO, and casacore::FilebufIO.
|
pure virtual |
Get the length of the byte stream.
Implemented in casacore::TapeIO, casacore::StreamIO, casacore::MFFileIO, casacore::MemoryIO, casacore::FiledesIO, and casacore::FilebufIO.
|
virtual |
Like read but reads from offset of start of the file The file offset is not changed.
Reimplemented in casacore::FiledesIO.
Write size
bytes to the byte stream at offset
.
The file offset is not changed
Reimplemented in casacore::FiledesIO.
|
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::TapeIO, casacore::StreamIO, casacore::MMapfdIO, casacore::MFFileIO, casacore::MemoryIO, casacore::FiledesIO, and casacore::FilebufIO.
|
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::RegularFileIO, and casacore::MFFileIO.
Referenced by casacore::StManArrayFile::reopenRW().
|
virtual |
Resync the file (i.e.
empty the current buffer). The default implementation does nothing.
Reimplemented in casacore::FilebufIO.
|
inline |
|
inline |
|
pure virtual |
Write size
bytes to the byte stream.
Implemented in casacore::MFFileIO, casacore::TapeIO, casacore::StreamIO, casacore::MMapfdIO, casacore::MemoryIO, casacore::FiledesIO, and casacore::FilebufIO.